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/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 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 memory[0] = 0xaabbccdd00112233LL; | 1240 memory[0] = 0xaabbccdd00112233LL; |
1241 CHECK_EQ(0xaabbccdd00112233LL, r.Call()); | 1241 CHECK_EQ(0xaabbccdd00112233LL, r.Call()); |
1242 | 1242 |
1243 memory[0] = 0x33aabbccdd001122LL; | 1243 memory[0] = 0x33aabbccdd001122LL; |
1244 CHECK_EQ(0x33aabbccdd001122LL, r.Call()); | 1244 CHECK_EQ(0x33aabbccdd001122LL, r.Call()); |
1245 | 1245 |
1246 memory[0] = 77777777; | 1246 memory[0] = 77777777; |
1247 CHECK_EQ(77777777, r.Call()); | 1247 CHECK_EQ(77777777, r.Call()); |
1248 } | 1248 } |
1249 | 1249 |
1250 WASM_EXEC_TEST(MemI64_Sum) { | 1250 WASM_EXEC_TEST(Run_Wasm_LoadMemI64_alignment) { |
| 1251 REQUIRE(I64LoadStore); |
| 1252 TestingModule module; |
| 1253 int64_t* memory = module.AddMemoryElems<int64_t>(8); |
| 1254 for (byte alignment = 0; alignment <= 3; alignment++) { |
| 1255 module.RandomizeMemory(1111); |
| 1256 WasmRunner<int64_t> r(&module); |
| 1257 |
| 1258 BUILD(r, |
| 1259 WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_I8(0), alignment)); |
| 1260 |
| 1261 memory[0] = 0xaabbccdd00112233LL; |
| 1262 CHECK_EQ(0xaabbccdd00112233LL, r.Call()); |
| 1263 |
| 1264 memory[0] = 0x33aabbccdd001122LL; |
| 1265 CHECK_EQ(0x33aabbccdd001122LL, r.Call()); |
| 1266 |
| 1267 memory[0] = 77777777; |
| 1268 CHECK_EQ(77777777, r.Call()); |
| 1269 } |
| 1270 } |
| 1271 |
| 1272 WASM_EXEC_TEST(Run_Wasm_MemI64_Sum) { |
1251 REQUIRE(I64LoadStore); | 1273 REQUIRE(I64LoadStore); |
1252 REQUIRE(I64Add); | 1274 REQUIRE(I64Add); |
1253 REQUIRE(I64Sub); | 1275 REQUIRE(I64Sub); |
1254 REQUIRE(I64Phi); | 1276 REQUIRE(I64Phi); |
1255 const int kNumElems = 20; | 1277 const int kNumElems = 20; |
1256 TestingModule module; | 1278 TestingModule module; |
1257 uint64_t* memory = module.AddMemoryElems<uint64_t>(kNumElems); | 1279 uint64_t* memory = module.AddMemoryElems<uint64_t>(kNumElems); |
1258 WasmRunner<uint64_t> r(&module, MachineType::Int32()); | 1280 WasmRunner<uint64_t> r(&module, MachineType::Int32()); |
1259 const byte kSum = r.AllocateLocal(kAstI64); | 1281 const byte kSum = r.AllocateLocal(kAstI64); |
1260 | 1282 |
(...skipping 15 matching lines...) Expand all Loading... |
1276 module.RandomizeMemory(i * 33); | 1298 module.RandomizeMemory(i * 33); |
1277 uint64_t expected = 0; | 1299 uint64_t expected = 0; |
1278 for (size_t j = kNumElems - 1; j > 0; j--) { | 1300 for (size_t j = kNumElems - 1; j > 0; j--) { |
1279 expected += memory[j]; | 1301 expected += memory[j]; |
1280 } | 1302 } |
1281 uint64_t result = r.Call(8 * (kNumElems - 1)); | 1303 uint64_t result = r.Call(8 * (kNumElems - 1)); |
1282 CHECK_EQ(expected, result); | 1304 CHECK_EQ(expected, result); |
1283 } | 1305 } |
1284 } | 1306 } |
1285 | 1307 |
1286 WASM_EXEC_TEST(I64Global) { | 1308 WASM_EXEC_TEST(Run_Wasm_StoreMemI64_alignment) { |
| 1309 TestingModule module; |
| 1310 int64_t* memory = module.AddMemoryElems<int64_t>(4); |
| 1311 const int64_t kWritten = 0x12345678abcd0011ll; |
| 1312 |
| 1313 for (byte i = 0; i <= 3; i++) { |
| 1314 WasmRunner<int64_t> r(&module, MachineType::Int64()); |
| 1315 BUILD(r, WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, i, |
| 1316 WASM_GET_LOCAL(0))); |
| 1317 module.RandomizeMemory(1111); |
| 1318 memory[0] = 0; |
| 1319 |
| 1320 CHECK_EQ(kWritten, r.Call(kWritten)); |
| 1321 CHECK_EQ(kWritten, memory[0]); |
| 1322 } |
| 1323 } |
| 1324 |
| 1325 WASM_EXEC_TEST(Run_Wasm_I64Global) { |
1287 REQUIRE(I64LoadStore); | 1326 REQUIRE(I64LoadStore); |
1288 REQUIRE(I64SConvertI32); | 1327 REQUIRE(I64SConvertI32); |
1289 REQUIRE(I64And); | 1328 REQUIRE(I64And); |
1290 REQUIRE(DepthFirst); | 1329 REQUIRE(DepthFirst); |
1291 TestingModule module; | 1330 TestingModule module; |
1292 int64_t* global = module.AddGlobal<int64_t>(MachineType::Int64()); | 1331 int64_t* global = module.AddGlobal<int64_t>(MachineType::Int64()); |
1293 WasmRunner<int32_t> r(&module, MachineType::Int32()); | 1332 WasmRunner<int32_t> r(&module, MachineType::Int32()); |
1294 // global = global + p0 | 1333 // global = global + p0 |
1295 BUILD(r, B2(WASM_STORE_GLOBAL( | 1334 BUILD(r, B2(WASM_STORE_GLOBAL( |
1296 0, WASM_I64_AND(WASM_LOAD_GLOBAL(0), | 1335 0, WASM_I64_AND(WASM_LOAD_GLOBAL(0), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 1374 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
1336 BUILD(r, WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 1375 BUILD(r, WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
1337 | 1376 |
1338 FOR_UINT64_INPUTS(i) { | 1377 FOR_UINT64_INPUTS(i) { |
1339 FOR_UINT64_INPUTS(j) { | 1378 FOR_UINT64_INPUTS(j) { |
1340 int64_t expected = bits::RotateLeft64(*i, *j & 0x3f); | 1379 int64_t expected = bits::RotateLeft64(*i, *j & 0x3f); |
1341 CHECK_EQ(expected, r.Call(*i, *j)); | 1380 CHECK_EQ(expected, r.Call(*i, *j)); |
1342 } | 1381 } |
1343 } | 1382 } |
1344 } | 1383 } |
OLD | NEW |