Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: test/unittests/wasm/ast-decoder-unittest.cc

Issue 1760363003: Revert of [wasm] Update {i32,i64}.const to use signed leb128 (Closed) Base URL: http://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/wasm/test-run-wasm-module.cc ('k') | test/unittests/wasm/decoder-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
222 const int kInc = 4498211; 224 const int kInc = 4498211;
223 for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) { 225 for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) {
224 // TODO(binji): expand test for other sized int32s; 1 through 5 bytes. 226 *ptr = i;
225 byte code[] = {WASM_I32V(i)};
226 EXPECT_VERIFIES(&env_i_i, code); 227 EXPECT_VERIFIES(&env_i_i, code);
227 } 228 }
228 } 229 }
229 230
230 TEST_F(AstDecoderTest, Int8Const_fallthru2) { 231 TEST_F(AstDecoderTest, Int8Const_fallthru2) {
231 byte code[] = {WASM_I8(0), WASM_I32V_4(0x1122334)}; 232 byte code[] = {kExprI8Const, 0, kExprI32Const, 1, 2, 3, 4};
232 EXPECT_VERIFIES(&env_i_i, code); 233 EXPECT_VERIFIES(&env_i_i, code);
233 } 234 }
234 235
235 TEST_F(AstDecoderTest, Int64Const) { 236 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);
236 const int kInc = 4498211; 239 const int kInc = 4498211;
237 for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) { 240 for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) {
238 byte code[] = {WASM_I64V((static_cast<int64_t>(i) << 32) | i)}; 241 *ptr = (static_cast<int64_t>(i) << 32) | i;
239 EXPECT_VERIFIES(&env_l_l, code); 242 EXPECT_VERIFIES(&env_l_l, code);
240 } 243 }
241 } 244 }
242 245
243 TEST_F(AstDecoderTest, Float32Const) { 246 TEST_F(AstDecoderTest, Float32Const) {
244 byte code[] = {kExprF32Const, 0, 0, 0, 0}; 247 byte code[] = {kExprF32Const, 0, 0, 0, 0};
245 float* ptr = reinterpret_cast<float*>(code + 1); 248 float* ptr = reinterpret_cast<float*>(code + 1);
246 for (int i = 0; i < 30; i++) { 249 for (int i = 0; i < 30; i++) {
247 *ptr = i * -7.75f; 250 *ptr = i * -7.75f;
248 EXPECT_VERIFIES(&env_f_ff, code); 251 EXPECT_VERIFIES(&env_f_ff, code);
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 TestUnop(kExprI32UConvertF64, kAstI32, kAstF64); 776 TestUnop(kExprI32UConvertF64, kAstI32, kAstF64);
774 TestUnop(kExprF64SConvertI32, kAstF64, kAstI32); 777 TestUnop(kExprF64SConvertI32, kAstF64, kAstI32);
775 TestUnop(kExprF64UConvertI32, kAstF64, kAstI32); 778 TestUnop(kExprF64UConvertI32, kAstF64, kAstI32);
776 TestUnop(kExprF64ConvertF32, kAstF64, kAstF32); 779 TestUnop(kExprF64ConvertF32, kAstF64, kAstF32);
777 TestUnop(kExprF32SConvertI32, kAstF32, kAstI32); 780 TestUnop(kExprF32SConvertI32, kAstF32, kAstI32);
778 TestUnop(kExprF32UConvertI32, kAstF32, kAstI32); 781 TestUnop(kExprF32UConvertI32, kAstF32, kAstI32);
779 TestUnop(kExprF32ConvertF64, kAstF32, kAstF64); 782 TestUnop(kExprF32ConvertF64, kAstF32, kAstF64);
780 } 783 }
781 784
782 TEST_F(AstDecoderTest, MacrosStmt) { 785 TEST_F(AstDecoderTest, MacrosStmt) {
783 VERIFY(WASM_SET_LOCAL(0, WASM_I32V_3(87348))); 786 VERIFY(WASM_SET_LOCAL(0, WASM_I32(87348)));
784 VERIFY(WASM_STORE_MEM(MachineType::Int32(), WASM_I8(24), WASM_I8(40))); 787 VERIFY(WASM_STORE_MEM(MachineType::Int32(), WASM_I8(24), WASM_I8(40)));
785 VERIFY(WASM_IF(WASM_GET_LOCAL(0), WASM_NOP)); 788 VERIFY(WASM_IF(WASM_GET_LOCAL(0), WASM_NOP));
786 VERIFY(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP)); 789 VERIFY(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP));
787 VERIFY(WASM_NOP); 790 VERIFY(WASM_NOP);
788 VERIFY(WASM_BLOCK(1, WASM_NOP)); 791 VERIFY(WASM_BLOCK(1, WASM_NOP));
789 VERIFY(WASM_LOOP(1, WASM_NOP)); 792 VERIFY(WASM_LOOP(1, WASM_NOP));
790 VERIFY(WASM_LOOP(1, WASM_BREAK(0))); 793 VERIFY(WASM_LOOP(1, WASM_BREAK(0)));
791 VERIFY(WASM_LOOP(1, WASM_CONTINUE(0))); 794 VERIFY(WASM_LOOP(1, WASM_CONTINUE(0)));
792 } 795 }
793 796
794 TEST_F(AstDecoderTest, MacrosBreak) { 797 TEST_F(AstDecoderTest, MacrosBreak) {
795 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BREAK(0))); 798 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BREAK(0)));
796 799
797 EXPECT_VERIFIES_INLINE(&env_i_i, WASM_LOOP(1, WASM_BREAKV(0, WASM_ZERO))); 800 EXPECT_VERIFIES_INLINE(&env_i_i, WASM_LOOP(1, WASM_BREAKV(0, WASM_ZERO)));
798 EXPECT_VERIFIES_INLINE(&env_l_l, 801 EXPECT_VERIFIES_INLINE(&env_l_l, WASM_LOOP(1, WASM_BREAKV(0, WASM_I64(0))));
799 WASM_LOOP(1, WASM_BREAKV(0, WASM_I64V_1(0))));
800 EXPECT_VERIFIES_INLINE(&env_f_ff, 802 EXPECT_VERIFIES_INLINE(&env_f_ff,
801 WASM_LOOP(1, WASM_BREAKV(0, WASM_F32(0.0)))); 803 WASM_LOOP(1, WASM_BREAKV(0, WASM_F32(0.0))));
802 EXPECT_VERIFIES_INLINE(&env_d_dd, 804 EXPECT_VERIFIES_INLINE(&env_d_dd,
803 WASM_LOOP(1, WASM_BREAKV(0, WASM_F64(0.0)))); 805 WASM_LOOP(1, WASM_BREAKV(0, WASM_F64(0.0))));
804 } 806 }
805 807
806 TEST_F(AstDecoderTest, MacrosContinue) { 808 TEST_F(AstDecoderTest, MacrosContinue) {
807 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_CONTINUE(0))); 809 EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_CONTINUE(0)));
808 } 810 }
809 811
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 888
887 TEST_F(AstDecoderTest, MacrosInt64) { 889 TEST_F(AstDecoderTest, MacrosInt64) {
888 FunctionEnv env_i_ll; 890 FunctionEnv env_i_ll;
889 FunctionEnv env_l_ll; 891 FunctionEnv env_l_ll;
890 init_env(&env_i_ll, sigs.i_ll()); 892 init_env(&env_i_ll, sigs.i_ll());
891 init_env(&env_l_ll, sigs.l_ll()); 893 init_env(&env_l_ll, sigs.l_ll());
892 894
893 #define VERIFY_L_LL(...) EXPECT_VERIFIES_INLINE(&env_l_ll, __VA_ARGS__) 895 #define VERIFY_L_LL(...) EXPECT_VERIFIES_INLINE(&env_l_ll, __VA_ARGS__)
894 #define VERIFY_I_LL(...) EXPECT_VERIFIES_INLINE(&env_i_ll, __VA_ARGS__) 896 #define VERIFY_I_LL(...) EXPECT_VERIFIES_INLINE(&env_i_ll, __VA_ARGS__)
895 897
896 VERIFY_L_LL(WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_I64V_1(12))); 898 VERIFY_L_LL(WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_I64(12)));
897 VERIFY_L_LL(WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_I64V_1(13))); 899 VERIFY_L_LL(WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_I64(13)));
898 VERIFY_L_LL(WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_I64V_1(14))); 900 VERIFY_L_LL(WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_I64(14)));
899 VERIFY_L_LL(WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64V_1(15))); 901 VERIFY_L_LL(WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64(15)));
900 VERIFY_L_LL(WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64V_1(16))); 902 VERIFY_L_LL(WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64(16)));
901 VERIFY_L_LL(WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_I64V_1(17))); 903 VERIFY_L_LL(WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_I64(17)));
902 VERIFY_L_LL(WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_I64V_1(18))); 904 VERIFY_L_LL(WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_I64(18)));
903 VERIFY_L_LL(WASM_I64_AND(WASM_GET_LOCAL(0), WASM_I64V_1(19))); 905 VERIFY_L_LL(WASM_I64_AND(WASM_GET_LOCAL(0), WASM_I64(19)));
904 VERIFY_L_LL(WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_I64V_1(20))); 906 VERIFY_L_LL(WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_I64(20)));
905 VERIFY_L_LL(WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_I64V_1(21))); 907 VERIFY_L_LL(WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_I64(21)));
906 908
907 VERIFY_L_LL(WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(22))); 909 VERIFY_L_LL(WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64(22)));
908 VERIFY_L_LL(WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(23))); 910 VERIFY_L_LL(WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64(23)));
909 VERIFY_L_LL(WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(24))); 911 VERIFY_L_LL(WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64(24)));
910 VERIFY_L_LL(WASM_I64_ROR(WASM_GET_LOCAL(0), WASM_I64V_1(24))); 912 VERIFY_L_LL(WASM_I64_ROR(WASM_GET_LOCAL(0), WASM_I64(24)));
911 VERIFY_L_LL(WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_I64V_1(24))); 913 VERIFY_L_LL(WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_I64(24)));
912 914
913 VERIFY_I_LL(WASM_I64_LTS(WASM_GET_LOCAL(0), WASM_I64V_1(26))); 915 VERIFY_I_LL(WASM_I64_LTS(WASM_GET_LOCAL(0), WASM_I64(26)));
914 VERIFY_I_LL(WASM_I64_LES(WASM_GET_LOCAL(0), WASM_I64V_1(27))); 916 VERIFY_I_LL(WASM_I64_LES(WASM_GET_LOCAL(0), WASM_I64(27)));
915 VERIFY_I_LL(WASM_I64_LTU(WASM_GET_LOCAL(0), WASM_I64V_1(28))); 917 VERIFY_I_LL(WASM_I64_LTU(WASM_GET_LOCAL(0), WASM_I64(28)));
916 VERIFY_I_LL(WASM_I64_LEU(WASM_GET_LOCAL(0), WASM_I64V_1(29))); 918 VERIFY_I_LL(WASM_I64_LEU(WASM_GET_LOCAL(0), WASM_I64(29)));
917 919
918 VERIFY_I_LL(WASM_I64_GTS(WASM_GET_LOCAL(0), WASM_I64V_1(26))); 920 VERIFY_I_LL(WASM_I64_GTS(WASM_GET_LOCAL(0), WASM_I64(26)));
919 VERIFY_I_LL(WASM_I64_GES(WASM_GET_LOCAL(0), WASM_I64V_1(27))); 921 VERIFY_I_LL(WASM_I64_GES(WASM_GET_LOCAL(0), WASM_I64(27)));
920 VERIFY_I_LL(WASM_I64_GTU(WASM_GET_LOCAL(0), WASM_I64V_1(28))); 922 VERIFY_I_LL(WASM_I64_GTU(WASM_GET_LOCAL(0), WASM_I64(28)));
921 VERIFY_I_LL(WASM_I64_GEU(WASM_GET_LOCAL(0), WASM_I64V_1(29))); 923 VERIFY_I_LL(WASM_I64_GEU(WASM_GET_LOCAL(0), WASM_I64(29)));
922 924
923 VERIFY_I_LL(WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_I64V_1(25))); 925 VERIFY_I_LL(WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_I64(25)));
924 VERIFY_I_LL(WASM_I64_NE(WASM_GET_LOCAL(0), WASM_I64V_1(25))); 926 VERIFY_I_LL(WASM_I64_NE(WASM_GET_LOCAL(0), WASM_I64(25)));
925 } 927 }
926 928
927 TEST_F(AstDecoderTest, AllSimpleExpressions) { 929 TEST_F(AstDecoderTest, AllSimpleExpressions) {
928 // Test all simple expressions which are described by a signature. 930 // Test all simple expressions which are described by a signature.
929 #define DECODE_TEST(name, opcode, sig) \ 931 #define DECODE_TEST(name, opcode, sig) \
930 { \ 932 { \
931 FunctionSig* sig = WasmOpcodes::Signature(kExpr##name); \ 933 FunctionSig* sig = WasmOpcodes::Signature(kExpr##name); \
932 if (sig->parameter_count() == 1) { \ 934 if (sig->parameter_count() == 1) { \
933 TestUnop(kExpr##name, sig); \ 935 TestUnop(kExpr##name, sig); \
934 } else { \ 936 } else { \
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 WASM_CALL_FUNCTION(0, WASM_F32(0.1), WASM_F32(0.1), WASM_F32(11))); 1189 WASM_CALL_FUNCTION(0, WASM_F32(0.1), WASM_F32(0.1), WASM_F32(11)));
1188 } 1190 }
1189 1191
1190 TEST_F(AstDecoderTest, CallsWithMismatchedSigs2) { 1192 TEST_F(AstDecoderTest, CallsWithMismatchedSigs2) {
1191 FunctionEnv* env = &env_i_i; 1193 FunctionEnv* env = &env_i_i;
1192 TestModuleEnv module_env; 1194 TestModuleEnv module_env;
1193 env->module = &module_env; 1195 env->module = &module_env;
1194 1196
1195 module_env.AddFunction(sigs.i_i()); 1197 module_env.AddFunction(sigs.i_i());
1196 1198
1197 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64V_1(17))); 1199 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64(17)));
1198 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F32(17.1))); 1200 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F32(17.1)));
1199 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(17.1))); 1201 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(17.1)));
1200 } 1202 }
1201 1203
1202 TEST_F(AstDecoderTest, CallsWithMismatchedSigs3) { 1204 TEST_F(AstDecoderTest, CallsWithMismatchedSigs3) {
1203 FunctionEnv* env = &env_i_i; 1205 FunctionEnv* env = &env_i_i;
1204 TestModuleEnv module_env; 1206 TestModuleEnv module_env;
1205 env->module = &module_env; 1207 env->module = &module_env;
1206 1208
1207 module_env.AddFunction(sigs.i_f()); 1209 module_env.AddFunction(sigs.i_f());
1208 1210
1209 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I8(17))); 1211 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I8(17)));
1210 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64V_1(27))); 1212 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64(27)));
1211 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(37.2))); 1213 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(37.2)));
1212 1214
1213 module_env.AddFunction(sigs.i_d()); 1215 module_env.AddFunction(sigs.i_d());
1214 1216
1215 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I8(16))); 1217 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I8(16)));
1216 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I64V_1(16))); 1218 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I64(16)));
1217 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_F32(17.6))); 1219 EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_F32(17.6)));
1218 } 1220 }
1219 1221
1220 TEST_F(AstDecoderTest, SimpleIndirectCalls) { 1222 TEST_F(AstDecoderTest, SimpleIndirectCalls) {
1221 FunctionEnv* env = &env_i_i; 1223 FunctionEnv* env = &env_i_i;
1222 TestModuleEnv module_env; 1224 TestModuleEnv module_env;
1223 env->module = &module_env; 1225 env->module = &module_env;
1224 1226
1225 byte f0 = module_env.AddSignature(sigs.i_v()); 1227 byte f0 = module_env.AddSignature(sigs.i_v());
1226 byte f1 = module_env.AddSignature(sigs.i_i()); 1228 byte f1 = module_env.AddSignature(sigs.i_i());
(...skipping 22 matching lines...) Expand all
1249 } 1251 }
1250 1252
1251 TEST_F(AstDecoderTest, IndirectCallsWithMismatchedSigs3) { 1253 TEST_F(AstDecoderTest, IndirectCallsWithMismatchedSigs3) {
1252 FunctionEnv* env = &env_i_i; 1254 FunctionEnv* env = &env_i_i;
1253 TestModuleEnv module_env; 1255 TestModuleEnv module_env;
1254 env->module = &module_env; 1256 env->module = &module_env;
1255 1257
1256 byte f0 = module_env.AddFunction(sigs.i_f()); 1258 byte f0 = module_env.AddFunction(sigs.i_f());
1257 1259
1258 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_I8(17))); 1260 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_I8(17)));
1259 EXPECT_FAILURE_INLINE(env, 1261 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_I64(27)));
1260 WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_I64V_1(27)));
1261 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_F64(37.2))); 1262 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_F64(37.2)));
1262 1263
1263 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_I8(17))); 1264 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_I8(17)));
1264 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_I64V_1(27))); 1265 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_I64(27)));
1265 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_F64(37.2))); 1266 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_F64(37.2)));
1266 1267
1267 byte f1 = module_env.AddFunction(sigs.i_d()); 1268 byte f1 = module_env.AddFunction(sigs.i_d());
1268 1269
1269 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_I8(16))); 1270 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_I8(16)));
1270 EXPECT_FAILURE_INLINE(env, 1271 EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_I64(16)));
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_I64V_1(27))); 1298 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f0, WASM_I64(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_I64V_1(16))); 1305 EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f1, WASM_I64(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
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( 1814 EXPECT_VERIFIES_INLINE(&env_l_l,
1815 &env_l_l, WASM_SELECT(WASM_I64V_1(0), WASM_I64V_1(0), WASM_ZERO)); 1815 WASM_SELECT(WASM_I64(0), WASM_I64(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
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_I64V_1(0))); 1864 &env_i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_I64(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
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
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-module.cc ('k') | test/unittests/wasm/decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698