| 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 |
| 11 #include "test/cctest/cctest.h" | 11 #include "test/cctest/cctest.h" |
| 12 #include "test/cctest/compiler/value-helper.h" | 12 #include "test/cctest/compiler/value-helper.h" |
| 13 #include "test/cctest/wasm/test-signatures.h" | 13 #include "test/cctest/wasm/test-signatures.h" |
| 14 #include "test/cctest/wasm/wasm-run-utils.h" | 14 #include "test/cctest/wasm/wasm-run-utils.h" |
| 15 | 15 |
| 16 #define CHECK_TRAP32(x) \ | 16 #define CHECK_TRAP32(x) \ |
| 17 CHECK_EQ(0xdeadbeef, (bit_cast<uint32_t>(x)) & 0xFFFFFFFF) | 17 CHECK_EQ(0xdeadbeef, (bit_cast<uint32_t>(x)) & 0xFFFFFFFF) |
| 18 #define CHECK_TRAP64(x) \ | 18 #define CHECK_TRAP64(x) \ |
| 19 CHECK_EQ(0xdeadbeefdeadbeef, (bit_cast<uint64_t>(x)) & 0xFFFFFFFFFFFFFFFF) | 19 CHECK_EQ(0xdeadbeefdeadbeef, (bit_cast<uint64_t>(x)) & 0xFFFFFFFFFFFFFFFF) |
| 20 #define CHECK_TRAP(x) CHECK_TRAP32(x) | 20 #define CHECK_TRAP(x) CHECK_TRAP32(x) |
| 21 | 21 |
| 22 #define asi64(x) static_cast<int64_t>(x) | 22 #define asi64(x) static_cast<int64_t>(x) |
| 23 | 23 |
| 24 #define asu64(x) static_cast<uint64_t>(x) | 24 #define asu64(x) static_cast<uint64_t>(x) |
| 25 | 25 |
| 26 #define B2(a, b) kExprBlock, 2, a, b | 26 #define B2(a, b) kExprBlock, a, b, kExprEnd |
| 27 #define B1(a) kExprBlock, 1, a | 27 #define B1(a) kExprBlock, a, kExprEnd |
| 28 | 28 |
| 29 // Can't bridge macro land with nested macros. | 29 // Can't bridge macro land with nested macros. |
| 30 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_X87 | 30 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_X87 |
| 31 #define MIPS_OR_X87 true | 31 #define MIPS_OR_X87 true |
| 32 #else | 32 #else |
| 33 #define MIPS_OR_X87 false | 33 #define MIPS_OR_X87 false |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_X87 || V8_TARGET_ARCH_ARM | 36 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_X87 || V8_TARGET_ARCH_ARM |
| 37 #define MIPS_OR_ARM_OR_X87 true | 37 #define MIPS_OR_ARM_OR_X87 true |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 REQUIRE(I64LoadStore); | 1102 REQUIRE(I64LoadStore); |
| 1103 REQUIRE(DepthFirst); // TODO(titzer): temporary hack | 1103 REQUIRE(DepthFirst); // TODO(titzer): temporary hack |
| 1104 byte loads[] = {kExprI64LoadMem8S, kExprI64LoadMem16S, kExprI64LoadMem32S, | 1104 byte loads[] = {kExprI64LoadMem8S, kExprI64LoadMem16S, kExprI64LoadMem32S, |
| 1105 kExprI64LoadMem}; | 1105 kExprI64LoadMem}; |
| 1106 | 1106 |
| 1107 for (size_t m = 0; m < arraysize(loads); m++) { | 1107 for (size_t m = 0; m < arraysize(loads); m++) { |
| 1108 TestingModule module; | 1108 TestingModule module; |
| 1109 byte* memory = module.AddMemoryElems<byte>(16); | 1109 byte* memory = module.AddMemoryElems<byte>(16); |
| 1110 WasmRunner<int64_t> r(&module); | 1110 WasmRunner<int64_t> r(&module); |
| 1111 | 1111 |
| 1112 byte code[] = {kExprI64StoreMem, ZERO_ALIGNMENT, | 1112 byte code[] = { |
| 1113 ZERO_OFFSET, // -- | 1113 kExprI8Const, 8, // -- |
| 1114 kExprI8Const, 8, // -- | 1114 kExprI8Const, 0, // -- |
| 1115 loads[m], ZERO_ALIGNMENT, | 1115 loads[m], // -- |
| 1116 ZERO_OFFSET, // -- | 1116 ZERO_ALIGNMENT, // -- |
| 1117 kExprI8Const, 0}; // -- | 1117 ZERO_OFFSET, // -- |
| 1118 kExprI64StoreMem, // -- |
| 1119 ZERO_ALIGNMENT, // -- |
| 1120 ZERO_OFFSET // -- |
| 1121 }; |
| 1118 | 1122 |
| 1119 r.Build(code, code + arraysize(code)); | 1123 r.Build(code, code + arraysize(code)); |
| 1120 | 1124 |
| 1121 // Try a bunch of different negative values. | 1125 // Try a bunch of different negative values. |
| 1122 for (int i = -1; i >= -128; i -= 11) { | 1126 for (int i = -1; i >= -128; i -= 11) { |
| 1123 int size = 1 << m; | 1127 int size = 1 << m; |
| 1124 module.BlankMemory(); | 1128 module.BlankMemory(); |
| 1125 memory[size - 1] = static_cast<byte>(i); // set the high order byte. | 1129 memory[size - 1] = static_cast<byte>(i); // set the high order byte. |
| 1126 | 1130 |
| 1127 int64_t expected = static_cast<int64_t>(i) << ((size - 1) * 8); | 1131 int64_t expected = static_cast<int64_t>(i) << ((size - 1) * 8); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 REQUIRE(I64Eq); | 1312 REQUIRE(I64Eq); |
| 1309 | 1313 |
| 1310 WasmRunner<int32_t> r(MachineType::Int64()); | 1314 WasmRunner<int32_t> r(MachineType::Int64()); |
| 1311 BUILD(r, WASM_I64_EQZ(WASM_GET_LOCAL(0))); | 1315 BUILD(r, WASM_I64_EQZ(WASM_GET_LOCAL(0))); |
| 1312 | 1316 |
| 1313 FOR_INT64_INPUTS(i) { | 1317 FOR_INT64_INPUTS(i) { |
| 1314 int32_t result = *i == 0 ? 1 : 0; | 1318 int32_t result = *i == 0 ? 1 : 0; |
| 1315 CHECK_EQ(result, r.Call(*i)); | 1319 CHECK_EQ(result, r.Call(*i)); |
| 1316 } | 1320 } |
| 1317 } | 1321 } |
| OLD | NEW |