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

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

Issue 2034093002: Implement WASM big-endian support (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Small fixes. Rebase to master Created 4 years, 6 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.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('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/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 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 REQUIRE(I64ReinterpretF64); 1238 REQUIRE(I64ReinterpretF64);
1239 TestingModule module(execution_mode); 1239 TestingModule module(execution_mode);
1240 int64_t* memory = module.AddMemoryElems<int64_t>(8); 1240 int64_t* memory = module.AddMemoryElems<int64_t>(8);
1241 WasmRunner<int64_t> r(&module); 1241 WasmRunner<int64_t> r(&module);
1242 1242
1243 BUILD(r, WASM_I64_REINTERPRET_F64( 1243 BUILD(r, WASM_I64_REINTERPRET_F64(
1244 WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO))); 1244 WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)));
1245 1245
1246 FOR_INT32_INPUTS(i) { 1246 FOR_INT32_INPUTS(i) {
1247 int64_t expected = static_cast<int64_t>(*i) * 0x300010001; 1247 int64_t expected = static_cast<int64_t>(*i) * 0x300010001;
1248 memory[0] = expected; 1248 module.WriteMemory(&memory[0], expected);
1249 CHECK_EQ(expected, r.Call()); 1249 CHECK_EQ(expected, r.Call());
1250 } 1250 }
1251 } 1251 }
1252 1252
1253 WASM_EXEC_TEST(F64ReinterpretI64) { 1253 WASM_EXEC_TEST(F64ReinterpretI64) {
1254 REQUIRE(F64ReinterpretI64); 1254 REQUIRE(F64ReinterpretI64);
1255 TestingModule module(execution_mode); 1255 TestingModule module(execution_mode);
1256 int64_t* memory = module.AddMemoryElems<int64_t>(8); 1256 int64_t* memory = module.AddMemoryElems<int64_t>(8);
1257 WasmRunner<int64_t> r(&module, MachineType::Int64()); 1257 WasmRunner<int64_t> r(&module, MachineType::Int64());
1258 1258
1259 BUILD(r, WASM_BLOCK( 1259 BUILD(r, WASM_BLOCK(
1260 2, WASM_STORE_MEM(MachineType::Float64(), WASM_ZERO, 1260 2, WASM_STORE_MEM(MachineType::Float64(), WASM_ZERO,
1261 WASM_F64_REINTERPRET_I64(WASM_GET_LOCAL(0))), 1261 WASM_F64_REINTERPRET_I64(WASM_GET_LOCAL(0))),
1262 WASM_GET_LOCAL(0))); 1262 WASM_GET_LOCAL(0)));
1263 1263
1264 FOR_INT32_INPUTS(i) { 1264 FOR_INT32_INPUTS(i) {
1265 int64_t expected = static_cast<int64_t>(*i) * 0x300010001; 1265 int64_t expected = static_cast<int64_t>(*i) * 0x300010001;
1266 CHECK_EQ(expected, r.Call(expected)); 1266 CHECK_EQ(expected, r.Call(expected));
1267 CHECK_EQ(expected, memory[0]); 1267 CHECK_EQ(expected, module.ReadMemory<int64_t>(&memory[0]));
1268 } 1268 }
1269 } 1269 }
1270 1270
1271 WASM_EXEC_TEST(LoadMemI64) { 1271 WASM_EXEC_TEST(LoadMemI64) {
1272 REQUIRE(I64LoadStore); 1272 REQUIRE(I64LoadStore);
1273 TestingModule module(execution_mode); 1273 TestingModule module(execution_mode);
1274 int64_t* memory = module.AddMemoryElems<int64_t>(8); 1274 int64_t* memory = module.AddMemoryElems<int64_t>(8);
1275 module.RandomizeMemory(1111); 1275 module.RandomizeMemory(1111);
1276 WasmRunner<int64_t> r(&module); 1276 WasmRunner<int64_t> r(&module);
1277 1277
1278 BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_I8(0))); 1278 BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_I8(0)));
1279 1279
1280 memory[0] = 0xaabbccdd00112233LL; 1280 module.WriteMemory<int64_t>(&memory[0], 0xaabbccdd00112233LL);
1281 CHECK_EQ(0xaabbccdd00112233LL, r.Call()); 1281 CHECK_EQ(0xaabbccdd00112233LL, r.Call());
1282 1282
1283 memory[0] = 0x33aabbccdd001122LL; 1283 module.WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL);
1284 CHECK_EQ(0x33aabbccdd001122LL, r.Call()); 1284 CHECK_EQ(0x33aabbccdd001122LL, r.Call());
1285 1285
1286 memory[0] = 77777777; 1286 module.WriteMemory<int64_t>(&memory[0], 77777777);
1287 CHECK_EQ(77777777, r.Call()); 1287 CHECK_EQ(77777777, r.Call());
1288 } 1288 }
1289 1289
1290 WASM_EXEC_TEST(LoadMemI64_alignment) { 1290 WASM_EXEC_TEST(LoadMemI64_alignment) {
1291 REQUIRE(I64LoadStore); 1291 REQUIRE(I64LoadStore);
1292 TestingModule module(execution_mode); 1292 TestingModule module(execution_mode);
1293 int64_t* memory = module.AddMemoryElems<int64_t>(8); 1293 int64_t* memory = module.AddMemoryElems<int64_t>(8);
1294 for (byte alignment = 0; alignment <= 3; alignment++) { 1294 for (byte alignment = 0; alignment <= 3; alignment++) {
1295 module.RandomizeMemory(1111); 1295 module.RandomizeMemory(1111);
1296 WasmRunner<int64_t> r(&module); 1296 WasmRunner<int64_t> r(&module);
1297 1297
1298 BUILD(r, 1298 BUILD(r,
1299 WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_I8(0), alignment)); 1299 WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_I8(0), alignment));
1300 1300
1301 memory[0] = 0xaabbccdd00112233LL; 1301 module.WriteMemory<int64_t>(&memory[0], 0xaabbccdd00112233LL);
1302 CHECK_EQ(0xaabbccdd00112233LL, r.Call()); 1302 CHECK_EQ(0xaabbccdd00112233LL, r.Call());
1303 1303
1304 memory[0] = 0x33aabbccdd001122LL; 1304 module.WriteMemory<int64_t>(&memory[0], 0x33aabbccdd001122LL);
1305 CHECK_EQ(0x33aabbccdd001122LL, r.Call()); 1305 CHECK_EQ(0x33aabbccdd001122LL, r.Call());
1306 1306
1307 memory[0] = 77777777; 1307 module.WriteMemory<int64_t>(&memory[0], 77777777);
1308 CHECK_EQ(77777777, r.Call()); 1308 CHECK_EQ(77777777, r.Call());
1309 } 1309 }
1310 } 1310 }
1311 1311
1312 WASM_EXEC_TEST(MemI64_Sum) { 1312 WASM_EXEC_TEST(MemI64_Sum) {
1313 REQUIRE(I64LoadStore); 1313 REQUIRE(I64LoadStore);
1314 REQUIRE(I64Add); 1314 REQUIRE(I64Add);
1315 REQUIRE(I64Sub); 1315 REQUIRE(I64Sub);
1316 REQUIRE(I64Phi); 1316 REQUIRE(I64Phi);
1317 const int kNumElems = 20; 1317 const int kNumElems = 20;
(...skipping 13 matching lines...) Expand all
1331 WASM_GET_LOCAL(0)))), 1331 WASM_GET_LOCAL(0)))),
1332 WASM_SET_LOCAL( 1332 WASM_SET_LOCAL(
1333 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(8))))), 1333 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(8))))),
1334 WASM_GET_LOCAL(1))); 1334 WASM_GET_LOCAL(1)));
1335 1335
1336 // Run 4 trials. 1336 // Run 4 trials.
1337 for (int i = 0; i < 3; i++) { 1337 for (int i = 0; i < 3; i++) {
1338 module.RandomizeMemory(i * 33); 1338 module.RandomizeMemory(i * 33);
1339 uint64_t expected = 0; 1339 uint64_t expected = 0;
1340 for (size_t j = kNumElems - 1; j > 0; j--) { 1340 for (size_t j = kNumElems - 1; j > 0; j--) {
1341 expected += memory[j]; 1341 expected += module.ReadMemory(&memory[j]);
1342 } 1342 }
1343 uint64_t result = r.Call(8 * (kNumElems - 1)); 1343 uint64_t result = r.Call(8 * (kNumElems - 1));
1344 CHECK_EQ(expected, result); 1344 CHECK_EQ(expected, result);
1345 } 1345 }
1346 } 1346 }
1347 1347
1348 WASM_EXEC_TEST(StoreMemI64_alignment) { 1348 WASM_EXEC_TEST(StoreMemI64_alignment) {
1349 TestingModule module(execution_mode); 1349 TestingModule module(execution_mode);
1350 int64_t* memory = module.AddMemoryElems<int64_t>(4); 1350 int64_t* memory = module.AddMemoryElems<int64_t>(4);
1351 const int64_t kWritten = 0x12345678abcd0011ll; 1351 const int64_t kWritten = 0x12345678abcd0011ll;
1352 1352
1353 for (byte i = 0; i <= 3; i++) { 1353 for (byte i = 0; i <= 3; i++) {
1354 WasmRunner<int64_t> r(&module, MachineType::Int64()); 1354 WasmRunner<int64_t> r(&module, MachineType::Int64());
1355 BUILD(r, WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, i, 1355 BUILD(r, WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, i,
1356 WASM_GET_LOCAL(0))); 1356 WASM_GET_LOCAL(0)));
1357 module.RandomizeMemory(1111); 1357 module.RandomizeMemory(1111);
1358 memory[0] = 0; 1358 module.WriteMemory<int64_t>(&memory[0], 0);
1359 1359
1360 CHECK_EQ(kWritten, r.Call(kWritten)); 1360 CHECK_EQ(kWritten, r.Call(kWritten));
1361 CHECK_EQ(kWritten, memory[0]); 1361 CHECK_EQ(kWritten, module.ReadMemory(&memory[0]));
1362 } 1362 }
1363 } 1363 }
1364 1364
1365 WASM_EXEC_TEST(I64Global) { 1365 WASM_EXEC_TEST(I64Global) {
1366 REQUIRE(I64LoadStore); 1366 REQUIRE(I64LoadStore);
1367 REQUIRE(I64SConvertI32); 1367 REQUIRE(I64SConvertI32);
1368 REQUIRE(I64And); 1368 REQUIRE(I64And);
1369 REQUIRE(DepthFirst); 1369 REQUIRE(DepthFirst);
1370 TestingModule module(execution_mode); 1370 TestingModule module(execution_mode);
1371 int64_t* global = module.AddGlobal<int64_t>(MachineType::Int64()); 1371 int64_t* global = module.AddGlobal<int64_t>(MachineType::Int64());
1372 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1372 WasmRunner<int32_t> r(&module, MachineType::Int32());
1373 // global = global + p0 1373 // global = global + p0
1374 BUILD(r, B2(WASM_STORE_GLOBAL( 1374 BUILD(r, B2(WASM_STORE_GLOBAL(
1375 0, WASM_I64_AND(WASM_LOAD_GLOBAL(0), 1375 0, WASM_I64_AND(WASM_LOAD_GLOBAL(0),
1376 WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0)))), 1376 WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0)))),
1377 WASM_ZERO)); 1377 WASM_ZERO));
1378 1378
1379 *global = 0xFFFFFFFFFFFFFFFFLL; 1379 module.WriteMemory<int64_t>(global, 0xFFFFFFFFFFFFFFFFLL);
1380 for (int i = 9; i < 444444; i += 111111) { 1380 for (int i = 9; i < 444444; i += 111111) {
1381 int64_t expected = *global & i; 1381 int64_t expected = *global & i;
1382 r.Call(i); 1382 r.Call(i);
1383 CHECK_EQ(expected, *global); 1383 CHECK_EQ(expected, *global);
1384 } 1384 }
1385 } 1385 }
1386 1386
1387 WASM_EXEC_TEST(I64Eqz) { 1387 WASM_EXEC_TEST(I64Eqz) {
1388 REQUIRE(I64Eq); 1388 REQUIRE(I64Eq);
1389 1389
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 CHECK_EQ(expected, result); 1566 CHECK_EQ(expected, result);
1567 } 1567 }
1568 } 1568 }
1569 } 1569 }
1570 } 1570 }
1571 1571
1572 WASM_EXEC_TEST(MixedCall_i64_0) { Run_WasmMixedCall_N(execution_mode, 0); } 1572 WASM_EXEC_TEST(MixedCall_i64_0) { Run_WasmMixedCall_N(execution_mode, 0); }
1573 WASM_EXEC_TEST(MixedCall_i64_1) { Run_WasmMixedCall_N(execution_mode, 1); } 1573 WASM_EXEC_TEST(MixedCall_i64_1) { Run_WasmMixedCall_N(execution_mode, 1); }
1574 WASM_EXEC_TEST(MixedCall_i64_2) { Run_WasmMixedCall_N(execution_mode, 2); } 1574 WASM_EXEC_TEST(MixedCall_i64_2) { Run_WasmMixedCall_N(execution_mode, 2); }
1575 WASM_EXEC_TEST(MixedCall_i64_3) { Run_WasmMixedCall_N(execution_mode, 3); } 1575 WASM_EXEC_TEST(MixedCall_i64_3) { Run_WasmMixedCall_N(execution_mode, 3); }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698