OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/unittests/test-utils.h" | 5 #include "test/unittests/test-utils.h" |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "test/common/wasm/test-signatures.h" | 9 #include "test/common/wasm/test-signatures.h" |
10 | 10 |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 TestBinop(kExpr##name, sig); \ | 1142 TestBinop(kExpr##name, sig); \ |
1143 } \ | 1143 } \ |
1144 } | 1144 } |
1145 | 1145 |
1146 FOREACH_SIMPLE_OPCODE(DECODE_TEST); | 1146 FOREACH_SIMPLE_OPCODE(DECODE_TEST); |
1147 | 1147 |
1148 #undef DECODE_TEST | 1148 #undef DECODE_TEST |
1149 } | 1149 } |
1150 | 1150 |
1151 TEST_F(AstDecoderTest, MemorySize) { | 1151 TEST_F(AstDecoderTest, MemorySize) { |
1152 byte code[] = {kExprMemorySize}; | 1152 byte code[] = {kExprMemorySize, 0}; |
1153 EXPECT_VERIFIES_C(i_i, code); | 1153 EXPECT_VERIFIES_C(i_i, code); |
1154 EXPECT_FAILURE_C(f_ff, code); | 1154 EXPECT_FAILURE_C(f_ff, code); |
1155 } | 1155 } |
1156 | 1156 |
1157 TEST_F(AstDecoderTest, LoadMemOffset) { | 1157 TEST_F(AstDecoderTest, LoadMemOffset) { |
1158 for (int offset = 0; offset < 128; offset += 7) { | 1158 for (int offset = 0; offset < 128; offset += 7) { |
1159 byte code[] = {kExprI8Const, 0, kExprI32LoadMem, ZERO_ALIGNMENT, | 1159 byte code[] = {kExprI8Const, 0, kExprI32LoadMem, ZERO_ALIGNMENT, |
1160 static_cast<byte>(offset)}; | 1160 static_cast<byte>(offset)}; |
1161 EXPECT_VERIFIES_C(i_i, code); | 1161 EXPECT_VERIFIES_C(i_i, code); |
1162 } | 1162 } |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 } | 1625 } |
1626 } | 1626 } |
1627 } | 1627 } |
1628 } | 1628 } |
1629 | 1629 |
1630 TEST_F(AstDecoderTest, WasmGrowMemory) { | 1630 TEST_F(AstDecoderTest, WasmGrowMemory) { |
1631 TestModuleEnv module_env; | 1631 TestModuleEnv module_env; |
1632 module = &module_env; | 1632 module = &module_env; |
1633 module->origin = kWasmOrigin; | 1633 module->origin = kWasmOrigin; |
1634 | 1634 |
1635 byte code[] = {WASM_UNOP(kExprGrowMemory, WASM_GET_LOCAL(0))}; | 1635 byte code[] = {WASM_GET_LOCAL(0), kExprGrowMemory, 0}; |
1636 EXPECT_VERIFIES_C(i_i, code); | 1636 EXPECT_VERIFIES_C(i_i, code); |
1637 EXPECT_FAILURE_C(i_d, code); | 1637 EXPECT_FAILURE_C(i_d, code); |
1638 } | 1638 } |
1639 | 1639 |
1640 TEST_F(AstDecoderTest, AsmJsGrowMemory) { | 1640 TEST_F(AstDecoderTest, AsmJsGrowMemory) { |
1641 TestModuleEnv module_env; | 1641 TestModuleEnv module_env; |
1642 module = &module_env; | 1642 module = &module_env; |
1643 module->origin = kAsmJsOrigin; | 1643 module->origin = kAsmJsOrigin; |
1644 | 1644 |
1645 byte code[] = {WASM_UNOP(kExprGrowMemory, WASM_GET_LOCAL(0))}; | 1645 byte code[] = {WASM_GET_LOCAL(0), kExprGrowMemory, 0}; |
1646 EXPECT_FAILURE_C(i_i, code); | 1646 EXPECT_FAILURE_C(i_i, code); |
1647 } | 1647 } |
1648 | 1648 |
1649 TEST_F(AstDecoderTest, AsmJsBinOpsCheckOrigin) { | 1649 TEST_F(AstDecoderTest, AsmJsBinOpsCheckOrigin) { |
1650 LocalType float32int32float32[] = {kAstF32, kAstI32, kAstF32}; | 1650 LocalType float32int32float32[] = {kAstF32, kAstI32, kAstF32}; |
1651 FunctionSig sig_f_if(1, 2, float32int32float32); | 1651 FunctionSig sig_f_if(1, 2, float32int32float32); |
1652 LocalType float64int32float64[] = {kAstF64, kAstI32, kAstF64}; | 1652 LocalType float64int32float64[] = {kAstF64, kAstI32, kAstF64}; |
1653 FunctionSig sig_d_id(1, 2, float64int32float64); | 1653 FunctionSig sig_d_id(1, 2, float64int32float64); |
1654 struct { | 1654 struct { |
1655 WasmOpcode op; | 1655 WasmOpcode op; |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2309 | 2309 |
2310 TEST_F(WasmOpcodeLengthTest, MiscExpressions) { | 2310 TEST_F(WasmOpcodeLengthTest, MiscExpressions) { |
2311 EXPECT_LENGTH(2, kExprI8Const); | 2311 EXPECT_LENGTH(2, kExprI8Const); |
2312 EXPECT_LENGTH(5, kExprF32Const); | 2312 EXPECT_LENGTH(5, kExprF32Const); |
2313 EXPECT_LENGTH(9, kExprF64Const); | 2313 EXPECT_LENGTH(9, kExprF64Const); |
2314 EXPECT_LENGTH(2, kExprGetLocal); | 2314 EXPECT_LENGTH(2, kExprGetLocal); |
2315 EXPECT_LENGTH(2, kExprSetLocal); | 2315 EXPECT_LENGTH(2, kExprSetLocal); |
2316 EXPECT_LENGTH(2, kExprGetGlobal); | 2316 EXPECT_LENGTH(2, kExprGetGlobal); |
2317 EXPECT_LENGTH(2, kExprSetGlobal); | 2317 EXPECT_LENGTH(2, kExprSetGlobal); |
2318 EXPECT_LENGTH(2, kExprCallFunction); | 2318 EXPECT_LENGTH(2, kExprCallFunction); |
2319 EXPECT_LENGTH(2, kExprCallIndirect); | 2319 EXPECT_LENGTH(3, kExprCallIndirect); |
2320 } | 2320 } |
2321 | 2321 |
2322 TEST_F(WasmOpcodeLengthTest, I32Const) { | 2322 TEST_F(WasmOpcodeLengthTest, I32Const) { |
2323 EXPECT_LENGTH_N(2, kExprI32Const, U32V_1(1)); | 2323 EXPECT_LENGTH_N(2, kExprI32Const, U32V_1(1)); |
2324 EXPECT_LENGTH_N(3, kExprI32Const, U32V_2(999)); | 2324 EXPECT_LENGTH_N(3, kExprI32Const, U32V_2(999)); |
2325 EXPECT_LENGTH_N(4, kExprI32Const, U32V_3(9999)); | 2325 EXPECT_LENGTH_N(4, kExprI32Const, U32V_3(9999)); |
2326 EXPECT_LENGTH_N(5, kExprI32Const, U32V_4(999999)); | 2326 EXPECT_LENGTH_N(5, kExprI32Const, U32V_4(999999)); |
2327 EXPECT_LENGTH_N(6, kExprI32Const, U32V_5(99999999)); | 2327 EXPECT_LENGTH_N(6, kExprI32Const, U32V_5(99999999)); |
2328 } | 2328 } |
2329 | 2329 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2368 EXPECT_LENGTH(3, kExprI32StoreMem); | 2368 EXPECT_LENGTH(3, kExprI32StoreMem); |
2369 EXPECT_LENGTH(3, kExprI64StoreMem8); | 2369 EXPECT_LENGTH(3, kExprI64StoreMem8); |
2370 EXPECT_LENGTH(3, kExprI64StoreMem16); | 2370 EXPECT_LENGTH(3, kExprI64StoreMem16); |
2371 EXPECT_LENGTH(3, kExprI64StoreMem32); | 2371 EXPECT_LENGTH(3, kExprI64StoreMem32); |
2372 EXPECT_LENGTH(3, kExprI64StoreMem); | 2372 EXPECT_LENGTH(3, kExprI64StoreMem); |
2373 EXPECT_LENGTH(3, kExprF32StoreMem); | 2373 EXPECT_LENGTH(3, kExprF32StoreMem); |
2374 EXPECT_LENGTH(3, kExprF64StoreMem); | 2374 EXPECT_LENGTH(3, kExprF64StoreMem); |
2375 } | 2375 } |
2376 | 2376 |
2377 TEST_F(WasmOpcodeLengthTest, MiscMemExpressions) { | 2377 TEST_F(WasmOpcodeLengthTest, MiscMemExpressions) { |
2378 EXPECT_LENGTH(1, kExprMemorySize); | 2378 EXPECT_LENGTH(2, kExprMemorySize); |
2379 EXPECT_LENGTH(1, kExprGrowMemory); | 2379 EXPECT_LENGTH(2, kExprGrowMemory); |
2380 } | 2380 } |
2381 | 2381 |
2382 TEST_F(WasmOpcodeLengthTest, SimpleExpressions) { | 2382 TEST_F(WasmOpcodeLengthTest, SimpleExpressions) { |
2383 EXPECT_LENGTH(1, kExprI32Add); | 2383 EXPECT_LENGTH(1, kExprI32Add); |
2384 EXPECT_LENGTH(1, kExprI32Sub); | 2384 EXPECT_LENGTH(1, kExprI32Sub); |
2385 EXPECT_LENGTH(1, kExprI32Mul); | 2385 EXPECT_LENGTH(1, kExprI32Mul); |
2386 EXPECT_LENGTH(1, kExprI32DivS); | 2386 EXPECT_LENGTH(1, kExprI32DivS); |
2387 EXPECT_LENGTH(1, kExprI32DivU); | 2387 EXPECT_LENGTH(1, kExprI32DivU); |
2388 EXPECT_LENGTH(1, kExprI32RemS); | 2388 EXPECT_LENGTH(1, kExprI32RemS); |
2389 EXPECT_LENGTH(1, kExprI32RemU); | 2389 EXPECT_LENGTH(1, kExprI32RemU); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2669 iter.next(); | 2669 iter.next(); |
2670 EXPECT_TRUE(iter.has_next()); | 2670 EXPECT_TRUE(iter.has_next()); |
2671 EXPECT_EQ(kExprI8Const, iter.current()); | 2671 EXPECT_EQ(kExprI8Const, iter.current()); |
2672 iter.next(); | 2672 iter.next(); |
2673 EXPECT_FALSE(iter.has_next()); | 2673 EXPECT_FALSE(iter.has_next()); |
2674 } | 2674 } |
2675 | 2675 |
2676 } // namespace wasm | 2676 } // namespace wasm |
2677 } // namespace internal | 2677 } // namespace internal |
2678 } // namespace v8 | 2678 } // namespace v8 |
OLD | NEW |