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 <stdint.h> | 5 #include <stdint.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "src/wasm/wasm-macro-gen.h" | 9 #include "src/wasm/wasm-macro-gen.h" |
10 | 10 |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 CHECK(std::isnan(result)); | 971 CHECK(std::isnan(result)); |
972 } else { | 972 } else { |
973 CHECK_EQ(expect, result); | 973 CHECK_EQ(expect, result); |
974 } | 974 } |
975 } | 975 } |
976 } | 976 } |
977 | 977 |
978 | 978 |
979 TEST(Run_Wasm_Select) { | 979 TEST(Run_Wasm_Select) { |
980 WasmRunner<int32_t> r(MachineType::Int32()); | 980 WasmRunner<int32_t> r(MachineType::Int32()); |
981 // return select(a, 11, 22); | 981 // return select(11, 22, a); |
982 BUILD(r, WASM_SELECT(WASM_GET_LOCAL(0), WASM_I8(11), WASM_I8(22))); | 982 BUILD(r, WASM_SELECT(WASM_I8(11), WASM_I8(22), WASM_GET_LOCAL(0))); |
983 FOR_INT32_INPUTS(i) { | 983 FOR_INT32_INPUTS(i) { |
984 int32_t expected = *i ? 11 : 22; | 984 int32_t expected = *i ? 11 : 22; |
985 CHECK_EQ(expected, r.Call(*i)); | 985 CHECK_EQ(expected, r.Call(*i)); |
986 } | 986 } |
987 } | 987 } |
988 | 988 |
989 | 989 |
990 TEST(Run_Wasm_Select_strict1) { | 990 TEST(Run_Wasm_Select_strict1) { |
991 WasmRunner<int32_t> r(MachineType::Int32()); | 991 WasmRunner<int32_t> r(MachineType::Int32()); |
992 // select(a, a = 11, 22); return a | 992 // select(a=0, a=1, a=2); return a |
993 BUILD(r, | 993 BUILD(r, WASM_BLOCK(2, WASM_SELECT(WASM_SET_LOCAL(0, WASM_I8(0)), |
994 WASM_BLOCK(2, WASM_SELECT(WASM_GET_LOCAL(0), | 994 WASM_SET_LOCAL(0, WASM_I8(1)), |
995 WASM_SET_LOCAL(0, WASM_I8(11)), WASM_I8(22)), | 995 WASM_SET_LOCAL(0, WASM_I8(2))), |
996 WASM_GET_LOCAL(0))); | 996 WASM_GET_LOCAL(0))); |
997 FOR_INT32_INPUTS(i) { CHECK_EQ(11, r.Call(*i)); } | 997 FOR_INT32_INPUTS(i) { CHECK_EQ(2, r.Call(*i)); } |
998 } | 998 } |
999 | 999 |
1000 | 1000 |
1001 TEST(Run_Wasm_Select_strict2) { | 1001 TEST(Run_Wasm_Select_strict2) { |
1002 WasmRunner<int32_t> r(MachineType::Int32()); | 1002 WasmRunner<int32_t> r(MachineType::Int32()); |
1003 // select(a, 11, a = 22); return a; | 1003 r.env()->AddLocals(kAstI32, 2); |
1004 BUILD(r, WASM_BLOCK(2, WASM_SELECT(WASM_GET_LOCAL(0), WASM_I8(11), | 1004 // select(b=5, c=6, a) |
1005 WASM_SET_LOCAL(0, WASM_I8(22))), | 1005 BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)), |
1006 WASM_GET_LOCAL(0))); | 1006 WASM_SET_LOCAL(2, WASM_I8(6)), WASM_GET_LOCAL(0))); |
1007 FOR_INT32_INPUTS(i) { CHECK_EQ(22, r.Call(*i)); } | 1007 FOR_INT32_INPUTS(i) { |
| 1008 int32_t expected = *i ? 5 : 6; |
| 1009 CHECK_EQ(expected, r.Call(*i)); |
| 1010 } |
| 1011 } |
| 1012 |
| 1013 TEST(Run_Wasm_Select_strict3) { |
| 1014 WasmRunner<int32_t> r(MachineType::Int32()); |
| 1015 r.env()->AddLocals(kAstI32, 2); |
| 1016 // select(b=5, c=6, a=b) |
| 1017 BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)), |
| 1018 WASM_SET_LOCAL(2, WASM_I8(6)), |
| 1019 WASM_SET_LOCAL(0, WASM_GET_LOCAL(1)))); |
| 1020 FOR_INT32_INPUTS(i) { |
| 1021 int32_t expected = 5; |
| 1022 CHECK_EQ(expected, r.Call(*i)); |
| 1023 } |
1008 } | 1024 } |
1009 | 1025 |
1010 | 1026 |
1011 TEST(Run_Wasm_BrIf_strict) { | 1027 TEST(Run_Wasm_BrIf_strict) { |
1012 WasmRunner<int32_t> r(MachineType::Int32()); | 1028 WasmRunner<int32_t> r(MachineType::Int32()); |
1013 BUILD(r, WASM_BLOCK( | 1029 BUILD(r, WASM_BLOCK( |
1014 2, WASM_BLOCK(1, WASM_BRV_IF(0, WASM_GET_LOCAL(0), | 1030 2, WASM_BLOCK(1, WASM_BRV_IF(0, WASM_GET_LOCAL(0), |
1015 WASM_SET_LOCAL(0, WASM_I8(99)))), | 1031 WASM_SET_LOCAL(0, WASM_I8(99)))), |
1016 WASM_GET_LOCAL(0))); | 1032 WASM_GET_LOCAL(0))); |
1017 | 1033 |
(...skipping 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3339 | 3355 |
3340 #if WASM_64 | 3356 #if WASM_64 |
3341 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } | 3357 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } |
3342 #endif | 3358 #endif |
3343 | 3359 |
3344 | 3360 |
3345 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } | 3361 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } |
3346 | 3362 |
3347 | 3363 |
3348 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } | 3364 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } |
OLD | NEW |