Index: test/unittests/wasm/loop-assignment-analysis-unittest.cc |
diff --git a/test/unittests/wasm/loop-assignment-analysis-unittest.cc b/test/unittests/wasm/loop-assignment-analysis-unittest.cc |
index f4e4be5fb2f636eeb3d992a0ad60769b3c5e804f..9c89d5df586fb13ea1936f4ad44affcb8b3e3b94 100644 |
--- a/test/unittests/wasm/loop-assignment-analysis-unittest.cc |
+++ b/test/unittests/wasm/loop-assignment-analysis-unittest.cc |
@@ -39,7 +39,7 @@ |
} |
TEST_F(WasmLoopAssignmentAnalyzerTest, Empty1) { |
- byte code[] = {kExprLoop, kLocalVoid, 0}; |
+ byte code[] = {kExprLoop, 0}; |
for (int i = 0; i < 5; i++) { |
BitVector* assigned = Analyze(code, code + arraysize(code)); |
for (int j = 0; j < assigned->length(); j++) { |
@@ -53,17 +53,6 @@ |
num_locals = 5; |
for (int i = 0; i < 5; i++) { |
byte code[] = {WASM_LOOP(WASM_SET_ZERO(i))}; |
- 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, 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)); |
@@ -109,10 +98,24 @@ |
} |
} |
+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[] = {WASM_LOOP(WASM_I8(11), kExprSetLocal, U32V_3(i))}; |
+ byte code[] = {kExprLoop, |
+ 1, |
+ kExprSetLocal, |
+ LEBByte(i, 0), |
+ LEBByte(i, 1), |
+ LEBByte(i, 2), |
+ 11, |
+ 12, |
+ 13}; |
BitVector* assigned = Analyze(code, code + arraysize(code)); |
for (int j = 0; j < assigned->length(); j++) { |
@@ -169,7 +172,7 @@ |
WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO, WASM_GET_LOCAL(kSum)), |
WASM_GET_LOCAL(kIter))}; |
- BitVector* assigned = Analyze(code + 2, code + arraysize(code)); |
+ BitVector* assigned = Analyze(code + 1, code + arraysize(code)); |
for (int j = 0; j < assigned->length(); j++) { |
bool expected = j == kIter || j == kSum; |
CHECK_EQ(expected, assigned->Contains(j)); |
@@ -177,9 +180,9 @@ |
} |
TEST_F(WasmLoopAssignmentAnalyzerTest, Malformed) { |
- byte code[] = {kExprLoop, kLocalVoid, kExprF32Neg, kExprBrTable, 0x0e, 'h', |
- 'e', 'l', 'l', 'o', ',', ' ', |
- 'w', 'o', 'r', 'l', 'd', '!'}; |
+ byte code[] = {kExprLoop, kExprF32Neg, kExprBrTable, 0x0e, 'h', 'e', |
+ 'l', 'l', 'o', ',', ' ', 'w', |
+ 'o', 'r', 'l', 'd', '!'}; |
BitVector* assigned = Analyze(code, code + arraysize(code)); |
CHECK_NULL(assigned); |
} |