diff options
Diffstat (limited to 'deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc')
-rw-r--r-- | deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc b/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc index 919ce8e234..cb452445bf 100644 --- a/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc +++ b/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc @@ -6,7 +6,7 @@ #include "src/v8.h" -#include "test/cctest/wasm/test-signatures.h" +#include "test/common/wasm/test-signatures.h" #include "src/bit-vector.h" #include "src/objects.h" @@ -39,7 +39,7 @@ TEST_F(WasmLoopAssignmentAnalyzerTest, Empty0) { } TEST_F(WasmLoopAssignmentAnalyzerTest, Empty1) { - byte code[] = {kExprLoop, 0}; + byte code[] = {kExprLoop, kLocalVoid, 0}; for (int i = 0; i < 5; i++) { BitVector* assigned = Analyze(code, code + arraysize(code)); for (int j = 0; j < assigned->length(); j++) { @@ -60,6 +60,17 @@ TEST_F(WasmLoopAssignmentAnalyzerTest, One) { } } +TEST_F(WasmLoopAssignmentAnalyzerTest, TeeOne) { + num_locals = 5; + for (int i = 0; i < 5; i++) { + byte code[] = {WASM_LOOP(WASM_TEE_LOCAL(i, WASM_ZERO))}; + BitVector* assigned = Analyze(code, code + arraysize(code)); + for (int j = 0; j < assigned->length(); j++) { + CHECK_EQ(j == i, assigned->Contains(j)); + } + } +} + TEST_F(WasmLoopAssignmentAnalyzerTest, OneBeyond) { num_locals = 5; for (int i = 0; i < 5; i++) { @@ -98,24 +109,10 @@ TEST_F(WasmLoopAssignmentAnalyzerTest, NestedIf) { } } -static byte LEBByte(uint32_t val, byte which) { - byte b = (val >> (which * 7)) & 0x7F; - if (val >> ((which + 1) * 7)) b |= 0x80; - return b; -} - TEST_F(WasmLoopAssignmentAnalyzerTest, BigLocal) { num_locals = 65000; for (int i = 13; i < 65000; i = static_cast<int>(i * 1.5)) { - byte code[] = {kExprLoop, - 1, - kExprSetLocal, - LEBByte(i, 0), - LEBByte(i, 1), - LEBByte(i, 2), - 11, - 12, - 13}; + byte code[] = {WASM_LOOP(WASM_I8(11), kExprSetLocal, U32V_3(i))}; BitVector* assigned = Analyze(code, code + arraysize(code)); for (int j = 0; j < assigned->length(); j++) { @@ -172,7 +169,7 @@ TEST_F(WasmLoopAssignmentAnalyzerTest, Loop2) { WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO, WASM_GET_LOCAL(kSum)), WASM_GET_LOCAL(kIter))}; - BitVector* assigned = Analyze(code + 1, code + arraysize(code)); + BitVector* assigned = Analyze(code + 2, code + arraysize(code)); for (int j = 0; j < assigned->length(); j++) { bool expected = j == kIter || j == kSum; CHECK_EQ(expected, assigned->Contains(j)); @@ -180,13 +177,21 @@ TEST_F(WasmLoopAssignmentAnalyzerTest, Loop2) { } TEST_F(WasmLoopAssignmentAnalyzerTest, Malformed) { - byte code[] = {kExprLoop, kExprF32Neg, kExprBrTable, 0x0e, 'h', 'e', - 'l', 'l', 'o', ',', ' ', 'w', - 'o', 'r', 'l', 'd', '!'}; + byte code[] = {kExprLoop, kLocalVoid, kExprF32Neg, kExprBrTable, 0x0e, 'h', + 'e', 'l', 'l', 'o', ',', ' ', + 'w', 'o', 'r', 'l', 'd', '!'}; BitVector* assigned = Analyze(code, code + arraysize(code)); CHECK_NULL(assigned); } +TEST_F(WasmLoopAssignmentAnalyzerTest, regress_642867) { + static const byte code[] = { + WASM_LOOP(WASM_ZERO, kExprSetLocal, 0xfa, 0xff, 0xff, 0xff, + 0x0f)}; // local index LEB128 0xfffffffa + // Just make sure that the analysis does not crash. + Analyze(code, code + arraysize(code)); +} + } // namespace wasm } // namespace internal } // namespace v8 |