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

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

Issue 2595733003: [wasm] Remove non-standard kExprI8Const bytecode (Closed)
Patch Set: Remove regression test Created 3 years, 11 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
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/bits.h" 9 #include "src/base/bits.h"
10 #include "src/wasm/wasm-macro-gen.h" 10 #include "src/wasm/wasm-macro-gen.h"
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 REQUIRE(I64LoadStore); 1181 REQUIRE(I64LoadStore);
1182 REQUIRE(DepthFirst); 1182 REQUIRE(DepthFirst);
1183 byte loads[] = {kExprI64LoadMem8S, kExprI64LoadMem16S, kExprI64LoadMem32S, 1183 byte loads[] = {kExprI64LoadMem8S, kExprI64LoadMem16S, kExprI64LoadMem32S,
1184 kExprI64LoadMem}; 1184 kExprI64LoadMem};
1185 1185
1186 for (size_t m = 0; m < arraysize(loads); m++) { 1186 for (size_t m = 0; m < arraysize(loads); m++) {
1187 WasmRunner<int64_t> r(execution_mode); 1187 WasmRunner<int64_t> r(execution_mode);
1188 byte* memory = r.module().AddMemoryElems<byte>(16); 1188 byte* memory = r.module().AddMemoryElems<byte>(16);
1189 1189
1190 byte code[] = { 1190 byte code[] = {
1191 kExprI8Const, 8, // -- 1191 kExprI32Const, 8, // --
1192 kExprI8Const, 0, // -- 1192 kExprI32Const, 0, // --
1193 loads[m], // -- 1193 loads[m], // --
1194 ZERO_ALIGNMENT, // -- 1194 ZERO_ALIGNMENT, // --
1195 ZERO_OFFSET, // -- 1195 ZERO_OFFSET, // --
1196 kExprI64StoreMem, // -- 1196 kExprI64StoreMem, // --
1197 ZERO_ALIGNMENT, // -- 1197 ZERO_ALIGNMENT, // --
1198 ZERO_OFFSET, // -- 1198 ZERO_OFFSET, // --
1199 kExprI8Const, 0, // -- 1199 kExprI32Const, 0, // --
1200 loads[m], // -- 1200 loads[m], // --
1201 ZERO_ALIGNMENT, // -- 1201 ZERO_ALIGNMENT, // --
1202 ZERO_OFFSET, // -- 1202 ZERO_OFFSET, // --
1203 }; 1203 };
1204 1204
1205 r.Build(code, code + arraysize(code)); 1205 r.Build(code, code + arraysize(code));
1206 1206
1207 // Try a bunch of different negative values. 1207 // Try a bunch of different negative values.
1208 for (int i = -1; i >= -128; i -= 11) { 1208 for (int i = -1; i >= -128; i -= 11) {
1209 int size = 1 << m; 1209 int size = 1 << m;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 CHECK_EQ(expected, r.module().ReadMemory<int64_t>(&memory[0])); 1309 CHECK_EQ(expected, r.module().ReadMemory<int64_t>(&memory[0]));
1310 } 1310 }
1311 } 1311 }
1312 1312
1313 WASM_EXEC_TEST(LoadMemI64) { 1313 WASM_EXEC_TEST(LoadMemI64) {
1314 REQUIRE(I64LoadStore); 1314 REQUIRE(I64LoadStore);
1315 WasmRunner<int64_t> r(execution_mode); 1315 WasmRunner<int64_t> r(execution_mode);
1316 int64_t* memory = r.module().AddMemoryElems<int64_t>(8); 1316 int64_t* memory = r.module().AddMemoryElems<int64_t>(8);
1317 r.module().RandomizeMemory(1111); 1317 r.module().RandomizeMemory(1111);
1318 1318
1319 BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_I8(0))); 1319 BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_ZERO));
1320 1320
1321 r.module().WriteMemory<int64_t>(&memory[0], 0x1abbccdd00112233LL); 1321 r.module().WriteMemory<int64_t>(&memory[0], 0x1abbccdd00112233LL);
1322 CHECK_EQ(0x1abbccdd00112233LL, r.Call()); 1322 CHECK_EQ(0x1abbccdd00112233LL, r.Call());
1323 1323
1324 r.module().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL); 1324 r.module().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL);
1325 CHECK_EQ(0x33aabbccdd001122LL, r.Call()); 1325 CHECK_EQ(0x33aabbccdd001122LL, r.Call());
1326 1326
1327 r.module().WriteMemory<int64_t>(&memory[0], 77777777); 1327 r.module().WriteMemory<int64_t>(&memory[0], 77777777);
1328 CHECK_EQ(77777777, r.Call()); 1328 CHECK_EQ(77777777, r.Call());
1329 } 1329 }
1330 1330
1331 WASM_EXEC_TEST(LoadMemI64_alignment) { 1331 WASM_EXEC_TEST(LoadMemI64_alignment) {
1332 REQUIRE(I64LoadStore); 1332 REQUIRE(I64LoadStore);
1333 for (byte alignment = 0; alignment <= 3; alignment++) { 1333 for (byte alignment = 0; alignment <= 3; alignment++) {
1334 WasmRunner<int64_t> r(execution_mode); 1334 WasmRunner<int64_t> r(execution_mode);
1335 int64_t* memory = r.module().AddMemoryElems<int64_t>(8); 1335 int64_t* memory = r.module().AddMemoryElems<int64_t>(8);
1336 r.module().RandomizeMemory(1111); 1336 r.module().RandomizeMemory(1111);
1337 1337
1338 BUILD(r, 1338 BUILD(r,
1339 WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_I8(0), alignment)); 1339 WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, alignment));
1340 1340
1341 r.module().WriteMemory<int64_t>(&memory[0], 0x1abbccdd00112233LL); 1341 r.module().WriteMemory<int64_t>(&memory[0], 0x1abbccdd00112233LL);
1342 CHECK_EQ(0x1abbccdd00112233LL, r.Call()); 1342 CHECK_EQ(0x1abbccdd00112233LL, r.Call());
1343 1343
1344 r.module().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL); 1344 r.module().WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL);
1345 CHECK_EQ(0x33aabbccdd001122LL, r.Call()); 1345 CHECK_EQ(0x33aabbccdd001122LL, r.Call());
1346 1346
1347 r.module().WriteMemory<int64_t>(&memory[0], 77777777); 1347 r.module().WriteMemory<int64_t>(&memory[0], 77777777);
1348 CHECK_EQ(77777777, r.Call()); 1348 CHECK_EQ(77777777, r.Call());
1349 } 1349 }
1350 } 1350 }
1351 1351
1352 WASM_EXEC_TEST(MemI64_Sum) { 1352 WASM_EXEC_TEST(MemI64_Sum) {
1353 REQUIRE(I64LoadStore); 1353 REQUIRE(I64LoadStore);
1354 REQUIRE(I64Add); 1354 REQUIRE(I64Add);
1355 REQUIRE(I64Sub); 1355 REQUIRE(I64Sub);
1356 REQUIRE(I64Phi); 1356 REQUIRE(I64Phi);
1357 const int kNumElems = 20; 1357 const int kNumElems = 20;
1358 WasmRunner<uint64_t, int32_t> r(execution_mode); 1358 WasmRunner<uint64_t, int32_t> r(execution_mode);
1359 uint64_t* memory = r.module().AddMemoryElems<uint64_t>(kNumElems); 1359 uint64_t* memory = r.module().AddMemoryElems<uint64_t>(kNumElems);
1360 const byte kSum = r.AllocateLocal(kWasmI64); 1360 const byte kSum = r.AllocateLocal(kWasmI64);
1361 1361
1362 BUILD( 1362 BUILD(r, WASM_WHILE(
1363 r, 1363 WASM_GET_LOCAL(0),
1364 WASM_WHILE( 1364 WASM_BLOCK(
1365 WASM_GET_LOCAL(0), 1365 WASM_SET_LOCAL(
1366 WASM_BLOCK( 1366 kSum, WASM_I64_ADD(WASM_GET_LOCAL(kSum),
1367 WASM_SET_LOCAL(kSum,
1368 WASM_I64_ADD(WASM_GET_LOCAL(kSum),
1369 WASM_LOAD_MEM(MachineType::Int64(), 1367 WASM_LOAD_MEM(MachineType::Int64(),
1370 WASM_GET_LOCAL(0)))), 1368 WASM_GET_LOCAL(0)))),
1371 WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(8))))), 1369 WASM_SET_LOCAL(
1372 WASM_GET_LOCAL(1)); 1370 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I32V_1(8))))),
1371 WASM_GET_LOCAL(1));
1373 1372
1374 // Run 4 trials. 1373 // Run 4 trials.
1375 for (int i = 0; i < 3; i++) { 1374 for (int i = 0; i < 3; i++) {
1376 r.module().RandomizeMemory(i * 33); 1375 r.module().RandomizeMemory(i * 33);
1377 uint64_t expected = 0; 1376 uint64_t expected = 0;
1378 for (size_t j = kNumElems - 1; j > 0; j--) { 1377 for (size_t j = kNumElems - 1; j > 0; j--) {
1379 expected += r.module().ReadMemory(&memory[j]); 1378 expected += r.module().ReadMemory(&memory[j]);
1380 } 1379 }
1381 uint64_t result = r.Call(8 * (kNumElems - 1)); 1380 uint64_t result = r.Call(8 * (kNumElems - 1));
1382 CHECK_EQ(expected, result); 1381 CHECK_EQ(expected, result);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 r.module().AddSignature(sig); 1502 r.module().AddSignature(sig);
1504 r.module().AddSignature(sig); 1503 r.module().AddSignature(sig);
1505 r.module().AddIndirectFunctionTable(nullptr, 0); 1504 r.module().AddIndirectFunctionTable(nullptr, 0);
1506 1505
1507 WasmFunctionCompiler& t = r.NewFunction(sig); 1506 WasmFunctionCompiler& t = r.NewFunction(sig);
1508 1507
1509 std::vector<byte> code; 1508 std::vector<byte> code;
1510 for (byte p = 0; p < num_params; p++) { 1509 for (byte p = 0; p < num_params; p++) {
1511 ADD_CODE(code, kExprGetLocal, p); 1510 ADD_CODE(code, kExprGetLocal, p);
1512 } 1511 }
1513 ADD_CODE(code, kExprI8Const, 0); 1512 ADD_CODE(code, kExprI32Const, 0);
1514 ADD_CODE(code, kExprCallIndirect, 1, TABLE_ZERO); 1513 ADD_CODE(code, kExprCallIndirect, 1, TABLE_ZERO);
1515 1514
1516 t.Build(&code[0], &code[0] + code.size()); 1515 t.Build(&code[0], &code[0] + code.size());
1517 } 1516 }
1518 } 1517 }
1519 1518
1520 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kWasmI64); } 1519 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kWasmI64); }
1521 1520
1522 static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) { 1521 static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
1523 const int kExpected = 6333; 1522 const int kExpected = 6333;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 // Build the calling function. 1554 // Build the calling function.
1556 // ========================================================================= 1555 // =========================================================================
1557 std::vector<byte> code; 1556 std::vector<byte> code;
1558 1557
1559 // Load the offset for the store. 1558 // Load the offset for the store.
1560 ADD_CODE(code, WASM_ZERO); 1559 ADD_CODE(code, WASM_ZERO);
1561 1560
1562 // Load the arguments. 1561 // Load the arguments.
1563 for (int i = 0; i < num_params; i++) { 1562 for (int i = 0; i < num_params; i++) {
1564 int offset = (i + 1) * kElemSize; 1563 int offset = (i + 1) * kElemSize;
1565 ADD_CODE(code, WASM_LOAD_MEM(memtypes[i], WASM_I8(offset))); 1564 ADD_CODE(code, WASM_LOAD_MEM(memtypes[i], WASM_I32V_2(offset)));
1566 } 1565 }
1567 1566
1568 // Call the selector function. 1567 // Call the selector function.
1569 ADD_CODE(code, WASM_CALL_FUNCTION0(t.function_index())); 1568 ADD_CODE(code, WASM_CALL_FUNCTION0(t.function_index()));
1570 1569
1571 // Store the result in memory. 1570 // Store the result in memory.
1572 ADD_CODE(code, 1571 ADD_CODE(code,
1573 static_cast<byte>(WasmOpcodes::LoadStoreOpcodeOf(result, true)), 1572 static_cast<byte>(WasmOpcodes::LoadStoreOpcodeOf(result, true)),
1574 ZERO_ALIGNMENT, ZERO_OFFSET); 1573 ZERO_ALIGNMENT, ZERO_OFFSET);
1575 1574
(...skipping 15 matching lines...) Expand all
1591 CHECK_EQ(expected, result); 1590 CHECK_EQ(expected, result);
1592 } 1591 }
1593 } 1592 }
1594 } 1593 }
1595 } 1594 }
1596 1595
1597 WASM_EXEC_TEST(MixedCall_i64_0) { Run_WasmMixedCall_N(execution_mode, 0); } 1596 WASM_EXEC_TEST(MixedCall_i64_0) { Run_WasmMixedCall_N(execution_mode, 0); }
1598 WASM_EXEC_TEST(MixedCall_i64_1) { Run_WasmMixedCall_N(execution_mode, 1); } 1597 WASM_EXEC_TEST(MixedCall_i64_1) { Run_WasmMixedCall_N(execution_mode, 1); }
1599 WASM_EXEC_TEST(MixedCall_i64_2) { Run_WasmMixedCall_N(execution_mode, 2); } 1598 WASM_EXEC_TEST(MixedCall_i64_2) { Run_WasmMixedCall_N(execution_mode, 2); }
1600 WASM_EXEC_TEST(MixedCall_i64_3) { Run_WasmMixedCall_N(execution_mode, 3); } 1599 WASM_EXEC_TEST(MixedCall_i64_3) { Run_WasmMixedCall_N(execution_mode, 3); }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698