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

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

Issue 2061583002: [ia32] Propagate rmodes when computing MemoryOperands (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: sep tests 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 | « src/compiler/ia32/code-generator-ia32.cc ('k') | no next file » | 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
11 #include "src/wasm/wasm-macro-gen.h" 11 #include "src/wasm/wasm-macro-gen.h"
12 12
13 #include "test/cctest/cctest.h" 13 #include "test/cctest/cctest.h"
14 #include "test/cctest/compiler/value-helper.h" 14 #include "test/cctest/compiler/value-helper.h"
15 #include "test/cctest/wasm/test-signatures.h" 15 #include "test/cctest/wasm/test-signatures.h"
16 #include "test/cctest/wasm/wasm-run-utils.h" 16 #include "test/cctest/wasm/wasm-run-utils.h"
17 17
18 using namespace v8::base; 18 using namespace v8::base;
19 using namespace v8::internal; 19 using namespace v8::internal;
20 using namespace v8::internal::compiler; 20 using namespace v8::internal::compiler;
21 using namespace v8::internal::wasm; 21 using namespace v8::internal::wasm;
22 22
23 // for even shorter tests. 23 // for even shorter tests.
24 #define B2(a, b) kExprBlock, a, b, kExprEnd 24 #define B2(a, b) kExprBlock, a, b, kExprEnd
25 #define B1(a) kExprBlock, a, kExprEnd 25 #define B1(a) kExprBlock, a, kExprEnd
26 #define RET(x) x, kExprReturn, 1 26 #define RET(x) x, kExprReturn, 1
27 #define RET_I8(x) kExprI8Const, x, kExprReturn, 1 27 #define RET_I8(x) kExprI8Const, x, kExprReturn, 1
28 28
29 namespace {
30 uint32_t GetMatchingRelocInfoCount(Handle<Code> code, RelocInfo::Mode rmode) {
31 int filter = 1 << rmode;
32 uint32_t ret = 0;
33 for (RelocIterator it(*code, filter); !it.done(); it.next()) {
34 ++ret;
35 }
36 return ret;
37 }
38 }
39
29 WASM_EXEC_TEST(Int32AsmjsDivS) { 40 WASM_EXEC_TEST(Int32AsmjsDivS) {
30 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(), 41 WasmRunner<int32_t> r(execution_mode, MachineType::Int32(),
31 MachineType::Int32()); 42 MachineType::Int32());
32 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)));
33 const int32_t kMin = std::numeric_limits<int32_t>::min(); 44 const int32_t kMin = std::numeric_limits<int32_t>::min();
34 CHECK_EQ(0, r.Call(0, 100)); 45 CHECK_EQ(0, r.Call(0, 100));
35 CHECK_EQ(0, r.Call(100, 0)); 46 CHECK_EQ(0, r.Call(100, 0));
36 CHECK_EQ(0, r.Call(-1001, 0)); 47 CHECK_EQ(0, r.Call(-1001, 0));
37 CHECK_EQ(kMin, r.Call(kMin, -1)); 48 CHECK_EQ(kMin, r.Call(kMin, -1));
38 CHECK_EQ(0, r.Call(kMin, 0)); 49 CHECK_EQ(0, r.Call(kMin, 0));
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 CHECK_EQ(999999, memory[0]); 201 CHECK_EQ(999999, memory[0]);
191 // TODO(titzer): offset 29-31 should also be OOB. 202 // TODO(titzer): offset 29-31 should also be OOB.
192 for (uint32_t offset = 32; offset < 40; offset++) { 203 for (uint32_t offset = 32; offset < 40; offset++) {
193 CHECK_EQ(8888, r.Call(offset, 8888)); 204 CHECK_EQ(8888, r.Call(offset, 8888));
194 } 205 }
195 206
196 for (uint32_t offset = 0x10000000; offset < 0xF0000000; offset += 0x1000000) { 207 for (uint32_t offset = 0x10000000; offset < 0xF0000000; offset += 0x1000000) {
197 CHECK_EQ(7777, r.Call(offset, 7777)); 208 CHECK_EQ(7777, r.Call(offset, 7777));
198 } 209 }
199 } 210 }
211
212 #define FOREACH_INT_CHECKED_LOAD_OP(TEST_BODY) \
213 TEST_BODY(kExprI32AsmjsLoadMem8S) \
214 TEST_BODY(kExprI32AsmjsLoadMem8U) \
215 TEST_BODY(kExprI32AsmjsLoadMem16S) \
216 TEST_BODY(kExprI32AsmjsLoadMem16U) \
217 TEST_BODY(kExprI32AsmjsLoadMem)
218
219 #define FOREACH_INT_CHECKED_STORE_OP(TEST_BODY) \
220 TEST_BODY(kExprI32AsmjsStoreMem8) \
221 TEST_BODY(kExprI32AsmjsStoreMem16) \
222 TEST_BODY(kExprI32AsmjsStoreMem)
223
224 #define INT_LOAD_TEST(OP_TYPE) \
225 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
226 TestingModule module(kExecuteCompiled); \
227 WasmRunner<int32_t> r(&module, MachineType::Uint32()); \
228 BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \
229 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], \
230 RelocInfo::WASM_MEMORY_REFERENCE)); \
231 }
232
233 FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST)
234
235 #define INT_STORE_TEST(OP_TYPE) \
236 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
237 TestingModule module(kExecuteCompiled); \
238 WasmRunner<int32_t> r(&module, MachineType::Uint32(), \
239 MachineType::Uint32()); \
240 BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \
241 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], \
242 RelocInfo::WASM_MEMORY_REFERENCE)); \
243 }
244
245 FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST)
246
247 TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) {
248 TestingModule module(kExecuteCompiled);
249 WasmRunner<float_t> r(&module, MachineType::Uint32());
250 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0)));
251
252 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
253 RelocInfo::WASM_MEMORY_REFERENCE));
254 }
255
256 TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) {
257 TestingModule module(kExecuteCompiled);
258 WasmRunner<float_t> r(&module, MachineType::Uint32(), MachineType::Float32());
259 BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0),
260 WASM_GET_LOCAL(1)));
261
262 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
263 RelocInfo::WASM_MEMORY_REFERENCE));
264 }
265
266 TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) {
267 TestingModule module(kExecuteCompiled);
268 WasmRunner<double_t> r(&module, MachineType::Uint32());
269 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0)));
270
271 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
272 RelocInfo::WASM_MEMORY_REFERENCE));
273 }
274
275 TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) {
276 TestingModule module(kExecuteCompiled);
277 WasmRunner<double_t> r(&module, MachineType::Uint32(),
278 MachineType::Float64());
279 BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0),
280 WASM_GET_LOCAL(1)));
281
282 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
283 RelocInfo::WASM_MEMORY_REFERENCE));
284 }
OLDNEW
« no previous file with comments | « src/compiler/ia32/code-generator-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698