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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 EXPECT_FAILURE(&env_v_v, code); | 212 EXPECT_FAILURE(&env_v_v, code); |
213 EXPECT_FAILURE(&env_i_i, code); | 213 EXPECT_FAILURE(&env_i_i, code); |
214 } | 214 } |
215 | 215 |
216 TEST_F(AstDecoderTest, Int8Const_fallthru) { | 216 TEST_F(AstDecoderTest, Int8Const_fallthru) { |
217 byte code[] = {kExprI8Const, 0, kExprI8Const, 1}; | 217 byte code[] = {kExprI8Const, 0, kExprI8Const, 1}; |
218 EXPECT_VERIFIES(&env_i_i, code); | 218 EXPECT_VERIFIES(&env_i_i, code); |
219 } | 219 } |
220 | 220 |
221 TEST_F(AstDecoderTest, Int32Const) { | 221 TEST_F(AstDecoderTest, Int32Const) { |
222 byte code[] = {kExprI32Const, 0, 0, 0, 0}; | |
223 int32_t* ptr = reinterpret_cast<int32_t*>(code + 1); | |
224 const int kInc = 4498211; | 222 const int kInc = 4498211; |
225 for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) { | 223 for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) { |
226 *ptr = i; | 224 // TODO(binji): expand test for other sized int32s; 1 through 5 bytes. |
| 225 byte code[] = {WASM_I32V(i)}; |
227 EXPECT_VERIFIES(&env_i_i, code); | 226 EXPECT_VERIFIES(&env_i_i, code); |
228 } | 227 } |
229 } | 228 } |
230 | 229 |
231 TEST_F(AstDecoderTest, Int8Const_fallthru2) { | 230 TEST_F(AstDecoderTest, Int8Const_fallthru2) { |
232 byte code[] = {kExprI8Const, 0, kExprI32Const, 1, 2, 3, 4}; | 231 byte code[] = {WASM_I8(0), WASM_I32V_4(0x1122334)}; |
233 EXPECT_VERIFIES(&env_i_i, code); | 232 EXPECT_VERIFIES(&env_i_i, code); |
234 } | 233 } |
235 | 234 |
236 TEST_F(AstDecoderTest, Int64Const) { | 235 TEST_F(AstDecoderTest, Int64Const) { |
237 byte code[] = {kExprI64Const, 0, 0, 0, 0, 0, 0, 0, 0}; | |
238 int64_t* ptr = reinterpret_cast<int64_t*>(code + 1); | |
239 const int kInc = 4498211; | 236 const int kInc = 4498211; |
240 for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) { | 237 for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) { |
241 *ptr = (static_cast<int64_t>(i) << 32) | i; | 238 byte code[] = {WASM_I64V((static_cast<int64_t>(i) << 32) | i)}; |
242 EXPECT_VERIFIES(&env_l_l, code); | 239 EXPECT_VERIFIES(&env_l_l, code); |
243 } | 240 } |
244 } | 241 } |
245 | 242 |
246 TEST_F(AstDecoderTest, Float32Const) { | 243 TEST_F(AstDecoderTest, Float32Const) { |
247 byte code[] = {kExprF32Const, 0, 0, 0, 0}; | 244 byte code[] = {kExprF32Const, 0, 0, 0, 0}; |
248 float* ptr = reinterpret_cast<float*>(code + 1); | 245 float* ptr = reinterpret_cast<float*>(code + 1); |
249 for (int i = 0; i < 30; i++) { | 246 for (int i = 0; i < 30; i++) { |
250 *ptr = i * -7.75f; | 247 *ptr = i * -7.75f; |
251 EXPECT_VERIFIES(&env_f_ff, code); | 248 EXPECT_VERIFIES(&env_f_ff, code); |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 TestUnop(kExprI32UConvertF64, kAstI32, kAstF64); | 773 TestUnop(kExprI32UConvertF64, kAstI32, kAstF64); |
777 TestUnop(kExprF64SConvertI32, kAstF64, kAstI32); | 774 TestUnop(kExprF64SConvertI32, kAstF64, kAstI32); |
778 TestUnop(kExprF64UConvertI32, kAstF64, kAstI32); | 775 TestUnop(kExprF64UConvertI32, kAstF64, kAstI32); |
779 TestUnop(kExprF64ConvertF32, kAstF64, kAstF32); | 776 TestUnop(kExprF64ConvertF32, kAstF64, kAstF32); |
780 TestUnop(kExprF32SConvertI32, kAstF32, kAstI32); | 777 TestUnop(kExprF32SConvertI32, kAstF32, kAstI32); |
781 TestUnop(kExprF32UConvertI32, kAstF32, kAstI32); | 778 TestUnop(kExprF32UConvertI32, kAstF32, kAstI32); |
782 TestUnop(kExprF32ConvertF64, kAstF32, kAstF64); | 779 TestUnop(kExprF32ConvertF64, kAstF32, kAstF64); |
783 } | 780 } |
784 | 781 |
785 TEST_F(AstDecoderTest, MacrosStmt) { | 782 TEST_F(AstDecoderTest, MacrosStmt) { |
786 VERIFY(WASM_SET_LOCAL(0, WASM_I32(87348))); | 783 VERIFY(WASM_SET_LOCAL(0, WASM_I32V_3(87348))); |
787 VERIFY(WASM_STORE_MEM(MachineType::Int32(), WASM_I8(24), WASM_I8(40))); | 784 VERIFY(WASM_STORE_MEM(MachineType::Int32(), WASM_I8(24), WASM_I8(40))); |
788 VERIFY(WASM_IF(WASM_GET_LOCAL(0), WASM_NOP)); | 785 VERIFY(WASM_IF(WASM_GET_LOCAL(0), WASM_NOP)); |
789 VERIFY(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP)); | 786 VERIFY(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP)); |
790 VERIFY(WASM_NOP); | 787 VERIFY(WASM_NOP); |
791 VERIFY(WASM_BLOCK(1, WASM_NOP)); | 788 VERIFY(WASM_BLOCK(1, WASM_NOP)); |
792 VERIFY(WASM_LOOP(1, WASM_NOP)); | 789 VERIFY(WASM_LOOP(1, WASM_NOP)); |
793 VERIFY(WASM_LOOP(1, WASM_BREAK(0))); | 790 VERIFY(WASM_LOOP(1, WASM_BREAK(0))); |
794 VERIFY(WASM_LOOP(1, WASM_CONTINUE(0))); | 791 VERIFY(WASM_LOOP(1, WASM_CONTINUE(0))); |
795 } | 792 } |
796 | 793 |
797 TEST_F(AstDecoderTest, MacrosBreak) { | 794 TEST_F(AstDecoderTest, MacrosBreak) { |
798 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BREAK(0))); | 795 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BREAK(0))); |
799 | 796 |
800 EXPECT_VERIFIES_INLINE(&env_i_i, WASM_LOOP(1, WASM_BREAKV(0, WASM_ZERO))); | 797 EXPECT_VERIFIES_INLINE(&env_i_i, WASM_LOOP(1, WASM_BREAKV(0, WASM_ZERO))); |
801 EXPECT_VERIFIES_INLINE(&env_l_l, WASM_LOOP(1, WASM_BREAKV(0, WASM_I64(0)))); | 798 EXPECT_VERIFIES_INLINE(&env_l_l, |
| 799 WASM_LOOP(1, WASM_BREAKV(0, WASM_I64V_1(0)))); |
802 EXPECT_VERIFIES_INLINE(&env_f_ff, | 800 EXPECT_VERIFIES_INLINE(&env_f_ff, |
803 WASM_LOOP(1, WASM_BREAKV(0, WASM_F32(0.0)))); | 801 WASM_LOOP(1, WASM_BREAKV(0, WASM_F32(0.0)))); |
804 EXPECT_VERIFIES_INLINE(&env_d_dd, | 802 EXPECT_VERIFIES_INLINE(&env_d_dd, |
805 WASM_LOOP(1, WASM_BREAKV(0, WASM_F64(0.0)))); | 803 WASM_LOOP(1, WASM_BREAKV(0, WASM_F64(0.0)))); |
806 } | 804 } |
807 | 805 |
808 TEST_F(AstDecoderTest, MacrosContinue) { | 806 TEST_F(AstDecoderTest, MacrosContinue) { |
809 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_CONTINUE(0))); | 807 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_CONTINUE(0))); |
810 } | 808 } |
811 | 809 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 | 886 |
889 TEST_F(AstDecoderTest, MacrosInt64) { | 887 TEST_F(AstDecoderTest, MacrosInt64) { |
890 FunctionEnv env_i_ll; | 888 FunctionEnv env_i_ll; |
891 FunctionEnv env_l_ll; | 889 FunctionEnv env_l_ll; |
892 init_env(&env_i_ll, sigs.i_ll()); | 890 init_env(&env_i_ll, sigs.i_ll()); |
893 init_env(&env_l_ll, sigs.l_ll()); | 891 init_env(&env_l_ll, sigs.l_ll()); |
894 | 892 |
895 #define VERIFY_L_LL(...) EXPECT_VERIFIES_INLINE(&env_l_ll, __VA_ARGS__) | 893 #define VERIFY_L_LL(...) EXPECT_VERIFIES_INLINE(&env_l_ll, __VA_ARGS__) |
896 #define VERIFY_I_LL(...) EXPECT_VERIFIES_INLINE(&env_i_ll, __VA_ARGS__) | 894 #define VERIFY_I_LL(...) EXPECT_VERIFIES_INLINE(&env_i_ll, __VA_ARGS__) |
897 | 895 |
898 VERIFY_L_LL(WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_I64(12))); | 896 VERIFY_L_LL(WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_I64V_1(12))); |
899 VERIFY_L_LL(WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_I64(13))); | 897 VERIFY_L_LL(WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_I64V_1(13))); |
900 VERIFY_L_LL(WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_I64(14))); | 898 VERIFY_L_LL(WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_I64V_1(14))); |
901 VERIFY_L_LL(WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64(15))); | 899 VERIFY_L_LL(WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64V_1(15))); |
902 VERIFY_L_LL(WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64(16))); | 900 VERIFY_L_LL(WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64V_1(16))); |
903 VERIFY_L_LL(WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_I64(17))); | 901 VERIFY_L_LL(WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_I64V_1(17))); |
904 VERIFY_L_LL(WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_I64(18))); | 902 VERIFY_L_LL(WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_I64V_1(18))); |
905 VERIFY_L_LL(WASM_I64_AND(WASM_GET_LOCAL(0), WASM_I64(19))); | 903 VERIFY_L_LL(WASM_I64_AND(WASM_GET_LOCAL(0), WASM_I64V_1(19))); |
906 VERIFY_L_LL(WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_I64(20))); | 904 VERIFY_L_LL(WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_I64V_1(20))); |
907 VERIFY_L_LL(WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_I64(21))); | 905 VERIFY_L_LL(WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_I64V_1(21))); |
908 | 906 |
909 VERIFY_L_LL(WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64(22))); | 907 VERIFY_L_LL(WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(22))); |
910 VERIFY_L_LL(WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64(23))); | 908 VERIFY_L_LL(WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(23))); |
911 VERIFY_L_LL(WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64(24))); | 909 VERIFY_L_LL(WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(24))); |
912 VERIFY_L_LL(WASM_I64_ROR(WASM_GET_LOCAL(0), WASM_I64(24))); | 910 VERIFY_L_LL(WASM_I64_ROR(WASM_GET_LOCAL(0), WASM_I64V_1(24))); |
913 VERIFY_L_LL(WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_I64(24))); | 911 VERIFY_L_LL(WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_I64V_1(24))); |
914 | 912 |
915 VERIFY_I_LL(WASM_I64_LTS(WASM_GET_LOCAL(0), WASM_I64(26))); | 913 VERIFY_I_LL(WASM_I64_LTS(WASM_GET_LOCAL(0), WASM_I64V_1(26))); |
916 VERIFY_I_LL(WASM_I64_LES(WASM_GET_LOCAL(0), WASM_I64(27))); | 914 VERIFY_I_LL(WASM_I64_LES(WASM_GET_LOCAL(0), WASM_I64V_1(27))); |
917 VERIFY_I_LL(WASM_I64_LTU(WASM_GET_LOCAL(0), WASM_I64(28))); | 915 VERIFY_I_LL(WASM_I64_LTU(WASM_GET_LOCAL(0), WASM_I64V_1(28))); |
918 VERIFY_I_LL(WASM_I64_LEU(WASM_GET_LOCAL(0), WASM_I64(29))); | 916 VERIFY_I_LL(WASM_I64_LEU(WASM_GET_LOCAL(0), WASM_I64V_1(29))); |
919 | 917 |
920 VERIFY_I_LL(WASM_I64_GTS(WASM_GET_LOCAL(0), WASM_I64(26))); | 918 VERIFY_I_LL(WASM_I64_GTS(WASM_GET_LOCAL(0), WASM_I64V_1(26))); |
921 VERIFY_I_LL(WASM_I64_GES(WASM_GET_LOCAL(0), WASM_I64(27))); | 919 VERIFY_I_LL(WASM_I64_GES(WASM_GET_LOCAL(0), WASM_I64V_1(27))); |
922 VERIFY_I_LL(WASM_I64_GTU(WASM_GET_LOCAL(0), WASM_I64(28))); | 920 VERIFY_I_LL(WASM_I64_GTU(WASM_GET_LOCAL(0), WASM_I64V_1(28))); |
923 VERIFY_I_LL(WASM_I64_GEU(WASM_GET_LOCAL(0), WASM_I64(29))); | 921 VERIFY_I_LL(WASM_I64_GEU(WASM_GET_LOCAL(0), WASM_I64V_1(29))); |
924 | 922 |
925 VERIFY_I_LL(WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_I64(25))); | 923 VERIFY_I_LL(WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_I64V_1(25))); |
926 VERIFY_I_LL(WASM_I64_NE(WASM_GET_LOCAL(0), WASM_I64(25))); | 924 VERIFY_I_LL(WASM_I64_NE(WASM_GET_LOCAL(0), WASM_I64V_1(25))); |
927 } | 925 } |
928 | 926 |
929 TEST_F(AstDecoderTest, AllSimpleExpressions) { | 927 TEST_F(AstDecoderTest, AllSimpleExpressions) { |
930 // Test all simple expressions which are described by a signature. | 928 // Test all simple expressions which are described by a signature. |
931 #define DECODE_TEST(name, opcode, sig) \ | 929 #define DECODE_TEST(name, opcode, sig) \ |
932 { \ | 930 { \ |
933 FunctionSig* sig = WasmOpcodes::Signature(kExpr##name); \ | 931 FunctionSig* sig = WasmOpcodes::Signature(kExpr##name); \ |
934 if (sig->parameter_count() == 1) { \ | 932 if (sig->parameter_count() == 1) { \ |
935 TestUnop(kExpr##name, sig); \ | 933 TestUnop(kExpr##name, sig); \ |
936 } else { \ | 934 } else { \ |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 WASM_CALL_FUNCTION(0, WASM_F32(0.1), WASM_F32(0.1), WASM_F32(11))); | 1187 WASM_CALL_FUNCTION(0, WASM_F32(0.1), WASM_F32(0.1), WASM_F32(11))); |
1190 } | 1188 } |
1191 | 1189 |
1192 TEST_F(AstDecoderTest, CallsWithMismatchedSigs2) { | 1190 TEST_F(AstDecoderTest, CallsWithMismatchedSigs2) { |
1193 FunctionEnv* env = &env_i_i; | 1191 FunctionEnv* env = &env_i_i; |
1194 TestModuleEnv module_env; | 1192 TestModuleEnv module_env; |
1195 env->module = &module_env; | 1193 env->module = &module_env; |
1196 | 1194 |
1197 module_env.AddFunction(sigs.i_i()); | 1195 module_env.AddFunction(sigs.i_i()); |
1198 | 1196 |
1199 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64(17))); | 1197 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64V_1(17))); |
1200 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F32(17.1))); | 1198 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F32(17.1))); |
1201 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(17.1))); | 1199 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(17.1))); |
1202 } | 1200 } |
1203 | 1201 |
1204 TEST_F(AstDecoderTest, CallsWithMismatchedSigs3) { | 1202 TEST_F(AstDecoderTest, CallsWithMismatchedSigs3) { |
1205 FunctionEnv* env = &env_i_i; | 1203 FunctionEnv* env = &env_i_i; |
1206 TestModuleEnv module_env; | 1204 TestModuleEnv module_env; |
1207 env->module = &module_env; | 1205 env->module = &module_env; |
1208 | 1206 |
1209 module_env.AddFunction(sigs.i_f()); | 1207 module_env.AddFunction(sigs.i_f()); |
1210 | 1208 |
1211 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I8(17))); | 1209 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I8(17))); |
1212 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64(27))); | 1210 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64V_1(27))); |
1213 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(37.2))); | 1211 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(37.2))); |
1214 | 1212 |
1215 module_env.AddFunction(sigs.i_d()); | 1213 module_env.AddFunction(sigs.i_d()); |
1216 | 1214 |
1217 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I8(16))); | 1215 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I8(16))); |
1218 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I64(16))); | 1216 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I64V_1(16))); |
1219 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_F32(17.6))); | 1217 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_F32(17.6))); |
1220 } | 1218 } |
1221 | 1219 |
1222 TEST_F(AstDecoderTest, SimpleIndirectCalls) { | 1220 TEST_F(AstDecoderTest, SimpleIndirectCalls) { |
1223 FunctionEnv* env = &env_i_i; | 1221 FunctionEnv* env = &env_i_i; |
1224 TestModuleEnv module_env; | 1222 TestModuleEnv module_env; |
1225 env->module = &module_env; | 1223 env->module = &module_env; |
1226 | 1224 |
1227 byte f0 = module_env.AddSignature(sigs.i_v()); | 1225 byte f0 = module_env.AddSignature(sigs.i_v()); |
1228 byte f1 = module_env.AddSignature(sigs.i_i()); | 1226 byte f1 = module_env.AddSignature(sigs.i_i()); |
(...skipping 22 matching lines...) Expand all Loading... |
1251 } | 1249 } |
1252 | 1250 |
1253 TEST_F(AstDecoderTest, IndirectCallsWithMismatchedSigs3) { | 1251 TEST_F(AstDecoderTest, IndirectCallsWithMismatchedSigs3) { |
1254 FunctionEnv* env = &env_i_i; | 1252 FunctionEnv* env = &env_i_i; |
1255 TestModuleEnv module_env; | 1253 TestModuleEnv module_env; |
1256 env->module = &module_env; | 1254 env->module = &module_env; |
1257 | 1255 |
1258 byte f0 = module_env.AddFunction(sigs.i_f()); | 1256 byte f0 = module_env.AddFunction(sigs.i_f()); |
1259 | 1257 |
1260 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_I8(17))); | 1258 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_I8(17))); |
1261 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_I64(27))); | 1259 EXPECT_FAILURE_INLINE(env, |
| 1260 WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_I64V_1(27))); |
1262 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_F64(37.2))); | 1261 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_F64(37.2))); |
1263 | 1262 |
1264 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_I8(17))); | 1263 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_I8(17))); |
1265 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_I64(27))); | 1264 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_I64V_1(27))); |
1266 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_F64(37.2))); | 1265 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_F64(37.2))); |
1267 | 1266 |
1268 byte f1 = module_env.AddFunction(sigs.i_d()); | 1267 byte f1 = module_env.AddFunction(sigs.i_d()); |
1269 | 1268 |
1270 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_I8(16))); | 1269 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_I8(16))); |
1271 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_I64(16))); | 1270 EXPECT_FAILURE_INLINE(env, |
| 1271 WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_I64V_1(16))); |
1272 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_F32(17.6))); | 1272 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_F32(17.6))); |
1273 } | 1273 } |
1274 | 1274 |
1275 TEST_F(AstDecoderTest, SimpleImportCalls) { | 1275 TEST_F(AstDecoderTest, SimpleImportCalls) { |
1276 FunctionEnv* env = &env_i_i; | 1276 FunctionEnv* env = &env_i_i; |
1277 TestModuleEnv module_env; | 1277 TestModuleEnv module_env; |
1278 env->module = &module_env; | 1278 env->module = &module_env; |
1279 | 1279 |
1280 byte f0 = module_env.AddImport(sigs.i_v()); | 1280 byte f0 = module_env.AddImport(sigs.i_v()); |
1281 byte f1 = module_env.AddImport(sigs.i_i()); | 1281 byte f1 = module_env.AddImport(sigs.i_i()); |
1282 byte f2 = module_env.AddImport(sigs.i_ii()); | 1282 byte f2 = module_env.AddImport(sigs.i_ii()); |
1283 | 1283 |
1284 EXPECT_VERIFIES_INLINE(env, WASM_CALL_IMPORT0(f0)); | 1284 EXPECT_VERIFIES_INLINE(env, WASM_CALL_IMPORT0(f0)); |
1285 EXPECT_VERIFIES_INLINE(env, WASM_CALL_IMPORT(f1, WASM_I8(22))); | 1285 EXPECT_VERIFIES_INLINE(env, WASM_CALL_IMPORT(f1, WASM_I8(22))); |
1286 EXPECT_VERIFIES_INLINE(env, WASM_CALL_IMPORT(f2, WASM_I8(32), WASM_I8(72))); | 1286 EXPECT_VERIFIES_INLINE(env, WASM_CALL_IMPORT(f2, WASM_I8(32), WASM_I8(72))); |
1287 } | 1287 } |
1288 | 1288 |
1289 TEST_F(AstDecoderTest, ImportCallsWithMismatchedSigs3) { | 1289 TEST_F(AstDecoderTest, ImportCallsWithMismatchedSigs3) { |
1290 FunctionEnv* env = &env_i_i; | 1290 FunctionEnv* env = &env_i_i; |
1291 TestModuleEnv module_env; | 1291 TestModuleEnv module_env; |
1292 env->module = &module_env; | 1292 env->module = &module_env; |
1293 | 1293 |
1294 byte f0 = module_env.AddImport(sigs.i_f()); | 1294 byte f0 = module_env.AddImport(sigs.i_f()); |
1295 | 1295 |
1296 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT0(f0)); | 1296 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT0(f0)); |
1297 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f0, WASM_I8(17))); | 1297 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f0, WASM_I8(17))); |
1298 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f0, WASM_I64(27))); | 1298 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f0, WASM_I64V_1(27))); |
1299 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f0, WASM_F64(37.2))); | 1299 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f0, WASM_F64(37.2))); |
1300 | 1300 |
1301 byte f1 = module_env.AddImport(sigs.i_d()); | 1301 byte f1 = module_env.AddImport(sigs.i_d()); |
1302 | 1302 |
1303 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT0(f1)); | 1303 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT0(f1)); |
1304 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f1, WASM_I8(16))); | 1304 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f1, WASM_I8(16))); |
1305 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f1, WASM_I64(16))); | 1305 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f1, WASM_I64V_1(16))); |
1306 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f1, WASM_F32(17.6))); | 1306 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f1, WASM_F32(17.6))); |
1307 } | 1307 } |
1308 | 1308 |
1309 TEST_F(AstDecoderTest, Int32Globals) { | 1309 TEST_F(AstDecoderTest, Int32Globals) { |
1310 FunctionEnv* env = &env_i_i; | 1310 FunctionEnv* env = &env_i_i; |
1311 TestModuleEnv module_env; | 1311 TestModuleEnv module_env; |
1312 env->module = &module_env; | 1312 env->module = &module_env; |
1313 | 1313 |
1314 module_env.AddGlobal(MachineType::Int8()); | 1314 module_env.AddGlobal(MachineType::Int8()); |
1315 module_env.AddGlobal(MachineType::Uint8()); | 1315 module_env.AddGlobal(MachineType::Uint8()); |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BR(1))); | 1804 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BR(1))); |
1805 } | 1805 } |
1806 | 1806 |
1807 TEST_F(AstDecoderTest, Select) { | 1807 TEST_F(AstDecoderTest, Select) { |
1808 EXPECT_VERIFIES_INLINE( | 1808 EXPECT_VERIFIES_INLINE( |
1809 &env_i_i, WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_ZERO)); | 1809 &env_i_i, WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_ZERO)); |
1810 EXPECT_VERIFIES_INLINE(&env_f_ff, | 1810 EXPECT_VERIFIES_INLINE(&env_f_ff, |
1811 WASM_SELECT(WASM_F32(0.0), WASM_F32(0.0), WASM_ZERO)); | 1811 WASM_SELECT(WASM_F32(0.0), WASM_F32(0.0), WASM_ZERO)); |
1812 EXPECT_VERIFIES_INLINE(&env_d_dd, | 1812 EXPECT_VERIFIES_INLINE(&env_d_dd, |
1813 WASM_SELECT(WASM_F64(0.0), WASM_F64(0.0), WASM_ZERO)); | 1813 WASM_SELECT(WASM_F64(0.0), WASM_F64(0.0), WASM_ZERO)); |
1814 EXPECT_VERIFIES_INLINE(&env_l_l, | 1814 EXPECT_VERIFIES_INLINE( |
1815 WASM_SELECT(WASM_I64(0), WASM_I64(0), WASM_ZERO)); | 1815 &env_l_l, WASM_SELECT(WASM_I64V_1(0), WASM_I64V_1(0), WASM_ZERO)); |
1816 } | 1816 } |
1817 | 1817 |
1818 TEST_F(AstDecoderTest, Select_fail1) { | 1818 TEST_F(AstDecoderTest, Select_fail1) { |
1819 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_F32(0.0), WASM_GET_LOCAL(0), | 1819 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_F32(0.0), WASM_GET_LOCAL(0), |
1820 WASM_GET_LOCAL(0))); | 1820 WASM_GET_LOCAL(0))); |
1821 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_GET_LOCAL(0), WASM_F32(0.0), | 1821 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_GET_LOCAL(0), WASM_F32(0.0), |
1822 WASM_GET_LOCAL(0))); | 1822 WASM_GET_LOCAL(0))); |
1823 EXPECT_FAILURE_INLINE( | 1823 EXPECT_FAILURE_INLINE( |
1824 &env_i_i, | 1824 &env_i_i, |
1825 WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_F32(0.0))); | 1825 WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_F32(0.0))); |
(...skipping 28 matching lines...) Expand all Loading... |
1854 } | 1854 } |
1855 | 1855 |
1856 TEST_F(AstDecoderTest, Select_TypeCheck) { | 1856 TEST_F(AstDecoderTest, Select_TypeCheck) { |
1857 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), | 1857 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), |
1858 WASM_GET_LOCAL(0))); | 1858 WASM_GET_LOCAL(0))); |
1859 | 1859 |
1860 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_GET_LOCAL(0), WASM_F64(0.25), | 1860 EXPECT_FAILURE_INLINE(&env_i_i, WASM_SELECT(WASM_GET_LOCAL(0), WASM_F64(0.25), |
1861 WASM_GET_LOCAL(0))); | 1861 WASM_GET_LOCAL(0))); |
1862 | 1862 |
1863 EXPECT_FAILURE_INLINE( | 1863 EXPECT_FAILURE_INLINE( |
1864 &env_i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_I64(0))); | 1864 &env_i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_I64V_1(0))); |
1865 } | 1865 } |
1866 | 1866 |
1867 | 1867 |
1868 class WasmOpcodeLengthTest : public TestWithZone { | 1868 class WasmOpcodeLengthTest : public TestWithZone { |
1869 public: | 1869 public: |
1870 WasmOpcodeLengthTest() : TestWithZone() {} | 1870 WasmOpcodeLengthTest() : TestWithZone() {} |
1871 }; | 1871 }; |
1872 | 1872 |
1873 #define EXPECT_LENGTH(expected, opcode) \ | 1873 #define EXPECT_LENGTH(expected, opcode) \ |
1874 { \ | 1874 { \ |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2336 EXPECT_ARITY(1, kExprF64SConvertI64); | 2336 EXPECT_ARITY(1, kExprF64SConvertI64); |
2337 EXPECT_ARITY(1, kExprF64UConvertI64); | 2337 EXPECT_ARITY(1, kExprF64UConvertI64); |
2338 EXPECT_ARITY(1, kExprF64ConvertF32); | 2338 EXPECT_ARITY(1, kExprF64ConvertF32); |
2339 EXPECT_ARITY(1, kExprF64ReinterpretI64); | 2339 EXPECT_ARITY(1, kExprF64ReinterpretI64); |
2340 EXPECT_ARITY(1, kExprI32ReinterpretF32); | 2340 EXPECT_ARITY(1, kExprI32ReinterpretF32); |
2341 EXPECT_ARITY(1, kExprI64ReinterpretF64); | 2341 EXPECT_ARITY(1, kExprI64ReinterpretF64); |
2342 } | 2342 } |
2343 } // namespace wasm | 2343 } // namespace wasm |
2344 } // namespace internal | 2344 } // namespace internal |
2345 } // namespace v8 | 2345 } // namespace v8 |
OLD | NEW |