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/cctest/wasm/test-signatures.h" | 9 #include "test/cctest/wasm/test-signatures.h" |
10 | 10 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 byte code[] = {kExprI64Const, 0, 0, 0, 0, 0, 0, 0, 0}; | 244 byte code[] = {kExprI64Const, 0, 0, 0, 0, 0, 0, 0, 0}; |
245 int64_t* ptr = reinterpret_cast<int64_t*>(code + 1); | 245 int64_t* ptr = reinterpret_cast<int64_t*>(code + 1); |
246 const int kInc = 4498211; | 246 const int kInc = 4498211; |
247 for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) { | 247 for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) { |
248 *ptr = (static_cast<int64_t>(i) << 32) | i; | 248 *ptr = (static_cast<int64_t>(i) << 32) | i; |
249 EXPECT_VERIFIES(&env_l_l, code); | 249 EXPECT_VERIFIES(&env_l_l, code); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 | 253 |
| 254 // TODO(tizer): Fix on arm and reenable. |
| 255 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 256 |
254 TEST_F(WasmDecoderTest, Float32Const) { | 257 TEST_F(WasmDecoderTest, Float32Const) { |
255 byte code[] = {kExprF32Const, 0, 0, 0, 0}; | 258 byte code[] = {kExprF32Const, 0, 0, 0, 0}; |
256 float* ptr = reinterpret_cast<float*>(code + 1); | 259 float* ptr = reinterpret_cast<float*>(code + 1); |
257 for (int i = 0; i < 30; i++) { | 260 for (int i = 0; i < 30; i++) { |
258 *ptr = i * -7.75f; | 261 *ptr = i * -7.75f; |
259 EXPECT_VERIFIES(&env_f_ff, code); | 262 EXPECT_VERIFIES(&env_f_ff, code); |
260 } | 263 } |
261 } | 264 } |
262 | 265 |
263 | 266 |
264 TEST_F(WasmDecoderTest, Float64Const) { | 267 TEST_F(WasmDecoderTest, Float64Const) { |
265 byte code[] = {kExprF64Const, 0, 0, 0, 0, 0, 0, 0, 0}; | 268 byte code[] = {kExprF64Const, 0, 0, 0, 0, 0, 0, 0, 0}; |
266 double* ptr = reinterpret_cast<double*>(code + 1); | 269 double* ptr = reinterpret_cast<double*>(code + 1); |
267 for (int i = 0; i < 30; i++) { | 270 for (int i = 0; i < 30; i++) { |
268 *ptr = i * 33.45; | 271 *ptr = i * 33.45; |
269 EXPECT_VERIFIES(&env_d_dd, code); | 272 EXPECT_VERIFIES(&env_d_dd, code); |
270 } | 273 } |
271 } | 274 } |
272 | 275 |
| 276 #endif |
| 277 |
273 | 278 |
274 TEST_F(WasmDecoderTest, Int32Const_off_end) { | 279 TEST_F(WasmDecoderTest, Int32Const_off_end) { |
275 byte code[] = {kExprI32Const, 0xaa, 0xbb, 0xcc, 0x44}; | 280 byte code[] = {kExprI32Const, 0xaa, 0xbb, 0xcc, 0x44}; |
276 | 281 |
277 for (int size = 1; size <= 4; size++) { | 282 for (int size = 1; size <= 4; size++) { |
278 Verify(kError, &env_i_i, code, code + size); | 283 Verify(kError, &env_i_i, code, code + size); |
279 } | 284 } |
280 } | 285 } |
281 | 286 |
282 | 287 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 EXPECT_VERIFIES(&env_i_i, code); | 525 EXPECT_VERIFIES(&env_i_i, code); |
521 } | 526 } |
522 | 527 |
523 | 528 |
524 TEST_F(WasmDecoderTest, ExprBlock1b) { | 529 TEST_F(WasmDecoderTest, ExprBlock1b) { |
525 static const byte code[] = {kExprBlock, 1, kExprI8Const, 0}; | 530 static const byte code[] = {kExprBlock, 1, kExprI8Const, 0}; |
526 EXPECT_FAILURE(&env_f_ff, code); | 531 EXPECT_FAILURE(&env_f_ff, code); |
527 } | 532 } |
528 | 533 |
529 | 534 |
| 535 // TODO(tizer): Fix on arm and reenable. |
| 536 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 537 |
530 TEST_F(WasmDecoderTest, ExprBlock1c) { | 538 TEST_F(WasmDecoderTest, ExprBlock1c) { |
531 static const byte code[] = {kExprBlock, 1, kExprF32Const, 0, 0, 0, 0}; | 539 static const byte code[] = {kExprBlock, 1, kExprF32Const, 0, 0, 0, 0}; |
532 EXPECT_VERIFIES(&env_f_ff, code); | 540 EXPECT_VERIFIES(&env_f_ff, code); |
533 } | 541 } |
534 | 542 |
| 543 #endif |
| 544 |
535 | 545 |
536 TEST_F(WasmDecoderTest, IfEmpty) { | 546 TEST_F(WasmDecoderTest, IfEmpty) { |
537 static const byte code[] = {kExprIf, kExprGetLocal, 0, kExprNop}; | 547 static const byte code[] = {kExprIf, kExprGetLocal, 0, kExprNop}; |
538 EXPECT_VERIFIES(&env_v_i, code); | 548 EXPECT_VERIFIES(&env_v_i, code); |
539 } | 549 } |
540 | 550 |
541 | 551 |
542 TEST_F(WasmDecoderTest, IfSet) { | 552 TEST_F(WasmDecoderTest, IfSet) { |
543 static const byte code[] = {kExprIfElse, kExprGetLocal, 0, kExprSetLocal, | 553 static const byte code[] = {kExprIfElse, kExprGetLocal, 0, kExprSetLocal, |
544 0, kExprI8Const, 0, kExprNop}; | 554 0, kExprI8Const, 0, kExprNop}; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 | 697 |
688 | 698 |
689 TEST_F(WasmDecoderTest, ReturnVoid2) { | 699 TEST_F(WasmDecoderTest, ReturnVoid2) { |
690 static const byte code[] = {kExprBlock, 1, kExprBr, 0, kExprNop}; | 700 static const byte code[] = {kExprBlock, 1, kExprBr, 0, kExprNop}; |
691 EXPECT_VERIFIES(&env_v_v, code); | 701 EXPECT_VERIFIES(&env_v_v, code); |
692 EXPECT_FAILURE(&env_i_i, code); | 702 EXPECT_FAILURE(&env_i_i, code); |
693 EXPECT_FAILURE(&env_i_f, code); | 703 EXPECT_FAILURE(&env_i_f, code); |
694 } | 704 } |
695 | 705 |
696 | 706 |
| 707 // TODO(tizer): Fix on arm and reenable. |
| 708 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 709 |
697 TEST_F(WasmDecoderTest, ReturnVoid3) { | 710 TEST_F(WasmDecoderTest, ReturnVoid3) { |
698 EXPECT_VERIFIES_INLINE(&env_v_v, kExprI8Const, 0); | 711 EXPECT_VERIFIES_INLINE(&env_v_v, kExprI8Const, 0); |
699 EXPECT_VERIFIES_INLINE(&env_v_v, kExprI32Const, 0, 0, 0, 0); | 712 EXPECT_VERIFIES_INLINE(&env_v_v, kExprI32Const, 0, 0, 0, 0); |
700 EXPECT_VERIFIES_INLINE(&env_v_v, kExprI64Const, 0, 0, 0, 0, 0, 0, 0, 0); | 713 EXPECT_VERIFIES_INLINE(&env_v_v, kExprI64Const, 0, 0, 0, 0, 0, 0, 0, 0); |
701 EXPECT_VERIFIES_INLINE(&env_v_v, kExprF32Const, 0, 0, 0, 0); | 714 EXPECT_VERIFIES_INLINE(&env_v_v, kExprF32Const, 0, 0, 0, 0); |
702 EXPECT_VERIFIES_INLINE(&env_v_v, kExprF64Const, 0, 0, 0, 0, 0, 0, 0, 0); | 715 EXPECT_VERIFIES_INLINE(&env_v_v, kExprF64Const, 0, 0, 0, 0, 0, 0, 0, 0); |
703 | 716 |
704 EXPECT_VERIFIES_INLINE(&env_v_i, kExprGetLocal, 0); | 717 EXPECT_VERIFIES_INLINE(&env_v_i, kExprGetLocal, 0); |
705 } | 718 } |
706 | 719 |
| 720 #endif |
| 721 |
707 | 722 |
708 TEST_F(WasmDecoderTest, Unreachable1) { | 723 TEST_F(WasmDecoderTest, Unreachable1) { |
709 EXPECT_VERIFIES_INLINE(&env_v_v, kExprUnreachable); | 724 EXPECT_VERIFIES_INLINE(&env_v_v, kExprUnreachable); |
710 EXPECT_VERIFIES_INLINE(&env_v_v, kExprUnreachable, kExprUnreachable); | 725 EXPECT_VERIFIES_INLINE(&env_v_v, kExprUnreachable, kExprUnreachable); |
711 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_BLOCK(2, WASM_UNREACHABLE, WASM_ZERO)); | 726 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_BLOCK(2, WASM_UNREACHABLE, WASM_ZERO)); |
712 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_BLOCK(2, WASM_BR(0), WASM_ZERO)); | 727 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_BLOCK(2, WASM_BR(0), WASM_ZERO)); |
713 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(2, WASM_UNREACHABLE, WASM_ZERO)); | 728 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(2, WASM_UNREACHABLE, WASM_ZERO)); |
714 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(2, WASM_BR(0), WASM_ZERO)); | 729 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(2, WASM_BR(0), WASM_ZERO)); |
715 } | 730 } |
716 | 731 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 VERIFY(WASM_IF(WASM_GET_LOCAL(0), WASM_NOP)); | 874 VERIFY(WASM_IF(WASM_GET_LOCAL(0), WASM_NOP)); |
860 VERIFY(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP)); | 875 VERIFY(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP)); |
861 VERIFY(WASM_NOP); | 876 VERIFY(WASM_NOP); |
862 VERIFY(WASM_BLOCK(1, WASM_NOP)); | 877 VERIFY(WASM_BLOCK(1, WASM_NOP)); |
863 VERIFY(WASM_LOOP(1, WASM_NOP)); | 878 VERIFY(WASM_LOOP(1, WASM_NOP)); |
864 VERIFY(WASM_LOOP(1, WASM_BREAK(0))); | 879 VERIFY(WASM_LOOP(1, WASM_BREAK(0))); |
865 VERIFY(WASM_LOOP(1, WASM_CONTINUE(0))); | 880 VERIFY(WASM_LOOP(1, WASM_CONTINUE(0))); |
866 } | 881 } |
867 | 882 |
868 | 883 |
| 884 // TODO(tizer): Fix on arm and reenable. |
| 885 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 886 |
869 TEST_F(WasmDecoderTest, MacrosBreak) { | 887 TEST_F(WasmDecoderTest, MacrosBreak) { |
870 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BREAK(0))); | 888 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BREAK(0))); |
871 | 889 |
872 EXPECT_VERIFIES_INLINE(&env_i_i, WASM_LOOP(1, WASM_BREAKV(0, WASM_ZERO))); | 890 EXPECT_VERIFIES_INLINE(&env_i_i, WASM_LOOP(1, WASM_BREAKV(0, WASM_ZERO))); |
873 EXPECT_VERIFIES_INLINE(&env_l_l, WASM_LOOP(1, WASM_BREAKV(0, WASM_I64(0)))); | 891 EXPECT_VERIFIES_INLINE(&env_l_l, WASM_LOOP(1, WASM_BREAKV(0, WASM_I64(0)))); |
874 EXPECT_VERIFIES_INLINE(&env_f_ff, | 892 EXPECT_VERIFIES_INLINE(&env_f_ff, |
875 WASM_LOOP(1, WASM_BREAKV(0, WASM_F32(0.0)))); | 893 WASM_LOOP(1, WASM_BREAKV(0, WASM_F32(0.0)))); |
876 EXPECT_VERIFIES_INLINE(&env_d_dd, | 894 EXPECT_VERIFIES_INLINE(&env_d_dd, |
877 WASM_LOOP(1, WASM_BREAKV(0, WASM_F64(0.0)))); | 895 WASM_LOOP(1, WASM_BREAKV(0, WASM_F64(0.0)))); |
878 } | 896 } |
879 | 897 |
| 898 #endif |
| 899 |
880 | 900 |
881 TEST_F(WasmDecoderTest, MacrosContinue) { | 901 TEST_F(WasmDecoderTest, MacrosContinue) { |
882 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_CONTINUE(0))); | 902 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_CONTINUE(0))); |
883 } | 903 } |
884 | 904 |
885 | 905 |
886 TEST_F(WasmDecoderTest, MacrosVariadic) { | 906 TEST_F(WasmDecoderTest, MacrosVariadic) { |
887 VERIFY(WASM_BLOCK(2, WASM_NOP, WASM_NOP)); | 907 VERIFY(WASM_BLOCK(2, WASM_NOP, WASM_NOP)); |
888 VERIFY(WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_NOP)); | 908 VERIFY(WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_NOP)); |
889 VERIFY(WASM_LOOP(2, WASM_NOP, WASM_NOP)); | 909 VERIFY(WASM_LOOP(2, WASM_NOP, WASM_NOP)); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 module_env.AddFunction(sigs.i_i()); | 1258 module_env.AddFunction(sigs.i_i()); |
1239 module_env.AddFunction(sigs.i_ii()); | 1259 module_env.AddFunction(sigs.i_ii()); |
1240 module_env.AddFunction(sigs.f_ff()); | 1260 module_env.AddFunction(sigs.f_ff()); |
1241 | 1261 |
1242 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION0(0)); | 1262 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION0(0)); |
1243 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_ZERO)); | 1263 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_ZERO)); |
1244 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(2, WASM_GET_LOCAL(0))); | 1264 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(2, WASM_GET_LOCAL(0))); |
1245 } | 1265 } |
1246 | 1266 |
1247 | 1267 |
| 1268 // TODO(tizer): Fix on arm and reenable. |
| 1269 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 1270 |
1248 TEST_F(WasmDecoderTest, CallsWithSpilloverArgs) { | 1271 TEST_F(WasmDecoderTest, CallsWithSpilloverArgs) { |
1249 static LocalType a_i_ff[] = {kAstI32, kAstF32, kAstF32}; | 1272 static LocalType a_i_ff[] = {kAstI32, kAstF32, kAstF32}; |
1250 FunctionSig sig_i_ff(1, 2, a_i_ff); | 1273 FunctionSig sig_i_ff(1, 2, a_i_ff); |
1251 FunctionEnv env_i_ff; | 1274 FunctionEnv env_i_ff; |
1252 init_env(&env_i_ff, &sig_i_ff); | 1275 init_env(&env_i_ff, &sig_i_ff); |
1253 | 1276 |
1254 TestModuleEnv module_env; | 1277 TestModuleEnv module_env; |
1255 env_i_ff.module = &module_env; | 1278 env_i_ff.module = &module_env; |
1256 env_i_i.module = &module_env; | 1279 env_i_i.module = &module_env; |
1257 env_f_ff.module = &module_env; | 1280 env_f_ff.module = &module_env; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64(27))); | 1324 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64(27))); |
1302 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(37.2))); | 1325 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(37.2))); |
1303 | 1326 |
1304 module_env.AddFunction(sigs.i_d()); | 1327 module_env.AddFunction(sigs.i_d()); |
1305 | 1328 |
1306 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I8(16))); | 1329 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I8(16))); |
1307 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I64(16))); | 1330 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I64(16))); |
1308 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_F32(17.6))); | 1331 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_F32(17.6))); |
1309 } | 1332 } |
1310 | 1333 |
| 1334 #endif |
| 1335 |
1311 | 1336 |
1312 TEST_F(WasmDecoderTest, SimpleIndirectCalls) { | 1337 TEST_F(WasmDecoderTest, SimpleIndirectCalls) { |
1313 FunctionEnv* env = &env_i_i; | 1338 FunctionEnv* env = &env_i_i; |
1314 TestModuleEnv module_env; | 1339 TestModuleEnv module_env; |
1315 env->module = &module_env; | 1340 env->module = &module_env; |
1316 | 1341 |
1317 byte f0 = module_env.AddSignature(sigs.i_v()); | 1342 byte f0 = module_env.AddSignature(sigs.i_v()); |
1318 byte f1 = module_env.AddSignature(sigs.i_i()); | 1343 byte f1 = module_env.AddSignature(sigs.i_i()); |
1319 byte f2 = module_env.AddSignature(sigs.i_ii()); | 1344 byte f2 = module_env.AddSignature(sigs.i_ii()); |
1320 | 1345 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 1, WASM_BLOCK(1, WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(i)))))}; | 1568 1, WASM_BLOCK(1, WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(i)))))}; |
1544 if (i < 3) { | 1569 if (i < 3) { |
1545 EXPECT_VERIFIES(&env_v_v, code); | 1570 EXPECT_VERIFIES(&env_v_v, code); |
1546 } else { | 1571 } else { |
1547 EXPECT_FAILURE(&env_v_v, code); | 1572 EXPECT_FAILURE(&env_v_v, code); |
1548 } | 1573 } |
1549 } | 1574 } |
1550 } | 1575 } |
1551 | 1576 |
1552 | 1577 |
| 1578 // TODO(tizer): Fix on arm and reenable. |
| 1579 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 1580 |
1553 TEST_F(WasmDecoderTest, BreaksWithMultipleTypes) { | 1581 TEST_F(WasmDecoderTest, BreaksWithMultipleTypes) { |
1554 EXPECT_FAILURE_INLINE( | 1582 EXPECT_FAILURE_INLINE( |
1555 &env_i_i, | 1583 &env_i_i, |
1556 WASM_BLOCK(2, WASM_BRV_IF(0, WASM_ZERO, WASM_I8(7)), WASM_F32(7.7))); | 1584 WASM_BLOCK(2, WASM_BRV_IF(0, WASM_ZERO, WASM_I8(7)), WASM_F32(7.7))); |
1557 EXPECT_FAILURE_INLINE(&env_i_i, | 1585 EXPECT_FAILURE_INLINE(&env_i_i, |
1558 WASM_BLOCK(2, WASM_BRV_IF(0, WASM_ZERO, WASM_I8(7)), | 1586 WASM_BLOCK(2, WASM_BRV_IF(0, WASM_ZERO, WASM_I8(7)), |
1559 WASM_BRV_IF(0, WASM_ZERO, WASM_F32(7.7)))); | 1587 WASM_BRV_IF(0, WASM_ZERO, WASM_F32(7.7)))); |
1560 EXPECT_FAILURE_INLINE(&env_i_i, | 1588 EXPECT_FAILURE_INLINE(&env_i_i, |
1561 WASM_BLOCK(3, WASM_BRV_IF(0, WASM_ZERO, WASM_I8(8)), | 1589 WASM_BLOCK(3, WASM_BRV_IF(0, WASM_ZERO, WASM_I8(8)), |
1562 WASM_BRV_IF(0, WASM_ZERO, WASM_I8(0)), | 1590 WASM_BRV_IF(0, WASM_ZERO, WASM_I8(0)), |
1563 WASM_BRV_IF(0, WASM_ZERO, WASM_F32(7.7)))); | 1591 WASM_BRV_IF(0, WASM_ZERO, WASM_F32(7.7)))); |
1564 EXPECT_FAILURE_INLINE(&env_i_i, | 1592 EXPECT_FAILURE_INLINE(&env_i_i, |
1565 WASM_BLOCK(3, WASM_BRV_IF(0, WASM_ZERO, WASM_I8(9)), | 1593 WASM_BLOCK(3, WASM_BRV_IF(0, WASM_ZERO, WASM_I8(9)), |
1566 WASM_BRV_IF(0, WASM_ZERO, WASM_F32(7.7)), | 1594 WASM_BRV_IF(0, WASM_ZERO, WASM_F32(7.7)), |
1567 WASM_BRV_IF(0, WASM_ZERO, WASM_I8(11)))); | 1595 WASM_BRV_IF(0, WASM_ZERO, WASM_I8(11)))); |
1568 } | 1596 } |
1569 | 1597 |
| 1598 #endif |
| 1599 |
1570 | 1600 |
1571 TEST_F(WasmDecoderTest, BreakNesting_6_levels) { | 1601 TEST_F(WasmDecoderTest, BreakNesting_6_levels) { |
1572 for (int mask = 0; mask < 64; mask++) { | 1602 for (int mask = 0; mask < 64; mask++) { |
1573 for (int i = 0; i < 14; i++) { | 1603 for (int i = 0; i < 14; i++) { |
1574 byte code[] = { | 1604 byte code[] = { |
1575 kExprBlock, 1, // -- | 1605 kExprBlock, 1, // -- |
1576 kExprBlock, 1, // -- | 1606 kExprBlock, 1, // -- |
1577 kExprBlock, 1, // -- | 1607 kExprBlock, 1, // -- |
1578 kExprBlock, 1, // -- | 1608 kExprBlock, 1, // -- |
1579 kExprBlock, 1, // -- | 1609 kExprBlock, 1, // -- |
(...skipping 13 matching lines...) Expand all Loading... |
1593 if (i < depth) { | 1623 if (i < depth) { |
1594 EXPECT_VERIFIES(&env_v_v, code); | 1624 EXPECT_VERIFIES(&env_v_v, code); |
1595 } else { | 1625 } else { |
1596 EXPECT_FAILURE(&env_v_v, code); | 1626 EXPECT_FAILURE(&env_v_v, code); |
1597 } | 1627 } |
1598 } | 1628 } |
1599 } | 1629 } |
1600 } | 1630 } |
1601 | 1631 |
1602 | 1632 |
| 1633 // TODO(tizer): Fix on arm and reenable. |
| 1634 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 1635 |
1603 TEST_F(WasmDecoderTest, ExprBreak_TypeCheck) { | 1636 TEST_F(WasmDecoderTest, ExprBreak_TypeCheck) { |
1604 FunctionEnv* envs[] = {&env_i_i, &env_l_l, &env_f_ff, &env_d_dd}; | 1637 FunctionEnv* envs[] = {&env_i_i, &env_l_l, &env_f_ff, &env_d_dd}; |
1605 for (size_t i = 0; i < arraysize(envs); i++) { | 1638 for (size_t i = 0; i < arraysize(envs); i++) { |
1606 FunctionEnv* env = envs[i]; | 1639 FunctionEnv* env = envs[i]; |
1607 // unify X and X => OK | 1640 // unify X and X => OK |
1608 EXPECT_VERIFIES_INLINE( | 1641 EXPECT_VERIFIES_INLINE( |
1609 env, WASM_BLOCK(2, WASM_IF(WASM_ZERO, WASM_BRV(0, WASM_GET_LOCAL(0))), | 1642 env, WASM_BLOCK(2, WASM_IF(WASM_ZERO, WASM_BRV(0, WASM_GET_LOCAL(0))), |
1610 WASM_GET_LOCAL(0))); | 1643 WASM_GET_LOCAL(0))); |
1611 } | 1644 } |
1612 | 1645 |
1613 // unify i32 and f32 => fail | 1646 // unify i32 and f32 => fail |
1614 EXPECT_FAILURE_INLINE( | 1647 EXPECT_FAILURE_INLINE( |
1615 &env_i_i, | 1648 &env_i_i, |
1616 WASM_BLOCK(2, WASM_IF(WASM_ZERO, WASM_BRV(0, WASM_ZERO)), WASM_F32(1.2))); | 1649 WASM_BLOCK(2, WASM_IF(WASM_ZERO, WASM_BRV(0, WASM_ZERO)), WASM_F32(1.2))); |
1617 | 1650 |
1618 // unify f64 and f64 => OK | 1651 // unify f64 and f64 => OK |
1619 EXPECT_VERIFIES_INLINE( | 1652 EXPECT_VERIFIES_INLINE( |
1620 &env_d_dd, | 1653 &env_d_dd, |
1621 WASM_BLOCK(2, WASM_IF(WASM_ZERO, WASM_BRV(0, WASM_GET_LOCAL(0))), | 1654 WASM_BLOCK(2, WASM_IF(WASM_ZERO, WASM_BRV(0, WASM_GET_LOCAL(0))), |
1622 WASM_F64(1.2))); | 1655 WASM_F64(1.2))); |
1623 } | 1656 } |
1624 | 1657 |
| 1658 #endif |
| 1659 |
1625 | 1660 |
1626 TEST_F(WasmDecoderTest, ExprBreak_TypeCheckAll) { | 1661 TEST_F(WasmDecoderTest, ExprBreak_TypeCheckAll) { |
1627 byte code1[] = {WASM_BLOCK(2, | 1662 byte code1[] = {WASM_BLOCK(2, |
1628 WASM_IF(WASM_ZERO, WASM_BRV(0, WASM_GET_LOCAL(0))), | 1663 WASM_IF(WASM_ZERO, WASM_BRV(0, WASM_GET_LOCAL(0))), |
1629 WASM_GET_LOCAL(1))}; | 1664 WASM_GET_LOCAL(1))}; |
1630 byte code2[] = {WASM_BLOCK( | 1665 byte code2[] = {WASM_BLOCK( |
1631 2, WASM_IF(WASM_ZERO, WASM_BRV_IF(0, WASM_ZERO, WASM_GET_LOCAL(0))), | 1666 2, WASM_IF(WASM_ZERO, WASM_BRV_IF(0, WASM_ZERO, WASM_GET_LOCAL(0))), |
1632 WASM_GET_LOCAL(1))}; | 1667 WASM_GET_LOCAL(1))}; |
1633 | 1668 |
1634 | 1669 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 static byte code[] = { | 1824 static byte code[] = { |
1790 WASM_TABLESWITCH_OP(2, 2, WASM_CASE(0), WASM_CASE(1)), | 1825 WASM_TABLESWITCH_OP(2, 2, WASM_CASE(0), WASM_CASE(1)), |
1791 WASM_TABLESWITCH_BODY(WASM_I8(3), WASM_I8(10), WASM_I8(11))}; | 1826 WASM_TABLESWITCH_BODY(WASM_I8(3), WASM_I8(10), WASM_I8(11))}; |
1792 EXPECT_VERIFIES(&env_i_i, code); | 1827 EXPECT_VERIFIES(&env_i_i, code); |
1793 EXPECT_VERIFIES(&env_v_v, code); | 1828 EXPECT_VERIFIES(&env_v_v, code); |
1794 EXPECT_FAILURE(&env_f_ff, code); | 1829 EXPECT_FAILURE(&env_f_ff, code); |
1795 EXPECT_FAILURE(&env_d_dd, code); | 1830 EXPECT_FAILURE(&env_d_dd, code); |
1796 } | 1831 } |
1797 | 1832 |
1798 | 1833 |
| 1834 // TODO(tizer): Fix on arm and reenable. |
| 1835 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 1836 |
1799 TEST_F(WasmDecoderTest, TableSwitch1b) { | 1837 TEST_F(WasmDecoderTest, TableSwitch1b) { |
1800 EXPECT_VERIFIES_INLINE(&env_i_i, WASM_TABLESWITCH_OP(1, 1, WASM_CASE(0)), | 1838 EXPECT_VERIFIES_INLINE(&env_i_i, WASM_TABLESWITCH_OP(1, 1, WASM_CASE(0)), |
1801 WASM_TABLESWITCH_BODY(WASM_GET_LOCAL(0), WASM_ZERO)); | 1839 WASM_TABLESWITCH_BODY(WASM_GET_LOCAL(0), WASM_ZERO)); |
1802 | 1840 |
1803 EXPECT_VERIFIES_INLINE(&env_f_ff, WASM_TABLESWITCH_OP(1, 1, WASM_CASE(0)), | 1841 EXPECT_VERIFIES_INLINE(&env_f_ff, WASM_TABLESWITCH_OP(1, 1, WASM_CASE(0)), |
1804 WASM_TABLESWITCH_BODY(WASM_ZERO, WASM_F32(0.0))); | 1842 WASM_TABLESWITCH_BODY(WASM_ZERO, WASM_F32(0.0))); |
1805 | 1843 |
1806 EXPECT_VERIFIES_INLINE(&env_d_dd, WASM_TABLESWITCH_OP(1, 1, WASM_CASE(0)), | 1844 EXPECT_VERIFIES_INLINE(&env_d_dd, WASM_TABLESWITCH_OP(1, 1, WASM_CASE(0)), |
1807 WASM_TABLESWITCH_BODY(WASM_ZERO, WASM_F64(0.0))); | 1845 WASM_TABLESWITCH_BODY(WASM_ZERO, WASM_F64(0.0))); |
1808 } | 1846 } |
1809 | 1847 |
| 1848 #endif |
| 1849 |
1810 | 1850 |
1811 TEST_F(WasmDecoderTest, TableSwitch_br) { | 1851 TEST_F(WasmDecoderTest, TableSwitch_br) { |
1812 EXPECT_VERIFIES_INLINE(&env_i_i, WASM_TABLESWITCH_OP(0, 1, WASM_CASE_BR(0)), | 1852 EXPECT_VERIFIES_INLINE(&env_i_i, WASM_TABLESWITCH_OP(0, 1, WASM_CASE_BR(0)), |
1813 WASM_GET_LOCAL(0)); | 1853 WASM_GET_LOCAL(0)); |
1814 for (int depth = 0; depth < 2; depth++) { | 1854 for (int depth = 0; depth < 2; depth++) { |
1815 EXPECT_VERIFIES_INLINE( | 1855 EXPECT_VERIFIES_INLINE( |
1816 &env_i_i, WASM_BLOCK(1, WASM_TABLESWITCH_OP(0, 1, WASM_CASE_BR(depth)), | 1856 &env_i_i, WASM_BLOCK(1, WASM_TABLESWITCH_OP(0, 1, WASM_CASE_BR(depth)), |
1817 WASM_GET_LOCAL(0))); | 1857 WASM_GET_LOCAL(0))); |
1818 } | 1858 } |
1819 } | 1859 } |
(...skipping 13 matching lines...) Expand all Loading... |
1833 | 1873 |
1834 | 1874 |
1835 TEST_F(WasmDecoderTest, TableSwitch_invalid_case_ref) { | 1875 TEST_F(WasmDecoderTest, TableSwitch_invalid_case_ref) { |
1836 EXPECT_FAILURE_INLINE(&env_i_i, WASM_TABLESWITCH_OP(0, 1, WASM_CASE(0)), | 1876 EXPECT_FAILURE_INLINE(&env_i_i, WASM_TABLESWITCH_OP(0, 1, WASM_CASE(0)), |
1837 WASM_GET_LOCAL(0)); | 1877 WASM_GET_LOCAL(0)); |
1838 EXPECT_FAILURE_INLINE(&env_i_i, WASM_TABLESWITCH_OP(1, 1, WASM_CASE(1)), | 1878 EXPECT_FAILURE_INLINE(&env_i_i, WASM_TABLESWITCH_OP(1, 1, WASM_CASE(1)), |
1839 WASM_TABLESWITCH_BODY(WASM_GET_LOCAL(0), WASM_ZERO)); | 1879 WASM_TABLESWITCH_BODY(WASM_GET_LOCAL(0), WASM_ZERO)); |
1840 } | 1880 } |
1841 | 1881 |
1842 | 1882 |
| 1883 // TODO(tizer): Fix on arm and reenable. |
| 1884 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 1885 |
1843 TEST_F(WasmDecoderTest, TableSwitch1_br) { | 1886 TEST_F(WasmDecoderTest, TableSwitch1_br) { |
1844 EXPECT_VERIFIES_INLINE( | 1887 EXPECT_VERIFIES_INLINE( |
1845 &env_i_i, WASM_TABLESWITCH_OP(1, 1, WASM_CASE(0)), | 1888 &env_i_i, WASM_TABLESWITCH_OP(1, 1, WASM_CASE(0)), |
1846 WASM_TABLESWITCH_BODY(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_ZERO))); | 1889 WASM_TABLESWITCH_BODY(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_ZERO))); |
1847 } | 1890 } |
1848 | 1891 |
| 1892 #endif |
| 1893 |
1849 | 1894 |
1850 TEST_F(WasmDecoderTest, TableSwitch2_br) { | 1895 TEST_F(WasmDecoderTest, TableSwitch2_br) { |
1851 EXPECT_VERIFIES_INLINE( | 1896 EXPECT_VERIFIES_INLINE( |
1852 &env_i_i, WASM_TABLESWITCH_OP(2, 2, WASM_CASE(0), WASM_CASE(1)), | 1897 &env_i_i, WASM_TABLESWITCH_OP(2, 2, WASM_CASE(0), WASM_CASE(1)), |
1853 WASM_TABLESWITCH_BODY(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(0)), | 1898 WASM_TABLESWITCH_BODY(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(0)), |
1854 WASM_BRV(0, WASM_I8(1)))); | 1899 WASM_BRV(0, WASM_I8(1)))); |
1855 | 1900 |
1856 EXPECT_FAILURE_INLINE( | 1901 EXPECT_FAILURE_INLINE( |
1857 &env_f_ff, WASM_TABLESWITCH_OP(2, 2, WASM_CASE(0), WASM_CASE(1)), | 1902 &env_f_ff, WASM_TABLESWITCH_OP(2, 2, WASM_CASE(0), WASM_CASE(1)), |
1858 WASM_TABLESWITCH_BODY(WASM_ZERO, WASM_BRV(0, WASM_I8(3)), | 1903 WASM_TABLESWITCH_BODY(WASM_ZERO, WASM_BRV(0, WASM_I8(3)), |
1859 WASM_BRV(0, WASM_I8(4)))); | 1904 WASM_BRV(0, WASM_I8(4)))); |
1860 } | 1905 } |
1861 | 1906 |
1862 | 1907 |
1863 TEST_F(WasmDecoderTest, TableSwitch2x2) { | 1908 TEST_F(WasmDecoderTest, TableSwitch2x2) { |
1864 EXPECT_VERIFIES_INLINE( | 1909 EXPECT_VERIFIES_INLINE( |
1865 &env_i_i, WASM_TABLESWITCH_OP(2, 4, WASM_CASE(0), WASM_CASE(1), | 1910 &env_i_i, WASM_TABLESWITCH_OP(2, 4, WASM_CASE(0), WASM_CASE(1), |
1866 WASM_CASE(0), WASM_CASE(1)), | 1911 WASM_CASE(0), WASM_CASE(1)), |
1867 WASM_TABLESWITCH_BODY(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(3)), | 1912 WASM_TABLESWITCH_BODY(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(3)), |
1868 WASM_BRV(0, WASM_I8(4)))); | 1913 WASM_BRV(0, WASM_I8(4)))); |
1869 } | 1914 } |
1870 | 1915 |
1871 | 1916 |
| 1917 // TODO(tizer): Fix on arm and reenable. |
| 1918 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 1919 |
1872 TEST_F(WasmDecoderTest, ExprBreakNesting1) { | 1920 TEST_F(WasmDecoderTest, ExprBreakNesting1) { |
1873 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_BLOCK(1, WASM_BRV(0, WASM_ZERO))); | 1921 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_BLOCK(1, WASM_BRV(0, WASM_ZERO))); |
1874 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_BLOCK(1, WASM_BR(0))); | 1922 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_BLOCK(1, WASM_BR(0))); |
1875 EXPECT_VERIFIES_INLINE(&env_v_v, | 1923 EXPECT_VERIFIES_INLINE(&env_v_v, |
1876 WASM_BLOCK(1, WASM_BRV_IF(0, WASM_ZERO, WASM_ZERO))); | 1924 WASM_BLOCK(1, WASM_BRV_IF(0, WASM_ZERO, WASM_ZERO))); |
1877 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_BLOCK(1, WASM_BR_IF(0, WASM_ZERO))); | 1925 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_BLOCK(1, WASM_BR_IF(0, WASM_ZERO))); |
1878 | 1926 |
1879 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BRV(0, WASM_ZERO))); | 1927 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BRV(0, WASM_ZERO))); |
1880 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BR(0))); | 1928 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BR(0))); |
1881 EXPECT_VERIFIES_INLINE(&env_v_v, | 1929 EXPECT_VERIFIES_INLINE(&env_v_v, |
1882 WASM_LOOP(1, WASM_BRV_IF(0, WASM_ZERO, WASM_ZERO))); | 1930 WASM_LOOP(1, WASM_BRV_IF(0, WASM_ZERO, WASM_ZERO))); |
1883 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BR_IF(0, WASM_ZERO))); | 1931 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BR_IF(0, WASM_ZERO))); |
1884 | 1932 |
1885 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BRV(1, WASM_ZERO))); | 1933 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BRV(1, WASM_ZERO))); |
1886 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BR(1))); | 1934 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BR(1))); |
1887 } | 1935 } |
1888 | 1936 |
| 1937 #endif |
| 1938 |
1889 | 1939 |
1890 TEST_F(WasmDecoderTest, Select) { | 1940 TEST_F(WasmDecoderTest, Select) { |
1891 EXPECT_VERIFIES_INLINE( | 1941 EXPECT_VERIFIES_INLINE( |
1892 &env_i_i, | 1942 &env_i_i, |
1893 WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); | 1943 WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); |
1894 } | 1944 } |
1895 | 1945 |
1896 | 1946 |
| 1947 // TODO(tizer): Fix on arm and reenable. |
| 1948 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 1949 |
1897 TEST_F(WasmDecoderTest, Select_TypeCheck) { | 1950 TEST_F(WasmDecoderTest, Select_TypeCheck) { |
1898 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), | 1951 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), |
1899 WASM_GET_LOCAL(0))); | 1952 WASM_GET_LOCAL(0))); |
1900 | 1953 |
1901 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_GET_LOCAL(0), WASM_F64(0.25), | 1954 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_GET_LOCAL(0), WASM_F64(0.25), |
1902 WASM_GET_LOCAL(0))); | 1955 WASM_GET_LOCAL(0))); |
1903 | 1956 |
1904 EXPECT_FAILURE_INLINE( | 1957 EXPECT_FAILURE_INLINE( |
1905 &env_i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_I64(0))); | 1958 &env_i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_I64(0))); |
1906 } | 1959 } |
1907 | 1960 |
| 1961 #endif |
| 1962 |
1908 | 1963 |
1909 class WasmOpcodeLengthTest : public TestWithZone { | 1964 class WasmOpcodeLengthTest : public TestWithZone { |
1910 public: | 1965 public: |
1911 WasmOpcodeLengthTest() : TestWithZone() {} | 1966 WasmOpcodeLengthTest() : TestWithZone() {} |
1912 }; | 1967 }; |
1913 | 1968 |
1914 | 1969 |
1915 #define EXPECT_LENGTH(expected, opcode) \ | 1970 #define EXPECT_LENGTH(expected, opcode) \ |
1916 { \ | 1971 { \ |
1917 static const byte code[] = {opcode, 0, 0, 0, 0, 0, 0, 0, 0}; \ | 1972 static const byte code[] = {opcode, 0, 0, 0, 0, 0, 0, 0, 0}; \ |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2375 EXPECT_ARITY(1, kExprF64SConvertI64); | 2430 EXPECT_ARITY(1, kExprF64SConvertI64); |
2376 EXPECT_ARITY(1, kExprF64UConvertI64); | 2431 EXPECT_ARITY(1, kExprF64UConvertI64); |
2377 EXPECT_ARITY(1, kExprF64ConvertF32); | 2432 EXPECT_ARITY(1, kExprF64ConvertF32); |
2378 EXPECT_ARITY(1, kExprF64ReinterpretI64); | 2433 EXPECT_ARITY(1, kExprF64ReinterpretI64); |
2379 EXPECT_ARITY(1, kExprI32ReinterpretF32); | 2434 EXPECT_ARITY(1, kExprI32ReinterpretF32); |
2380 EXPECT_ARITY(1, kExprI64ReinterpretF64); | 2435 EXPECT_ARITY(1, kExprI64ReinterpretF64); |
2381 } | 2436 } |
2382 } // namespace wasm | 2437 } // namespace wasm |
2383 } // namespace internal | 2438 } // namespace internal |
2384 } // namespace v8 | 2439 } // namespace v8 |
OLD | NEW |