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

Side by Side Diff: test/cctest/wasm/test-run-wasm.cc

Issue 2170773003: [wasm] Remove the explicit count from WASM_BLOCK and WASM_LOOP macros. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | « src/wasm/wasm-macro-gen.h ('k') | test/cctest/wasm/test-run-wasm-64.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 <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/base/platform/elapsed-timer.h" 9 #include "src/base/platform/elapsed-timer.h"
10 10
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 } 867 }
868 868
869 WASM_EXEC_TEST(BrTable1) { 869 WASM_EXEC_TEST(BrTable1) {
870 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 870 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
871 BUILD(r, B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0))), RET_I8(93)); 871 BUILD(r, B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0))), RET_I8(93));
872 FOR_INT32_INPUTS(i) { CHECK_EQ(93, r.Call(*i)); } 872 FOR_INT32_INPUTS(i) { CHECK_EQ(93, r.Call(*i)); }
873 } 873 }
874 874
875 WASM_EXEC_TEST(BrTable_loop) { 875 WASM_EXEC_TEST(BrTable_loop) {
876 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 876 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
877 BUILD(r, 877 BUILD(r, B2(WASM_LOOP(WASM_BR_TABLE(WASM_INC_LOCAL_BY(0, 1), 2, BR_TARGET(2),
878 B2(WASM_LOOP(1, WASM_BR_TABLE(WASM_INC_LOCAL_BY(0, 1), 2, BR_TARGET(2),
879 BR_TARGET(1), BR_TARGET(0))), 878 BR_TARGET(1), BR_TARGET(0))),
880 RET_I8(99)), 879 RET_I8(99)),
881 WASM_I8(98)); 880 WASM_I8(98));
882 CHECK_EQ(99, r.Call(0)); 881 CHECK_EQ(99, r.Call(0));
883 CHECK_EQ(98, r.Call(-1)); 882 CHECK_EQ(98, r.Call(-1));
884 CHECK_EQ(98, r.Call(-2)); 883 CHECK_EQ(98, r.Call(-2));
885 CHECK_EQ(98, r.Call(-3)); 884 CHECK_EQ(98, r.Call(-3));
886 CHECK_EQ(98, r.Call(-100)); 885 CHECK_EQ(98, r.Call(-100));
887 } 886 }
888 887
889 WASM_EXEC_TEST(BrTable_br) { 888 WASM_EXEC_TEST(BrTable_br) {
890 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 889 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 module.WriteMemory(&memory[0], expected); 1014 module.WriteMemory(&memory[0], expected);
1016 CHECK_EQ(expected, r.Call()); 1015 CHECK_EQ(expected, r.Call());
1017 } 1016 }
1018 } 1017 }
1019 1018
1020 WASM_EXEC_TEST(I32ReinterpretF32) { 1019 WASM_EXEC_TEST(I32ReinterpretF32) {
1021 TestingModule module(execution_mode); 1020 TestingModule module(execution_mode);
1022 int32_t* memory = module.AddMemoryElems<int32_t>(8); 1021 int32_t* memory = module.AddMemoryElems<int32_t>(8);
1023 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1022 WasmRunner<int32_t> r(&module, MachineType::Int32());
1024 1023
1025 BUILD(r, WASM_BLOCK( 1024 BUILD(r,
1026 2, WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO, 1025 WASM_BLOCK(WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO,
1027 WASM_F32_REINTERPRET_I32(WASM_GET_LOCAL(0))), 1026 WASM_F32_REINTERPRET_I32(WASM_GET_LOCAL(0))),
1028 WASM_I8(107))); 1027 WASM_I8(107)));
1029 1028
1030 FOR_INT32_INPUTS(i) { 1029 FOR_INT32_INPUTS(i) {
1031 int32_t expected = *i; 1030 int32_t expected = *i;
1032 CHECK_EQ(107, r.Call(expected)); 1031 CHECK_EQ(107, r.Call(expected));
1033 CHECK_EQ(expected, module.ReadMemory(&memory[0])); 1032 CHECK_EQ(expected, module.ReadMemory(&memory[0]));
1034 } 1033 }
1035 } 1034 }
1036 1035
1037 WASM_EXEC_TEST(ReturnStore) { 1036 WASM_EXEC_TEST(ReturnStore) {
1038 TestingModule module(execution_mode); 1037 TestingModule module(execution_mode);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 } 1130 }
1132 1131
1133 WASM_EXEC_TEST(Loop_empty) { 1132 WASM_EXEC_TEST(Loop_empty) {
1134 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1133 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1135 BUILD(r, kExprLoop, kExprEnd, WASM_GET_LOCAL(0)); 1134 BUILD(r, kExprLoop, kExprEnd, WASM_GET_LOCAL(0));
1136 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 1135 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
1137 } 1136 }
1138 1137
1139 WASM_EXEC_TEST(Loop_empty_br1) { 1138 WASM_EXEC_TEST(Loop_empty_br1) {
1140 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1139 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1141 BUILD(r, WASM_LOOP(1, WASM_BR(1)), WASM_GET_LOCAL(0)); 1140 BUILD(r, WASM_LOOP(WASM_BR(1)), WASM_GET_LOCAL(0));
1142 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 1141 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
1143 } 1142 }
1144 1143
1145 WASM_EXEC_TEST(Loop_empty_brif1) { 1144 WASM_EXEC_TEST(Loop_empty_brif1) {
1146 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1145 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1147 BUILD(r, WASM_LOOP(1, WASM_BR_IF(1, WASM_ZERO)), WASM_GET_LOCAL(0)); 1146 BUILD(r, WASM_LOOP(WASM_BR_IF(1, WASM_ZERO)), WASM_GET_LOCAL(0));
1148 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 1147 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
1149 } 1148 }
1150 1149
1151 WASM_EXEC_TEST(Loop_empty_brif2) { 1150 WASM_EXEC_TEST(Loop_empty_brif2) {
1152 WasmRunner<uint32_t> r(execution_mode, MachineType::Uint32(), 1151 WasmRunner<uint32_t> r(execution_mode, MachineType::Uint32(),
1153 MachineType::Uint32()); 1152 MachineType::Uint32());
1154 BUILD(r, WASM_LOOP(1, WASM_BR_IF(1, WASM_GET_LOCAL(1))), WASM_GET_LOCAL(0)); 1153 BUILD(r, WASM_LOOP(WASM_BR_IF(1, WASM_GET_LOCAL(1))), WASM_GET_LOCAL(0));
1155 FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i, *i + 1)); } 1154 FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i, *i + 1)); }
1156 } 1155 }
1157 1156
1158 WASM_EXEC_TEST(Block_BrIf_P) { 1157 WASM_EXEC_TEST(Block_BrIf_P) {
1159 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1158 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1160 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(51), WASM_GET_LOCAL(0)), WASM_I8(52))); 1159 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(51), WASM_GET_LOCAL(0)), WASM_I8(52)));
1161 FOR_INT32_INPUTS(i) { 1160 FOR_INT32_INPUTS(i) {
1162 int32_t expected = *i ? 51 : 52; 1161 int32_t expected = *i ? 51 : 52;
1163 CHECK_EQ(expected, r.Call(*i)); 1162 CHECK_EQ(expected, r.Call(*i));
1164 } 1163 }
(...skipping 22 matching lines...) Expand all
1187 RET_I8(82))); // -- 1186 RET_I8(82))); // --
1188 FOR_INT32_INPUTS(i) { 1187 FOR_INT32_INPUTS(i) {
1189 int32_t expected = *i ? 81 : 82; 1188 int32_t expected = *i ? 81 : 82;
1190 CHECK_EQ(expected, r.Call(*i)); 1189 CHECK_EQ(expected, r.Call(*i));
1191 } 1190 }
1192 } 1191 }
1193 1192
1194 WASM_EXEC_TEST(Block_If_P_assign) { 1193 WASM_EXEC_TEST(Block_If_P_assign) {
1195 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1194 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1196 // { if (p0) p0 = 61; p0; } 1195 // { if (p0) p0 = 61; p0; }
1197 BUILD(r, WASM_BLOCK( 1196 BUILD(r,
1198 2, WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I8(61))), 1197 WASM_BLOCK(WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I8(61))),
1199 WASM_GET_LOCAL(0))); 1198 WASM_GET_LOCAL(0)));
1200 FOR_INT32_INPUTS(i) { 1199 FOR_INT32_INPUTS(i) {
1201 int32_t expected = *i ? 61 : *i; 1200 int32_t expected = *i ? 61 : *i;
1202 CHECK_EQ(expected, r.Call(*i)); 1201 CHECK_EQ(expected, r.Call(*i));
1203 } 1202 }
1204 } 1203 }
1205 1204
1206 WASM_EXEC_TEST(DanglingAssign) { 1205 WASM_EXEC_TEST(DanglingAssign) {
1207 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1206 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1208 // { return 0; p0 = 0; } 1207 // { return 0; p0 = 0; }
1209 BUILD(r, B2(RET_I8(99), WASM_SET_LOCAL(0, WASM_ZERO))); 1208 BUILD(r, B2(RET_I8(99), WASM_SET_LOCAL(0, WASM_ZERO)));
(...skipping 19 matching lines...) Expand all
1229 WASM_I8(11), // -- 1228 WASM_I8(11), // --
1230 WASM_I8(22))); // -- 1229 WASM_I8(22))); // --
1231 FOR_INT32_INPUTS(i) { 1230 FOR_INT32_INPUTS(i) {
1232 int32_t expected = *i ? 11 : 22; 1231 int32_t expected = *i ? 11 : 22;
1233 CHECK_EQ(expected, r.Call(*i)); 1232 CHECK_EQ(expected, r.Call(*i));
1234 } 1233 }
1235 } 1234 }
1236 1235
1237 WASM_EXEC_TEST(CountDown) { 1236 WASM_EXEC_TEST(CountDown) {
1238 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1237 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1239 BUILD(r, 1238 BUILD(r, WASM_BLOCK(
1240 WASM_BLOCK( 1239 WASM_LOOP(WASM_IF(
1241 2, WASM_LOOP( 1240 WASM_GET_LOCAL(0),
1242 1, WASM_IF(WASM_GET_LOCAL(0), 1241 WASM_BRV(1, WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0),
1243 WASM_BRV(1, WASM_SET_LOCAL(
1244 0, WASM_I32_SUB(WASM_GET_LOCAL(0),
1245 WASM_I8(1)))))), 1242 WASM_I8(1)))))),
1246 WASM_GET_LOCAL(0))); 1243 WASM_GET_LOCAL(0)));
1247 CHECK_EQ(0, r.Call(1)); 1244 CHECK_EQ(0, r.Call(1));
1248 CHECK_EQ(0, r.Call(10)); 1245 CHECK_EQ(0, r.Call(10));
1249 CHECK_EQ(0, r.Call(100)); 1246 CHECK_EQ(0, r.Call(100));
1250 } 1247 }
1251 1248
1252 WASM_EXEC_TEST(CountDown_fallthru) { 1249 WASM_EXEC_TEST(CountDown_fallthru) {
1253 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1250 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1254 BUILD(r, 1251 BUILD(r, WASM_BLOCK(
1255 WASM_BLOCK( 1252 WASM_LOOP(WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)), WASM_BREAK(1)),
1256 2, WASM_LOOP(3, WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)), WASM_BREAK(1)),
1257 WASM_SET_LOCAL( 1253 WASM_SET_LOCAL(
1258 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))), 1254 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))),
1259 WASM_CONTINUE(0)), 1255 WASM_CONTINUE(0)),
1260 WASM_GET_LOCAL(0))); 1256 WASM_GET_LOCAL(0)));
1261 CHECK_EQ(0, r.Call(1)); 1257 CHECK_EQ(0, r.Call(1));
1262 CHECK_EQ(0, r.Call(10)); 1258 CHECK_EQ(0, r.Call(10));
1263 CHECK_EQ(0, r.Call(100)); 1259 CHECK_EQ(0, r.Call(100));
1264 } 1260 }
1265 1261
1266 WASM_EXEC_TEST(WhileCountDown) { 1262 WASM_EXEC_TEST(WhileCountDown) {
1267 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1263 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1268 BUILD(r, WASM_BLOCK( 1264 BUILD(r,
1269 2, WASM_WHILE(WASM_GET_LOCAL(0), 1265 WASM_BLOCK(WASM_WHILE(WASM_GET_LOCAL(0),
1270 WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), 1266 WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0),
1271 WASM_I8(1)))), 1267 WASM_I8(1)))),
1272 WASM_GET_LOCAL(0))); 1268 WASM_GET_LOCAL(0)));
1273 CHECK_EQ(0, r.Call(1)); 1269 CHECK_EQ(0, r.Call(1));
1274 CHECK_EQ(0, r.Call(10)); 1270 CHECK_EQ(0, r.Call(10));
1275 CHECK_EQ(0, r.Call(100)); 1271 CHECK_EQ(0, r.Call(100));
1276 } 1272 }
1277 1273
1278 WASM_EXEC_TEST(Loop_if_break1) { 1274 WASM_EXEC_TEST(Loop_if_break1) {
1279 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1275 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1280 BUILD(r, B2(WASM_LOOP(2, WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)), 1276 BUILD(r, B2(WASM_LOOP(WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)),
1281 WASM_SET_LOCAL(0, WASM_I8(99))), 1277 WASM_SET_LOCAL(0, WASM_I8(99))),
1282 WASM_GET_LOCAL(0))); 1278 WASM_GET_LOCAL(0)));
1283 CHECK_EQ(99, r.Call(0)); 1279 CHECK_EQ(99, r.Call(0));
1284 CHECK_EQ(3, r.Call(3)); 1280 CHECK_EQ(3, r.Call(3));
1285 CHECK_EQ(10000, r.Call(10000)); 1281 CHECK_EQ(10000, r.Call(10000));
1286 CHECK_EQ(-29, r.Call(-29)); 1282 CHECK_EQ(-29, r.Call(-29));
1287 } 1283 }
1288 1284
1289 WASM_EXEC_TEST(Loop_if_break2) { 1285 WASM_EXEC_TEST(Loop_if_break2) {
1290 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1286 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1291 BUILD(r, B2(WASM_LOOP(2, WASM_BR_IF(1, WASM_GET_LOCAL(0)), 1287 BUILD(r, B2(WASM_LOOP(WASM_BR_IF(1, WASM_GET_LOCAL(0)),
1292 WASM_SET_LOCAL(0, WASM_I8(99))), 1288 WASM_SET_LOCAL(0, WASM_I8(99))),
1293 WASM_GET_LOCAL(0))); 1289 WASM_GET_LOCAL(0)));
1294 CHECK_EQ(99, r.Call(0)); 1290 CHECK_EQ(99, r.Call(0));
1295 CHECK_EQ(3, r.Call(3)); 1291 CHECK_EQ(3, r.Call(3));
1296 CHECK_EQ(10000, r.Call(10000)); 1292 CHECK_EQ(10000, r.Call(10000));
1297 CHECK_EQ(-29, r.Call(-29)); 1293 CHECK_EQ(-29, r.Call(-29));
1298 } 1294 }
1299 1295
1300 WASM_EXEC_TEST(Loop_if_break_fallthru) { 1296 WASM_EXEC_TEST(Loop_if_break_fallthru) {
1301 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1297 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1302 BUILD(r, B1(WASM_LOOP(2, WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)), 1298 BUILD(r, B1(WASM_LOOP(WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)),
1303 WASM_SET_LOCAL(0, WASM_I8(93)))), 1299 WASM_SET_LOCAL(0, WASM_I8(93)))),
1304 WASM_GET_LOCAL(0)); 1300 WASM_GET_LOCAL(0));
1305 CHECK_EQ(93, r.Call(0)); 1301 CHECK_EQ(93, r.Call(0));
1306 CHECK_EQ(3, r.Call(3)); 1302 CHECK_EQ(3, r.Call(3));
1307 CHECK_EQ(10001, r.Call(10001)); 1303 CHECK_EQ(10001, r.Call(10001));
1308 CHECK_EQ(-22, r.Call(-22)); 1304 CHECK_EQ(-22, r.Call(-22));
1309 } 1305 }
1310 1306
1311 WASM_EXEC_TEST(IfBreak1) { 1307 WASM_EXEC_TEST(IfBreak1) {
1312 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1308 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 } 1559 }
1564 } 1560 }
1565 1561
1566 WASM_EXEC_TEST(MemI32_Sum) { 1562 WASM_EXEC_TEST(MemI32_Sum) {
1567 const int kNumElems = 20; 1563 const int kNumElems = 20;
1568 TestingModule module(execution_mode); 1564 TestingModule module(execution_mode);
1569 uint32_t* memory = module.AddMemoryElems<uint32_t>(kNumElems); 1565 uint32_t* memory = module.AddMemoryElems<uint32_t>(kNumElems);
1570 WasmRunner<uint32_t> r(&module, MachineType::Int32()); 1566 WasmRunner<uint32_t> r(&module, MachineType::Int32());
1571 const byte kSum = r.AllocateLocal(kAstI32); 1567 const byte kSum = r.AllocateLocal(kAstI32);
1572 1568
1573 BUILD(r, WASM_BLOCK( 1569 BUILD(r,
1574 2, WASM_WHILE( 1570 WASM_BLOCK(
1575 WASM_GET_LOCAL(0), 1571 WASM_WHILE(
1576 WASM_BLOCK( 1572 WASM_GET_LOCAL(0),
1577 2, WASM_SET_LOCAL( 1573 WASM_BLOCK(
1578 kSum, WASM_I32_ADD( 1574 WASM_SET_LOCAL(
1579 WASM_GET_LOCAL(kSum), 1575 kSum, WASM_I32_ADD(WASM_GET_LOCAL(kSum),
1580 WASM_LOAD_MEM(MachineType::Int32(), 1576 WASM_LOAD_MEM(MachineType::Int32(),
1581 WASM_GET_LOCAL(0)))), 1577 WASM_GET_LOCAL(0)))),
1582 WASM_SET_LOCAL( 1578 WASM_SET_LOCAL(
1583 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(4))))), 1579 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(4))))),
1584 WASM_GET_LOCAL(1))); 1580 WASM_GET_LOCAL(1)));
1585 1581
1586 // Run 4 trials. 1582 // Run 4 trials.
1587 for (int i = 0; i < 3; ++i) { 1583 for (int i = 0; i < 3; ++i) {
1588 module.RandomizeMemory(i * 33); 1584 module.RandomizeMemory(i * 33);
1589 uint32_t expected = 0; 1585 uint32_t expected = 0;
1590 for (size_t j = kNumElems - 1; j > 0; --j) { 1586 for (size_t j = kNumElems - 1; j > 0; --j) {
1591 expected += module.ReadMemory(&memory[j]); 1587 expected += module.ReadMemory(&memory[j]);
1592 } 1588 }
1593 uint32_t result = r.Call(4 * (kNumElems - 1)); 1589 uint32_t result = r.Call(4 * (kNumElems - 1));
1594 CHECK_EQ(expected, result); 1590 CHECK_EQ(expected, result);
(...skipping 21 matching lines...) Expand all
1616 module.AddMemoryElems<float>(kSize); 1612 module.AddMemoryElems<float>(kSize);
1617 float* buffer = module.raw_mem_start<float>(); 1613 float* buffer = module.raw_mem_start<float>();
1618 module.WriteMemory(&buffer[0], -99.25f); 1614 module.WriteMemory(&buffer[0], -99.25f);
1619 module.WriteMemory(&buffer[1], -888.25f); 1615 module.WriteMemory(&buffer[1], -888.25f);
1620 module.WriteMemory(&buffer[2], -77.25f); 1616 module.WriteMemory(&buffer[2], -77.25f);
1621 module.WriteMemory(&buffer[3], 66666.25f); 1617 module.WriteMemory(&buffer[3], 66666.25f);
1622 module.WriteMemory(&buffer[4], 5555.25f); 1618 module.WriteMemory(&buffer[4], 5555.25f);
1623 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1619 WasmRunner<int32_t> r(&module, MachineType::Int32());
1624 const byte kSum = r.AllocateLocal(kAstF32); 1620 const byte kSum = r.AllocateLocal(kAstF32);
1625 1621
1626 BUILD(r, WASM_BLOCK( 1622 BUILD(r,
1627 3, WASM_WHILE( 1623 WASM_BLOCK(
1628 WASM_GET_LOCAL(0), 1624 WASM_WHILE(
1629 WASM_BLOCK( 1625 WASM_GET_LOCAL(0),
1630 2, WASM_SET_LOCAL( 1626 WASM_BLOCK(
1631 kSum, WASM_F32_ADD( 1627 WASM_SET_LOCAL(
1632 WASM_GET_LOCAL(kSum), 1628 kSum, WASM_F32_ADD(WASM_GET_LOCAL(kSum),
1633 WASM_LOAD_MEM(MachineType::Float32(), 1629 WASM_LOAD_MEM(MachineType::Float32(),
1634 WASM_GET_LOCAL(0)))), 1630 WASM_GET_LOCAL(0)))),
1635 WASM_SET_LOCAL( 1631 WASM_SET_LOCAL(
1636 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(4))))), 1632 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(4))))),
1637 WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO, 1633 WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO,
1638 WASM_GET_LOCAL(kSum)), 1634 WASM_GET_LOCAL(kSum)),
1639 WASM_GET_LOCAL(0))); 1635 WASM_GET_LOCAL(0)));
1640 1636
1641 CHECK_EQ(0, r.Call(4 * (kSize - 1))); 1637 CHECK_EQ(0, r.Call(4 * (kSize - 1)));
1642 CHECK_NE(-99.25f, module.ReadMemory(&buffer[0])); 1638 CHECK_NE(-99.25f, module.ReadMemory(&buffer[0]));
1643 CHECK_EQ(71256.0f, module.ReadMemory(&buffer[0])); 1639 CHECK_EQ(71256.0f, module.ReadMemory(&buffer[0]));
1644 } 1640 }
1645 1641
1646 template <typename T> 1642 template <typename T>
1647 T GenerateAndRunFold(WasmExecutionMode execution_mode, WasmOpcode binop, 1643 T GenerateAndRunFold(WasmExecutionMode execution_mode, WasmOpcode binop,
1648 T* buffer, uint32_t size, LocalType astType, 1644 T* buffer, uint32_t size, LocalType astType,
1649 MachineType memType) { 1645 MachineType memType) {
1650 TestingModule module(execution_mode); 1646 TestingModule module(execution_mode);
1651 T* memory = module.AddMemoryElems<T>(size); 1647 T* memory = module.AddMemoryElems<T>(size);
1652 for (uint32_t i = 0; i < size; ++i) { 1648 for (uint32_t i = 0; i < size; ++i) {
1653 module.WriteMemory(&memory[i], buffer[i]); 1649 module.WriteMemory(&memory[i], buffer[i]);
1654 } 1650 }
1655 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1651 WasmRunner<int32_t> r(&module, MachineType::Int32());
1656 const byte kAccum = r.AllocateLocal(astType); 1652 const byte kAccum = r.AllocateLocal(astType);
1657 1653
1658 BUILD( 1654 BUILD(r, WASM_BLOCK(
1659 r, 1655 WASM_SET_LOCAL(kAccum, WASM_LOAD_MEM(memType, WASM_ZERO)),
1660 WASM_BLOCK( 1656 WASM_WHILE(
1661 4, WASM_SET_LOCAL(kAccum, WASM_LOAD_MEM(memType, WASM_ZERO)), 1657 WASM_GET_LOCAL(0),
1662 WASM_WHILE( 1658 WASM_BLOCK(
1663 WASM_GET_LOCAL(0), 1659 WASM_SET_LOCAL(
1664 WASM_BLOCK( 1660 kAccum, WASM_BINOP(binop, WASM_GET_LOCAL(kAccum),
1665 2, WASM_SET_LOCAL( 1661 WASM_LOAD_MEM(
1666 kAccum, 1662 memType, WASM_GET_LOCAL(0)))),
1667 WASM_BINOP(binop, WASM_GET_LOCAL(kAccum), 1663 WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0),
1668 WASM_LOAD_MEM(memType, WASM_GET_LOCAL(0)))), 1664 WASM_I8(sizeof(T)))))),
1669 WASM_SET_LOCAL( 1665 WASM_STORE_MEM(memType, WASM_ZERO, WASM_GET_LOCAL(kAccum)),
1670 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(sizeof(T)))))), 1666 WASM_GET_LOCAL(0)));
1671 WASM_STORE_MEM(memType, WASM_ZERO, WASM_GET_LOCAL(kAccum)),
1672 WASM_GET_LOCAL(0)));
1673 r.Call(static_cast<int>(sizeof(T) * (size - 1))); 1667 r.Call(static_cast<int>(sizeof(T) * (size - 1)));
1674 return module.ReadMemory(&memory[0]); 1668 return module.ReadMemory(&memory[0]);
1675 } 1669 }
1676 1670
1677 WASM_EXEC_TEST(MemF64_Mul) { 1671 WASM_EXEC_TEST(MemF64_Mul) {
1678 const size_t kSize = 6; 1672 const size_t kSize = 6;
1679 double buffer[kSize] = {1, 2, 2, 2, 2, 2}; 1673 double buffer[kSize] = {1, 2, 2, 2, 2, 2};
1680 double result = 1674 double result =
1681 GenerateAndRunFold<double>(execution_mode, kExprF64Mul, buffer, kSize, 1675 GenerateAndRunFold<double>(execution_mode, kExprF64Mul, buffer, kSize,
1682 kAstF64, MachineType::Float64()); 1676 kAstF64, MachineType::Float64());
1683 CHECK_EQ(32, result); 1677 CHECK_EQ(32, result);
1684 } 1678 }
1685 1679
1686 WASM_EXEC_TEST(Build_Wasm_Infinite_Loop) { 1680 WASM_EXEC_TEST(Build_Wasm_Infinite_Loop) {
1687 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1681 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1688 // Only build the graph and compile, don't run. 1682 // Only build the graph and compile, don't run.
1689 BUILD(r, WASM_INFINITE_LOOP); 1683 BUILD(r, WASM_INFINITE_LOOP);
1690 } 1684 }
1691 1685
1692 WASM_EXEC_TEST(Build_Wasm_Infinite_Loop_effect) { 1686 WASM_EXEC_TEST(Build_Wasm_Infinite_Loop_effect) {
1693 TestingModule module(execution_mode); 1687 TestingModule module(execution_mode);
1694 module.AddMemoryElems<int8_t>(16); 1688 module.AddMemoryElems<int8_t>(16);
1695 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1689 WasmRunner<int32_t> r(&module, MachineType::Int32());
1696 1690
1697 // Only build the graph and compile, don't run. 1691 // Only build the graph and compile, don't run.
1698 BUILD(r, WASM_LOOP(1, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))); 1692 BUILD(r, WASM_LOOP(WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)));
1699 } 1693 }
1700 1694
1701 WASM_EXEC_TEST(Unreachable0a) { 1695 WASM_EXEC_TEST(Unreachable0a) {
1702 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 1696 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
1703 BUILD(r, B2(WASM_BRV(0, WASM_I8(9)), RET(WASM_GET_LOCAL(0)))); 1697 BUILD(r, B2(WASM_BRV(0, WASM_I8(9)), RET(WASM_GET_LOCAL(0))));
1704 CHECK_EQ(9, r.Call(0)); 1698 CHECK_EQ(9, r.Call(0));
1705 CHECK_EQ(9, r.Call(1)); 1699 CHECK_EQ(9, r.Call(1));
1706 } 1700 }
1707 1701
1708 WASM_EXEC_TEST(Unreachable0b) { 1702 WASM_EXEC_TEST(Unreachable0b) {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 int32_t* var_int32 = module.AddGlobal<int32_t>(MachineType::Int32()); 1948 int32_t* var_int32 = module.AddGlobal<int32_t>(MachineType::Int32());
1955 uint32_t* var_uint32 = module.AddGlobal<uint32_t>(MachineType::Uint32()); 1949 uint32_t* var_uint32 = module.AddGlobal<uint32_t>(MachineType::Uint32());
1956 float* var_float = module.AddGlobal<float>(MachineType::Float32()); 1950 float* var_float = module.AddGlobal<float>(MachineType::Float32());
1957 double* var_double = module.AddGlobal<double>(MachineType::Float64()); 1951 double* var_double = module.AddGlobal<double>(MachineType::Float64());
1958 1952
1959 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1953 WasmRunner<int32_t> r(&module, MachineType::Int32());
1960 1954
1961 BUILD( 1955 BUILD(
1962 r, 1956 r,
1963 WASM_BLOCK( 1957 WASM_BLOCK(
1964 9,
1965 WASM_STORE_GLOBAL(1, WASM_LOAD_MEM(MachineType::Int8(), WASM_ZERO)), 1958 WASM_STORE_GLOBAL(1, WASM_LOAD_MEM(MachineType::Int8(), WASM_ZERO)),
1966 WASM_STORE_GLOBAL(2, WASM_LOAD_MEM(MachineType::Uint8(), WASM_ZERO)), 1959 WASM_STORE_GLOBAL(2, WASM_LOAD_MEM(MachineType::Uint8(), WASM_ZERO)),
1967 WASM_STORE_GLOBAL(3, WASM_LOAD_MEM(MachineType::Int16(), WASM_ZERO)), 1960 WASM_STORE_GLOBAL(3, WASM_LOAD_MEM(MachineType::Int16(), WASM_ZERO)),
1968 WASM_STORE_GLOBAL(4, WASM_LOAD_MEM(MachineType::Uint16(), WASM_ZERO)), 1961 WASM_STORE_GLOBAL(4, WASM_LOAD_MEM(MachineType::Uint16(), WASM_ZERO)),
1969 WASM_STORE_GLOBAL(5, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)), 1962 WASM_STORE_GLOBAL(5, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
1970 WASM_STORE_GLOBAL(6, WASM_LOAD_MEM(MachineType::Uint32(), WASM_ZERO)), 1963 WASM_STORE_GLOBAL(6, WASM_LOAD_MEM(MachineType::Uint32(), WASM_ZERO)),
1971 WASM_STORE_GLOBAL(7, 1964 WASM_STORE_GLOBAL(7,
1972 WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)), 1965 WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)),
1973 WASM_STORE_GLOBAL(8, 1966 WASM_STORE_GLOBAL(8,
1974 WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)), 1967 WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)),
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 FOR_FLOAT32_INPUTS(i) { 2116 FOR_FLOAT32_INPUTS(i) {
2124 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, r.Call(*i, *j)); } 2117 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, r.Call(*i, *j)); }
2125 } 2118 }
2126 } 2119 }
2127 2120
2128 WASM_EXEC_TEST(Call_Float64Sub) { 2121 WASM_EXEC_TEST(Call_Float64Sub) {
2129 TestingModule module(execution_mode); 2122 TestingModule module(execution_mode);
2130 double* memory = module.AddMemoryElems<double>(16); 2123 double* memory = module.AddMemoryElems<double>(16);
2131 WasmRunner<int32_t> r(&module); 2124 WasmRunner<int32_t> r(&module);
2132 2125
2133 BUILD(r, WASM_BLOCK( 2126 BUILD(r,
2134 2, WASM_STORE_MEM( 2127 WASM_BLOCK(WASM_STORE_MEM(
2135 MachineType::Float64(), WASM_ZERO, 2128 MachineType::Float64(), WASM_ZERO,
2136 WASM_F64_SUB( 2129 WASM_F64_SUB(
2137 WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO), 2130 WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO),
2138 WASM_LOAD_MEM(MachineType::Float64(), WASM_I8(8)))), 2131 WASM_LOAD_MEM(MachineType::Float64(), WASM_I8(8)))),
2139 WASM_I8(107))); 2132 WASM_I8(107)));
2140 2133
2141 FOR_FLOAT64_INPUTS(i) { 2134 FOR_FLOAT64_INPUTS(i) {
2142 FOR_FLOAT64_INPUTS(j) { 2135 FOR_FLOAT64_INPUTS(j) {
2143 module.WriteMemory(&memory[0], *i); 2136 module.WriteMemory(&memory[0], *i);
2144 module.WriteMemory(&memory[1], *j); 2137 module.WriteMemory(&memory[1], *j);
2145 double expected = *i - *j; 2138 double expected = *i - *j;
2146 CHECK_EQ(107, r.Call()); 2139 CHECK_EQ(107, r.Call());
2147 2140
2148 if (expected != expected) { 2141 if (expected != expected) {
2149 CHECK(module.ReadMemory(&memory[0]) != module.ReadMemory(&memory[0])); 2142 CHECK(module.ReadMemory(&memory[0]) != module.ReadMemory(&memory[0]));
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 WASM_GET_LOCAL(local))))); 2254 WASM_GET_LOCAL(local)))));
2262 2255
2263 CHECK_EQ(198, r.Call(0)); 2256 CHECK_EQ(198, r.Call(0));
2264 CHECK_EQ(200, r.Call(1)); 2257 CHECK_EQ(200, r.Call(1));
2265 CHECK_EQ(100, r.Call(-49)); 2258 CHECK_EQ(100, r.Call(-49));
2266 } 2259 }
2267 2260
2268 WASM_EXEC_TEST(CountDown_expr) { 2261 WASM_EXEC_TEST(CountDown_expr) {
2269 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 2262 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
2270 BUILD(r, WASM_LOOP( 2263 BUILD(r, WASM_LOOP(
2271 3, WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)), 2264 WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)),
2272 WASM_BREAKV(1, WASM_GET_LOCAL(0))), 2265 WASM_BREAKV(1, WASM_GET_LOCAL(0))),
2273 WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))), 2266 WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))),
2274 WASM_CONTINUE(0))); 2267 WASM_CONTINUE(0)));
2275 CHECK_EQ(0, r.Call(1)); 2268 CHECK_EQ(0, r.Call(1));
2276 CHECK_EQ(0, r.Call(10)); 2269 CHECK_EQ(0, r.Call(10));
2277 CHECK_EQ(0, r.Call(100)); 2270 CHECK_EQ(0, r.Call(100));
2278 } 2271 }
2279 2272
2280 WASM_EXEC_TEST(ExprBlock2a) { 2273 WASM_EXEC_TEST(ExprBlock2a) {
2281 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 2274 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
2282 BUILD(r, B2(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(1))), WASM_I8(1))); 2275 BUILD(r, B2(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(1))), WASM_I8(1)));
(...skipping 17 matching lines...) Expand all
2300 2293
2301 WASM_EXEC_TEST(ExprBlock2d) { 2294 WASM_EXEC_TEST(ExprBlock2d) {
2302 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 2295 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
2303 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(1), WASM_GET_LOCAL(0)), WASM_I8(2))); 2296 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(1), WASM_GET_LOCAL(0)), WASM_I8(2)));
2304 CHECK_EQ(2, r.Call(0)); 2297 CHECK_EQ(2, r.Call(0));
2305 CHECK_EQ(1, r.Call(1)); 2298 CHECK_EQ(1, r.Call(1));
2306 } 2299 }
2307 2300
2308 WASM_EXEC_TEST(ExprBlock_ManualSwitch) { 2301 WASM_EXEC_TEST(ExprBlock_ManualSwitch) {
2309 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 2302 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
2310 BUILD(r, WASM_BLOCK(6, WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1)), 2303 BUILD(r, WASM_BLOCK(WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1)),
2311 WASM_BRV(1, WASM_I8(11))), 2304 WASM_BRV(1, WASM_I8(11))),
2312 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2)), 2305 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2)),
2313 WASM_BRV(1, WASM_I8(12))), 2306 WASM_BRV(1, WASM_I8(12))),
2314 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3)), 2307 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3)),
2315 WASM_BRV(1, WASM_I8(13))), 2308 WASM_BRV(1, WASM_I8(13))),
2316 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4)), 2309 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4)),
2317 WASM_BRV(1, WASM_I8(14))), 2310 WASM_BRV(1, WASM_I8(14))),
2318 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5)), 2311 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5)),
2319 WASM_BRV(1, WASM_I8(15))), 2312 WASM_BRV(1, WASM_I8(15))),
2320 WASM_I8(99))); 2313 WASM_I8(99)));
2321 CHECK_EQ(99, r.Call(0)); 2314 CHECK_EQ(99, r.Call(0));
2322 CHECK_EQ(11, r.Call(1)); 2315 CHECK_EQ(11, r.Call(1));
2323 CHECK_EQ(12, r.Call(2)); 2316 CHECK_EQ(12, r.Call(2));
2324 CHECK_EQ(13, r.Call(3)); 2317 CHECK_EQ(13, r.Call(3));
2325 CHECK_EQ(14, r.Call(4)); 2318 CHECK_EQ(14, r.Call(4));
2326 CHECK_EQ(15, r.Call(5)); 2319 CHECK_EQ(15, r.Call(5));
2327 CHECK_EQ(99, r.Call(6)); 2320 CHECK_EQ(99, r.Call(6));
2328 } 2321 }
2329 2322
2330 WASM_EXEC_TEST(ExprBlock_ManualSwitch_brif) { 2323 WASM_EXEC_TEST(ExprBlock_ManualSwitch_brif) {
2331 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); 2324 WasmRunner<int32_t> r(execution_mode, MachineType::Int32());
2332 BUILD(r, 2325 BUILD(r, WASM_BLOCK(WASM_BRV_IF(0, WASM_I8(11),
2333 WASM_BLOCK(6, WASM_BRV_IF(0, WASM_I8(11),
2334 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1))), 2326 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1))),
2335 WASM_BRV_IF(0, WASM_I8(12), 2327 WASM_BRV_IF(0, WASM_I8(12),
2336 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2))), 2328 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2))),
2337 WASM_BRV_IF(0, WASM_I8(13), 2329 WASM_BRV_IF(0, WASM_I8(13),
2338 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3))), 2330 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3))),
2339 WASM_BRV_IF(0, WASM_I8(14), 2331 WASM_BRV_IF(0, WASM_I8(14),
2340 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4))), 2332 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4))),
2341 WASM_BRV_IF(0, WASM_I8(15), 2333 WASM_BRV_IF(0, WASM_I8(15),
2342 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5))), 2334 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5))),
2343 WASM_I8(99))); 2335 WASM_I8(99)));
2344 CHECK_EQ(99, r.Call(0)); 2336 CHECK_EQ(99, r.Call(0));
2345 CHECK_EQ(11, r.Call(1)); 2337 CHECK_EQ(11, r.Call(1));
2346 CHECK_EQ(12, r.Call(2)); 2338 CHECK_EQ(12, r.Call(2));
2347 CHECK_EQ(13, r.Call(3)); 2339 CHECK_EQ(13, r.Call(3));
2348 CHECK_EQ(14, r.Call(4)); 2340 CHECK_EQ(14, r.Call(4));
2349 CHECK_EQ(15, r.Call(5)); 2341 CHECK_EQ(15, r.Call(5));
2350 CHECK_EQ(99, r.Call(6)); 2342 CHECK_EQ(99, r.Call(6));
2351 } 2343 }
2352 2344
2353 WASM_EXEC_TEST(nested_ifs) { 2345 WASM_EXEC_TEST(nested_ifs) {
(...skipping 18 matching lines...) Expand all
2372 WASM_BRV(1, WASM_I8(14))))); 2364 WASM_BRV(1, WASM_I8(14)))));
2373 2365
2374 CHECK_EQ(11, r.Call(1)); 2366 CHECK_EQ(11, r.Call(1));
2375 CHECK_EQ(14, r.Call(0)); 2367 CHECK_EQ(14, r.Call(0));
2376 } 2368 }
2377 2369
2378 WASM_EXEC_TEST(ExprBlock_nested_ifs) { 2370 WASM_EXEC_TEST(ExprBlock_nested_ifs) {
2379 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(), 2371 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
2380 MachineType::Int32()); 2372 MachineType::Int32());
2381 2373
2382 BUILD(r, WASM_BLOCK( 2374 BUILD(r, WASM_BLOCK(WASM_IF_ELSE(
2383 1, WASM_IF_ELSE( 2375 WASM_GET_LOCAL(0),
2384 WASM_GET_LOCAL(0), 2376 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(11)),
2385 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(11)), 2377 WASM_BRV(1, WASM_I8(12))),
2386 WASM_BRV(1, WASM_I8(12))), 2378 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(13)),
2387 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(13)), 2379 WASM_BRV(1, WASM_I8(14))))));
2388 WASM_BRV(1, WASM_I8(14))))));
2389 2380
2390 CHECK_EQ(11, r.Call(1, 1)); 2381 CHECK_EQ(11, r.Call(1, 1));
2391 CHECK_EQ(12, r.Call(1, 0)); 2382 CHECK_EQ(12, r.Call(1, 0));
2392 CHECK_EQ(13, r.Call(0, 1)); 2383 CHECK_EQ(13, r.Call(0, 1));
2393 CHECK_EQ(14, r.Call(0, 0)); 2384 CHECK_EQ(14, r.Call(0, 0));
2394 } 2385 }
2395 2386
2396 WASM_EXEC_TEST(ExprLoop_nested_ifs) { 2387 WASM_EXEC_TEST(ExprLoop_nested_ifs) {
2397 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(), 2388 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
2398 MachineType::Int32()); 2389 MachineType::Int32());
2399 2390
2400 BUILD(r, WASM_LOOP( 2391 BUILD(r, WASM_LOOP(WASM_IF_ELSE(
2401 1, WASM_IF_ELSE( 2392 WASM_GET_LOCAL(0),
2402 WASM_GET_LOCAL(0), 2393 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(1, WASM_I8(11)),
2403 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(1, WASM_I8(11)), 2394 WASM_BRV(3, WASM_I8(12))),
2404 WASM_BRV(3, WASM_I8(12))), 2395 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(1, WASM_I8(13)),
2405 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(1, WASM_I8(13)), 2396 WASM_BRV(3, WASM_I8(14))))));
2406 WASM_BRV(3, WASM_I8(14))))));
2407 2397
2408 CHECK_EQ(11, r.Call(1, 1)); 2398 CHECK_EQ(11, r.Call(1, 1));
2409 CHECK_EQ(12, r.Call(1, 0)); 2399 CHECK_EQ(12, r.Call(1, 0));
2410 CHECK_EQ(13, r.Call(0, 1)); 2400 CHECK_EQ(13, r.Call(0, 1));
2411 CHECK_EQ(14, r.Call(0, 0)); 2401 CHECK_EQ(14, r.Call(0, 0));
2412 } 2402 }
2413 2403
2414 WASM_EXEC_TEST(SimpleCallIndirect) { 2404 WASM_EXEC_TEST(SimpleCallIndirect) {
2415 TestSignatures sigs; 2405 TestSignatures sigs;
2416 TestingModule module(execution_mode); 2406 TestingModule module(execution_mode);
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
2860 MachineType::Int32()); 2850 MachineType::Int32());
2861 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO); 2851 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO);
2862 const int32_t kMin = std::numeric_limits<int32_t>::min(); 2852 const int32_t kMin = std::numeric_limits<int32_t>::min();
2863 CHECK_EQ(0, r.Call(133, 100)); 2853 CHECK_EQ(0, r.Call(133, 100));
2864 CHECK_EQ(0, r.Call(kMin, -1)); 2854 CHECK_EQ(0, r.Call(kMin, -1));
2865 CHECK_EQ(0, r.Call(0, 1)); 2855 CHECK_EQ(0, r.Call(0, 1));
2866 CHECK_TRAP(r.Call(100, 0)); 2856 CHECK_TRAP(r.Call(100, 0));
2867 CHECK_TRAP(r.Call(-1001, 0)); 2857 CHECK_TRAP(r.Call(-1001, 0));
2868 CHECK_TRAP(r.Call(kMin, 0)); 2858 CHECK_TRAP(r.Call(kMin, 0));
2869 } 2859 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-macro-gen.h ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698