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-64.cc

Issue 1830663002: [wasm] Binary 11: AST changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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/test-run-wasm-js.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/bits.h" 9 #include "src/base/bits.h"
10 #include "src/wasm/wasm-macro-gen.h" 10 #include "src/wasm/wasm-macro-gen.h"
11 11
12 #include "test/cctest/cctest.h" 12 #include "test/cctest/cctest.h"
13 #include "test/cctest/compiler/value-helper.h" 13 #include "test/cctest/compiler/value-helper.h"
14 #include "test/cctest/wasm/test-signatures.h" 14 #include "test/cctest/wasm/test-signatures.h"
15 #include "test/cctest/wasm/wasm-run-utils.h" 15 #include "test/cctest/wasm/wasm-run-utils.h"
16 16
17 #define CHECK_TRAP32(x) \ 17 #define CHECK_TRAP32(x) \
18 CHECK_EQ(0xdeadbeef, (bit_cast<uint32_t>(x)) & 0xFFFFFFFF) 18 CHECK_EQ(0xdeadbeef, (bit_cast<uint32_t>(x)) & 0xFFFFFFFF)
19 #define CHECK_TRAP64(x) \ 19 #define CHECK_TRAP64(x) \
20 CHECK_EQ(0xdeadbeefdeadbeef, (bit_cast<uint64_t>(x)) & 0xFFFFFFFFFFFFFFFF) 20 CHECK_EQ(0xdeadbeefdeadbeef, (bit_cast<uint64_t>(x)) & 0xFFFFFFFFFFFFFFFF)
21 #define CHECK_TRAP(x) CHECK_TRAP32(x) 21 #define CHECK_TRAP(x) CHECK_TRAP32(x)
22 22
23 #define asi64(x) static_cast<int64_t>(x) 23 #define asi64(x) static_cast<int64_t>(x)
24 24
25 #define asu64(x) static_cast<uint64_t>(x) 25 #define asu64(x) static_cast<uint64_t>(x)
26 26
27 #define B2(a, b) kExprBlock, 2, a, b 27 #define B2(a, b) kExprBlock, a, b, kExprEnd
28 #define B1(a) kExprBlock, 1, a 28 #define B1(a) kExprBlock, a, kExprEnd
29 29
30 // Can't bridge macro land with nested macros. 30 // Can't bridge macro land with nested macros.
31 #if V8_TARGET_ARCH_MIPS 31 #if V8_TARGET_ARCH_MIPS
32 #define MIPS true 32 #define MIPS true
33 #else 33 #else
34 #define MIPS false 34 #define MIPS false
35 #endif 35 #endif
36 36
37 #define FOREACH_I64_OPERATOR(V) \ 37 #define FOREACH_I64_OPERATOR(V) \
38 V(DepthFirst, true) \ 38 V(DepthFirst, true) \
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 BUILD(r, WASM_I64V(kExpectedValue)); 109 BUILD(r, WASM_I64V(kExpectedValue));
110 CHECK_EQ(kExpectedValue, r.Call()); 110 CHECK_EQ(kExpectedValue, r.Call());
111 cntr++; 111 cntr++;
112 } 112 }
113 } 113 }
114 114
115 TEST(Run_Wasm_Return_I64) { 115 TEST(Run_Wasm_Return_I64) {
116 REQUIRE(I64Return); 116 REQUIRE(I64Return);
117 WasmRunner<int64_t> r(MachineType::Int64()); 117 WasmRunner<int64_t> r(MachineType::Int64());
118 118
119 BUILD(r, WASM_RETURN(WASM_GET_LOCAL(0))); 119 BUILD(r, WASM_RETURN1(WASM_GET_LOCAL(0)));
120 120
121 FOR_INT64_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 121 FOR_INT64_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
122 } 122 }
123 123
124 // todo(ahaas): I added a list of missing instructions here to make merging 124 // todo(ahaas): I added a list of missing instructions here to make merging
125 // easier when I do them one by one. 125 // easier when I do them one by one.
126 // kExprI64Add: 126 // kExprI64Add:
127 TEST(Run_WasmI64Add) { 127 TEST(Run_WasmI64Add) {
128 REQUIRE(I64Add); 128 REQUIRE(I64Add);
129 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); 129 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64());
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 continue; 809 continue;
810 } else { 810 } else {
811 BUILD(t, WASM_GET_LOCAL(i)); 811 BUILD(t, WASM_GET_LOCAL(i));
812 } 812 }
813 uint32_t index = t.CompileAndAdd(); 813 uint32_t index = t.CompileAndAdd();
814 814
815 // Build the calling function. 815 // Build the calling function.
816 WasmRunner<int32_t> r(&module); 816 WasmRunner<int32_t> r(&module);
817 BUILD( 817 BUILD(
818 r, 818 r,
819 WASM_I32_CONVERT_I64(WASM_CALL_FUNCTION( 819 WASM_I32_CONVERT_I64(WASM_CALL_FUNCTIONN(
820 index, WASM_I64V_9(0xbcd12340000000b), 820 19, index, WASM_I64V_9(0xbcd12340000000b),
821 WASM_I64V_9(0xbcd12340000000c), WASM_I32V_1(0xd), 821 WASM_I64V_9(0xbcd12340000000c), WASM_I32V_1(0xd),
822 WASM_I32_CONVERT_I64(WASM_I64V_9(0xbcd12340000000e)), 822 WASM_I32_CONVERT_I64(WASM_I64V_9(0xbcd12340000000e)),
823 WASM_I64V_9(0xbcd12340000000f), WASM_I64V_10(0xbcd1234000000010), 823 WASM_I64V_9(0xbcd12340000000f), WASM_I64V_10(0xbcd1234000000010),
824 WASM_I64V_10(0xbcd1234000000011), WASM_I64V_10(0xbcd1234000000012), 824 WASM_I64V_10(0xbcd1234000000011), WASM_I64V_10(0xbcd1234000000012),
825 WASM_I64V_10(0xbcd1234000000013), WASM_I64V_10(0xbcd1234000000014), 825 WASM_I64V_10(0xbcd1234000000013), WASM_I64V_10(0xbcd1234000000014),
826 WASM_I64V_10(0xbcd1234000000015), WASM_I64V_10(0xbcd1234000000016), 826 WASM_I64V_10(0xbcd1234000000015), WASM_I64V_10(0xbcd1234000000016),
827 WASM_I64V_10(0xbcd1234000000017), WASM_I64V_10(0xbcd1234000000018), 827 WASM_I64V_10(0xbcd1234000000017), WASM_I64V_10(0xbcd1234000000018),
828 WASM_I64V_10(0xbcd1234000000019), WASM_I64V_10(0xbcd123400000001a), 828 WASM_I64V_10(0xbcd1234000000019), WASM_I64V_10(0xbcd123400000001a),
829 WASM_I64V_10(0xbcd123400000001b), WASM_I64V_10(0xbcd123400000001c), 829 WASM_I64V_10(0xbcd123400000001b), WASM_I64V_10(0xbcd123400000001c),
830 WASM_I64V_10(0xbcd123400000001d)))); 830 WASM_I64V_10(0xbcd123400000001d))));
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 REQUIRE(I64Sub); 1086 REQUIRE(I64Sub);
1087 // Build the target function. 1087 // Build the target function.
1088 TestSignatures sigs; 1088 TestSignatures sigs;
1089 TestingModule module; 1089 TestingModule module;
1090 WasmFunctionCompiler t(sigs.l_ll(), &module); 1090 WasmFunctionCompiler t(sigs.l_ll(), &module);
1091 BUILD(t, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 1091 BUILD(t, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
1092 uint32_t index = t.CompileAndAdd(); 1092 uint32_t index = t.CompileAndAdd();
1093 1093
1094 // Build the caller function. 1094 // Build the caller function.
1095 WasmRunner<int64_t> r(&module, MachineType::Int64(), MachineType::Int64()); 1095 WasmRunner<int64_t> r(&module, MachineType::Int64(), MachineType::Int64());
1096 BUILD(r, WASM_CALL_FUNCTION(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 1096 BUILD(r, WASM_CALL_FUNCTION2(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
1097 1097
1098 FOR_INT32_INPUTS(i) { 1098 FOR_INT32_INPUTS(i) {
1099 FOR_INT32_INPUTS(j) { 1099 FOR_INT32_INPUTS(j) {
1100 int64_t a = static_cast<int64_t>(*i) << 32 | 1100 int64_t a = static_cast<int64_t>(*i) << 32 |
1101 (static_cast<int64_t>(*j) | 0xFFFFFFFF); 1101 (static_cast<int64_t>(*j) | 0xFFFFFFFF);
1102 int64_t b = static_cast<int64_t>(*j) << 32 | 1102 int64_t b = static_cast<int64_t>(*j) << 32 |
1103 (static_cast<int64_t>(*i) | 0xFFFFFFFF); 1103 (static_cast<int64_t>(*i) | 0xFFFFFFFF);
1104 1104
1105 int64_t expected = static_cast<int64_t>(static_cast<uint64_t>(a) - 1105 int64_t expected = static_cast<int64_t>(static_cast<uint64_t>(a) -
1106 static_cast<uint64_t>(b)); 1106 static_cast<uint64_t>(b));
1107 CHECK_EQ(expected, r.Call(a, b)); 1107 CHECK_EQ(expected, r.Call(a, b));
1108 } 1108 }
1109 } 1109 }
1110 } 1110 }
1111 1111
1112 TEST(Run_Wasm_LoadStoreI64_sx) { 1112 TEST(Run_Wasm_LoadStoreI64_sx) {
1113 REQUIRE(I64LoadStore); 1113 REQUIRE(I64LoadStore);
1114 REQUIRE(DepthFirst); 1114 REQUIRE(DepthFirst);
1115 byte loads[] = {kExprI64LoadMem8S, kExprI64LoadMem16S, kExprI64LoadMem32S, 1115 byte loads[] = {kExprI64LoadMem8S, kExprI64LoadMem16S, kExprI64LoadMem32S,
1116 kExprI64LoadMem}; 1116 kExprI64LoadMem};
1117 1117
1118 for (size_t m = 0; m < arraysize(loads); m++) { 1118 for (size_t m = 0; m < arraysize(loads); m++) {
1119 TestingModule module; 1119 TestingModule module;
1120 byte* memory = module.AddMemoryElems<byte>(16); 1120 byte* memory = module.AddMemoryElems<byte>(16);
1121 WasmRunner<int64_t> r(&module); 1121 WasmRunner<int64_t> r(&module);
1122 1122
1123 byte code[] = {kExprI64StoreMem, ZERO_ALIGNMENT, 1123 byte code[] = {
1124 ZERO_OFFSET, // -- 1124 kExprI8Const, 8, // --
1125 kExprI8Const, 8, // -- 1125 kExprI8Const, 0, // --
1126 loads[m], ZERO_ALIGNMENT, 1126 loads[m], // --
1127 ZERO_OFFSET, // -- 1127 ZERO_ALIGNMENT, // --
1128 kExprI8Const, 0}; // -- 1128 ZERO_OFFSET, // --
1129 kExprI64StoreMem, // --
1130 ZERO_ALIGNMENT, // --
1131 ZERO_OFFSET // --
1132 };
1129 1133
1130 r.Build(code, code + arraysize(code)); 1134 r.Build(code, code + arraysize(code));
1131 1135
1132 // Try a bunch of different negative values. 1136 // Try a bunch of different negative values.
1133 for (int i = -1; i >= -128; i -= 11) { 1137 for (int i = -1; i >= -128; i -= 11) {
1134 int size = 1 << m; 1138 int size = 1 << m;
1135 module.BlankMemory(); 1139 module.BlankMemory();
1136 memory[size - 1] = static_cast<byte>(i); // set the high order byte. 1140 memory[size - 1] = static_cast<byte>(i); // set the high order byte.
1137 1141
1138 int64_t expected = static_cast<int64_t>(i) << ((size - 1) * 8); 1142 int64_t expected = static_cast<int64_t>(i) << ((size - 1) * 8);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); 1349 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64());
1346 BUILD(r, WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 1350 BUILD(r, WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
1347 1351
1348 FOR_UINT64_INPUTS(i) { 1352 FOR_UINT64_INPUTS(i) {
1349 FOR_UINT64_INPUTS(j) { 1353 FOR_UINT64_INPUTS(j) {
1350 int64_t expected = bits::RotateLeft64(*i, *j & 0x3f); 1354 int64_t expected = bits::RotateLeft64(*i, *j & 0x3f);
1351 CHECK_EQ(expected, r.Call(*i, *j)); 1355 CHECK_EQ(expected, r.Call(*i, *j));
1352 } 1356 }
1353 } 1357 }
1354 } 1358 }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm.cc ('k') | test/cctest/wasm/test-run-wasm-js.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698