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

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

Issue 2551043002: [wasm] Make WasmRunner the central test structure (Closed)
Patch Set: Make DoCall return void - quickfix Created 4 years 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-64.cc ('k') | test/cctest/wasm/test-run-wasm-interpreter.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/platform/elapsed-timer.h" 9 #include "src/base/platform/elapsed-timer.h"
10 10
(...skipping 20 matching lines...) Expand all
31 int filter = 1 << rmode; 31 int filter = 1 << rmode;
32 uint32_t ret = 0; 32 uint32_t ret = 0;
33 for (RelocIterator it(*code, filter); !it.done(); it.next()) { 33 for (RelocIterator it(*code, filter); !it.done(); it.next()) {
34 ++ret; 34 ++ret;
35 } 35 }
36 return ret; 36 return ret;
37 } 37 }
38 } 38 }
39 39
40 WASM_EXEC_TEST(Int32AsmjsDivS) { 40 WASM_EXEC_TEST(Int32AsmjsDivS) {
41 TestingModule module(execution_mode); 41 WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
42 module.ChangeOriginToAsmjs(); 42 r.module().ChangeOriginToAsmjs();
43 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32());
44 BUILD(r, WASM_BINOP(kExprI32AsmjsDivS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 43 BUILD(r, WASM_BINOP(kExprI32AsmjsDivS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
45 const int32_t kMin = std::numeric_limits<int32_t>::min(); 44 const int32_t kMin = std::numeric_limits<int32_t>::min();
46 CHECK_EQ(0, r.Call(0, 100)); 45 CHECK_EQ(0, r.Call(0, 100));
47 CHECK_EQ(0, r.Call(100, 0)); 46 CHECK_EQ(0, r.Call(100, 0));
48 CHECK_EQ(0, r.Call(-1001, 0)); 47 CHECK_EQ(0, r.Call(-1001, 0));
49 CHECK_EQ(kMin, r.Call(kMin, -1)); 48 CHECK_EQ(kMin, r.Call(kMin, -1));
50 CHECK_EQ(0, r.Call(kMin, 0)); 49 CHECK_EQ(0, r.Call(kMin, 0));
51 } 50 }
52 51
53 WASM_EXEC_TEST(Int32AsmjsRemS) { 52 WASM_EXEC_TEST(Int32AsmjsRemS) {
54 TestingModule module(execution_mode); 53 WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
55 module.ChangeOriginToAsmjs(); 54 r.module().ChangeOriginToAsmjs();
56 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32());
57 BUILD(r, WASM_BINOP(kExprI32AsmjsRemS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 55 BUILD(r, WASM_BINOP(kExprI32AsmjsRemS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
58 const int32_t kMin = std::numeric_limits<int32_t>::min(); 56 const int32_t kMin = std::numeric_limits<int32_t>::min();
59 CHECK_EQ(33, r.Call(133, 100)); 57 CHECK_EQ(33, r.Call(133, 100));
60 CHECK_EQ(0, r.Call(kMin, -1)); 58 CHECK_EQ(0, r.Call(kMin, -1));
61 CHECK_EQ(0, r.Call(100, 0)); 59 CHECK_EQ(0, r.Call(100, 0));
62 CHECK_EQ(0, r.Call(-1001, 0)); 60 CHECK_EQ(0, r.Call(-1001, 0));
63 CHECK_EQ(0, r.Call(kMin, 0)); 61 CHECK_EQ(0, r.Call(kMin, 0));
64 } 62 }
65 63
66 WASM_EXEC_TEST(Int32AsmjsDivU) { 64 WASM_EXEC_TEST(Int32AsmjsDivU) {
67 TestingModule module(execution_mode); 65 WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
68 module.ChangeOriginToAsmjs(); 66 r.module().ChangeOriginToAsmjs();
69 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32());
70 BUILD(r, WASM_BINOP(kExprI32AsmjsDivU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 67 BUILD(r, WASM_BINOP(kExprI32AsmjsDivU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
71 const int32_t kMin = std::numeric_limits<int32_t>::min(); 68 const int32_t kMin = std::numeric_limits<int32_t>::min();
72 CHECK_EQ(0, r.Call(0, 100)); 69 CHECK_EQ(0, r.Call(0, 100));
73 CHECK_EQ(0, r.Call(kMin, -1)); 70 CHECK_EQ(0, r.Call(kMin, -1));
74 CHECK_EQ(0, r.Call(100, 0)); 71 CHECK_EQ(0, r.Call(100, 0));
75 CHECK_EQ(0, r.Call(-1001, 0)); 72 CHECK_EQ(0, r.Call(-1001, 0));
76 CHECK_EQ(0, r.Call(kMin, 0)); 73 CHECK_EQ(0, r.Call(kMin, 0));
77 } 74 }
78 75
79 WASM_EXEC_TEST(Int32AsmjsRemU) { 76 WASM_EXEC_TEST(Int32AsmjsRemU) {
80 TestingModule module(execution_mode); 77 WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
81 module.ChangeOriginToAsmjs(); 78 r.module().ChangeOriginToAsmjs();
82 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32());
83 BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 79 BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
84 const int32_t kMin = std::numeric_limits<int32_t>::min(); 80 const int32_t kMin = std::numeric_limits<int32_t>::min();
85 CHECK_EQ(17, r.Call(217, 100)); 81 CHECK_EQ(17, r.Call(217, 100));
86 CHECK_EQ(0, r.Call(100, 0)); 82 CHECK_EQ(0, r.Call(100, 0));
87 CHECK_EQ(0, r.Call(-1001, 0)); 83 CHECK_EQ(0, r.Call(-1001, 0));
88 CHECK_EQ(0, r.Call(kMin, 0)); 84 CHECK_EQ(0, r.Call(kMin, 0));
89 CHECK_EQ(kMin, r.Call(kMin, -1)); 85 CHECK_EQ(kMin, r.Call(kMin, -1));
90 } 86 }
91 87
92 WASM_EXEC_TEST(I32AsmjsSConvertF32) { 88 WASM_EXEC_TEST(I32AsmjsSConvertF32) {
93 TestingModule module(execution_mode); 89 WasmRunner<int32_t, float> r(execution_mode);
94 module.ChangeOriginToAsmjs(); 90 r.module().ChangeOriginToAsmjs();
95 WasmRunner<int32_t> r(&module, MachineType::Float32());
96 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0))); 91 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0)));
97 92
98 FOR_FLOAT32_INPUTS(i) { 93 FOR_FLOAT32_INPUTS(i) {
99 int32_t expected = DoubleToInt32(*i); 94 int32_t expected = DoubleToInt32(*i);
100 CHECK_EQ(expected, r.Call(*i)); 95 CHECK_EQ(expected, r.Call(*i));
101 } 96 }
102 } 97 }
103 98
104 WASM_EXEC_TEST(I32AsmjsSConvertF64) { 99 WASM_EXEC_TEST(I32AsmjsSConvertF64) {
105 TestingModule module(execution_mode); 100 WasmRunner<int32_t, double> r(execution_mode);
106 module.ChangeOriginToAsmjs(); 101 r.module().ChangeOriginToAsmjs();
107 WasmRunner<int32_t> r(&module, MachineType::Float64());
108 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0))); 102 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0)));
109 103
110 FOR_FLOAT64_INPUTS(i) { 104 FOR_FLOAT64_INPUTS(i) {
111 int32_t expected = DoubleToInt32(*i); 105 int32_t expected = DoubleToInt32(*i);
112 CHECK_EQ(expected, r.Call(*i)); 106 CHECK_EQ(expected, r.Call(*i));
113 } 107 }
114 } 108 }
115 109
116 WASM_EXEC_TEST(I32AsmjsUConvertF32) { 110 WASM_EXEC_TEST(I32AsmjsUConvertF32) {
117 TestingModule module(execution_mode); 111 WasmRunner<uint32_t, float> r(execution_mode);
118 module.ChangeOriginToAsmjs(); 112 r.module().ChangeOriginToAsmjs();
119 WasmRunner<uint32_t> r(&module, MachineType::Float32());
120 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0))); 113 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0)));
121 114
122 FOR_FLOAT32_INPUTS(i) { 115 FOR_FLOAT32_INPUTS(i) {
123 uint32_t expected = DoubleToUint32(*i); 116 uint32_t expected = DoubleToUint32(*i);
124 CHECK_EQ(expected, r.Call(*i)); 117 CHECK_EQ(expected, r.Call(*i));
125 } 118 }
126 } 119 }
127 120
128 WASM_EXEC_TEST(I32AsmjsUConvertF64) { 121 WASM_EXEC_TEST(I32AsmjsUConvertF64) {
129 TestingModule module(execution_mode); 122 WasmRunner<uint32_t, double> r(execution_mode);
130 module.ChangeOriginToAsmjs(); 123 r.module().ChangeOriginToAsmjs();
131 WasmRunner<uint32_t> r(&module, MachineType::Float64());
132 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0))); 124 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0)));
133 125
134 FOR_FLOAT64_INPUTS(i) { 126 FOR_FLOAT64_INPUTS(i) {
135 uint32_t expected = DoubleToUint32(*i); 127 uint32_t expected = DoubleToUint32(*i);
136 CHECK_EQ(expected, r.Call(*i)); 128 CHECK_EQ(expected, r.Call(*i));
137 } 129 }
138 } 130 }
139 131
140 WASM_EXEC_TEST(LoadMemI32_oob_asm) { 132 WASM_EXEC_TEST(LoadMemI32_oob_asm) {
141 TestingModule module(execution_mode); 133 WasmRunner<int32_t, uint32_t> r(execution_mode);
142 module.ChangeOriginToAsmjs(); 134 r.module().ChangeOriginToAsmjs();
143 int32_t* memory = module.AddMemoryElems<int32_t>(8); 135 int32_t* memory = r.module().AddMemoryElems<int32_t>(8);
144 WasmRunner<int32_t> r(&module, MachineType::Uint32()); 136 r.module().RandomizeMemory(1112);
145 module.RandomizeMemory(1112);
146 137
147 BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0))); 138 BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0)));
148 139
149 memory[0] = 999999; 140 memory[0] = 999999;
150 CHECK_EQ(999999, r.Call(0u)); 141 CHECK_EQ(999999, r.Call(0u));
151 // TODO(titzer): offset 29-31 should also be OOB. 142 // TODO(titzer): offset 29-31 should also be OOB.
152 for (uint32_t offset = 32; offset < 40; offset++) { 143 for (uint32_t offset = 32; offset < 40; offset++) {
153 CHECK_EQ(0, r.Call(offset)); 144 CHECK_EQ(0, r.Call(offset));
154 } 145 }
155 146
156 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { 147 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) {
157 CHECK_EQ(0, r.Call(offset)); 148 CHECK_EQ(0, r.Call(offset));
158 } 149 }
159 } 150 }
160 151
161 WASM_EXEC_TEST(LoadMemF32_oob_asm) { 152 WASM_EXEC_TEST(LoadMemF32_oob_asm) {
162 TestingModule module(execution_mode); 153 WasmRunner<float, uint32_t> r(execution_mode);
163 module.ChangeOriginToAsmjs(); 154 r.module().ChangeOriginToAsmjs();
164 float* memory = module.AddMemoryElems<float>(8); 155 float* memory = r.module().AddMemoryElems<float>(8);
165 WasmRunner<float> r(&module, MachineType::Uint32()); 156 r.module().RandomizeMemory(1112);
166 module.RandomizeMemory(1112);
167 157
168 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); 158 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0)));
169 159
170 memory[0] = 9999.5f; 160 memory[0] = 9999.5f;
171 CHECK_EQ(9999.5f, r.Call(0u)); 161 CHECK_EQ(9999.5f, r.Call(0u));
172 // TODO(titzer): offset 29-31 should also be OOB. 162 // TODO(titzer): offset 29-31 should also be OOB.
173 for (uint32_t offset = 32; offset < 40; offset++) { 163 for (uint32_t offset = 32; offset < 40; offset++) {
174 CHECK(std::isnan(r.Call(offset))); 164 CHECK(std::isnan(r.Call(offset)));
175 } 165 }
176 166
177 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { 167 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) {
178 CHECK(std::isnan(r.Call(offset))); 168 CHECK(std::isnan(r.Call(offset)));
179 } 169 }
180 } 170 }
181 171
182 WASM_EXEC_TEST(LoadMemF64_oob_asm) { 172 WASM_EXEC_TEST(LoadMemF64_oob_asm) {
183 TestingModule module(execution_mode); 173 WasmRunner<double, uint32_t> r(execution_mode);
184 module.ChangeOriginToAsmjs(); 174 r.module().ChangeOriginToAsmjs();
185 double* memory = module.AddMemoryElems<double>(8); 175 double* memory = r.module().AddMemoryElems<double>(8);
186 WasmRunner<double> r(&module, MachineType::Uint32()); 176 r.module().RandomizeMemory(1112);
187 module.RandomizeMemory(1112);
188 177
189 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); 178 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0)));
190 179
191 memory[0] = 9799.5; 180 memory[0] = 9799.5;
192 CHECK_EQ(9799.5, r.Call(0u)); 181 CHECK_EQ(9799.5, r.Call(0u));
193 memory[1] = 11799.25; 182 memory[1] = 11799.25;
194 CHECK_EQ(11799.25, r.Call(8u)); 183 CHECK_EQ(11799.25, r.Call(8u));
195 // TODO(titzer): offset 57-63 should also be OOB. 184 // TODO(titzer): offset 57-63 should also be OOB.
196 for (uint32_t offset = 64; offset < 80; offset++) { 185 for (uint32_t offset = 64; offset < 80; offset++) {
197 CHECK(std::isnan(r.Call(offset))); 186 CHECK(std::isnan(r.Call(offset)));
198 } 187 }
199 188
200 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { 189 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) {
201 CHECK(std::isnan(r.Call(offset))); 190 CHECK(std::isnan(r.Call(offset)));
202 } 191 }
203 } 192 }
204 193
205 WASM_EXEC_TEST(StoreMemI32_oob_asm) { 194 WASM_EXEC_TEST(StoreMemI32_oob_asm) {
206 TestingModule module(execution_mode); 195 WasmRunner<int32_t, uint32_t, uint32_t> r(execution_mode);
207 module.ChangeOriginToAsmjs(); 196 r.module().ChangeOriginToAsmjs();
208 int32_t* memory = module.AddMemoryElems<int32_t>(8); 197 int32_t* memory = r.module().AddMemoryElems<int32_t>(8);
209 WasmRunner<int32_t> r(&module, MachineType::Uint32(), MachineType::Uint32()); 198 r.module().RandomizeMemory(1112);
210 module.RandomizeMemory(1112);
211 199
212 BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0), 200 BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0),
213 WASM_GET_LOCAL(1))); 201 WASM_GET_LOCAL(1)));
214 202
215 memory[0] = 7777; 203 memory[0] = 7777;
216 CHECK_EQ(999999, r.Call(0u, 999999)); 204 CHECK_EQ(999999, r.Call(0u, 999999));
217 CHECK_EQ(999999, memory[0]); 205 CHECK_EQ(999999, memory[0]);
218 // TODO(titzer): offset 29-31 should also be OOB. 206 // TODO(titzer): offset 29-31 should also be OOB.
219 for (uint32_t offset = 32; offset < 40; offset++) { 207 for (uint32_t offset = 32; offset < 40; offset++) {
220 CHECK_EQ(8888, r.Call(offset, 8888)); 208 CHECK_EQ(8888, r.Call(offset, 8888));
221 } 209 }
222 210
223 for (uint32_t offset = 0x10000000; offset < 0xF0000000; offset += 0x1000000) { 211 for (uint32_t offset = 0x10000000; offset < 0xF0000000; offset += 0x1000000) {
224 CHECK_EQ(7777, r.Call(offset, 7777)); 212 CHECK_EQ(7777, r.Call(offset, 7777));
225 } 213 }
226 } 214 }
227 215
228 #define FOREACH_INT_CHECKED_LOAD_OP(TEST_BODY) \ 216 #define FOREACH_INT_CHECKED_LOAD_OP(TEST_BODY) \
229 TEST_BODY(kExprI32AsmjsLoadMem8S) \ 217 TEST_BODY(kExprI32AsmjsLoadMem8S) \
230 TEST_BODY(kExprI32AsmjsLoadMem8U) \ 218 TEST_BODY(kExprI32AsmjsLoadMem8U) \
231 TEST_BODY(kExprI32AsmjsLoadMem16S) \ 219 TEST_BODY(kExprI32AsmjsLoadMem16S) \
232 TEST_BODY(kExprI32AsmjsLoadMem16U) \ 220 TEST_BODY(kExprI32AsmjsLoadMem16U) \
233 TEST_BODY(kExprI32AsmjsLoadMem) 221 TEST_BODY(kExprI32AsmjsLoadMem)
234 222
235 #define FOREACH_INT_CHECKED_STORE_OP(TEST_BODY) \ 223 #define FOREACH_INT_CHECKED_STORE_OP(TEST_BODY) \
236 TEST_BODY(kExprI32AsmjsStoreMem8) \ 224 TEST_BODY(kExprI32AsmjsStoreMem8) \
237 TEST_BODY(kExprI32AsmjsStoreMem16) \ 225 TEST_BODY(kExprI32AsmjsStoreMem16) \
238 TEST_BODY(kExprI32AsmjsStoreMem) 226 TEST_BODY(kExprI32AsmjsStoreMem)
239 227
240 #define INT_LOAD_TEST(OP_TYPE) \ 228 #define INT_LOAD_TEST(OP_TYPE) \
241 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ 229 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
242 TestingModule module(kExecuteCompiled); \ 230 WasmRunner<int32_t, uint32_t> r(kExecuteCompiled); \
243 module.ChangeOriginToAsmjs(); \ 231 r.module().ChangeOriginToAsmjs(); \
244 WasmRunner<int32_t> r(&module, MachineType::Uint32()); \ 232 BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \
245 BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \ 233 CHECK_EQ(1, \
246 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ 234 GetMatchingRelocInfoCount(r.module().instance->function_code[0], \
247 RelocInfo::WASM_MEMORY_REFERENCE)); \ 235 RelocInfo::WASM_MEMORY_REFERENCE)); \
248 CHECK_NE( \ 236 CHECK_NE( \
249 0u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ 237 0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], \
250 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ 238 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
251 } 239 }
252 240
253 FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST) 241 FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST)
254 242
255 #define INT_STORE_TEST(OP_TYPE) \ 243 #define INT_STORE_TEST(OP_TYPE) \
256 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ 244 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
257 TestingModule module(kExecuteCompiled); \ 245 WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteCompiled); \
258 module.ChangeOriginToAsmjs(); \ 246 r.module().ChangeOriginToAsmjs(); \
259 WasmRunner<int32_t> r(&module, MachineType::Uint32(), \ 247 BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \
260 MachineType::Uint32()); \ 248 CHECK_EQ(1, \
261 BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \ 249 GetMatchingRelocInfoCount(r.module().instance->function_code[0], \
262 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ 250 RelocInfo::WASM_MEMORY_REFERENCE)); \
263 RelocInfo::WASM_MEMORY_REFERENCE)); \ 251 CHECK_NE( \
264 CHECK_NE( \ 252 0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], \
265 0u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ 253 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
266 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
267 } 254 }
268 255
269 FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST) 256 FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST)
270 257
271 TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) { 258 TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) {
272 TestingModule module(kExecuteCompiled); 259 WasmRunner<float, uint32_t> r(kExecuteCompiled);
273 module.ChangeOriginToAsmjs(); 260 r.module().ChangeOriginToAsmjs();
274 WasmRunner<float> r(&module, MachineType::Uint32());
275 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); 261 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0)));
276 262
277 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], 263 CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0],
278 RelocInfo::WASM_MEMORY_REFERENCE)); 264 RelocInfo::WASM_MEMORY_REFERENCE));
279 CHECK_NE(0u, 265 CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0],
280 GetMatchingRelocInfoCount(module.instance->function_code[0], 266 RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
281 RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
282 } 267 }
283 268
284 TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) { 269 TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) {
285 TestingModule module(kExecuteCompiled); 270 WasmRunner<float, uint32_t, float> r(kExecuteCompiled);
286 module.ChangeOriginToAsmjs(); 271 r.module().ChangeOriginToAsmjs();
287 WasmRunner<float> r(&module, MachineType::Uint32(), MachineType::Float32());
288 BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0), 272 BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0),
289 WASM_GET_LOCAL(1))); 273 WASM_GET_LOCAL(1)));
290 274
291 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], 275 CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0],
292 RelocInfo::WASM_MEMORY_REFERENCE)); 276 RelocInfo::WASM_MEMORY_REFERENCE));
293 CHECK_NE(0u, 277 CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0],
294 GetMatchingRelocInfoCount(module.instance->function_code[0], 278 RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
295 RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
296 } 279 }
297 280
298 TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) { 281 TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) {
299 TestingModule module(kExecuteCompiled); 282 WasmRunner<double, uint32_t> r(kExecuteCompiled);
300 module.ChangeOriginToAsmjs(); 283 r.module().ChangeOriginToAsmjs();
301 WasmRunner<double> r(&module, MachineType::Uint32());
302 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); 284 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0)));
303 285
304 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], 286 CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0],
305 RelocInfo::WASM_MEMORY_REFERENCE)); 287 RelocInfo::WASM_MEMORY_REFERENCE));
306 CHECK_NE(0u, 288 CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0],
307 GetMatchingRelocInfoCount(module.instance->function_code[0], 289 RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
308 RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
309 } 290 }
310 291
311 TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) { 292 TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) {
312 TestingModule module(kExecuteCompiled); 293 WasmRunner<double, uint32_t, double> r(kExecuteCompiled);
313 module.ChangeOriginToAsmjs(); 294 r.module().ChangeOriginToAsmjs();
314 WasmRunner<double> r(&module, MachineType::Uint32(), MachineType::Float64());
315 BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0), 295 BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0),
316 WASM_GET_LOCAL(1))); 296 WASM_GET_LOCAL(1)));
317 297
318 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], 298 CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0],
319 RelocInfo::WASM_MEMORY_REFERENCE)); 299 RelocInfo::WASM_MEMORY_REFERENCE));
320 CHECK_NE(0u, 300 CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0],
321 GetMatchingRelocInfoCount(module.instance->function_code[0], 301 RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
322 RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
323 } 302 }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-64.cc ('k') | test/cctest/wasm/test-run-wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698