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

Issue 1968943002: [wasm] Introduce custom asm.js bytecodes for loads and stores. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm_asmjs_convert
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 | « src/wasm/wasm-opcodes.h ('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
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 } 111 }
112 112
113 TEST(Run_Wasm_LoadMemI32_oob_asm) { 113 TEST(Run_Wasm_LoadMemI32_oob_asm) {
114 TestingModule module; 114 TestingModule module;
115 module.origin = kAsmJsOrigin; 115 module.origin = kAsmJsOrigin;
116 int32_t* memory = module.AddMemoryElems<int32_t>(8); 116 int32_t* memory = module.AddMemoryElems<int32_t>(8);
117 WasmRunner<int32_t> r(&module, MachineType::Uint32()); 117 WasmRunner<int32_t> r(&module, MachineType::Uint32());
118 module.RandomizeMemory(1112); 118 module.RandomizeMemory(1112);
119 119
120 BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0))); 120 BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0)));
121 121
122 memory[0] = 999999; 122 memory[0] = 999999;
123 CHECK_EQ(999999, r.Call(0u)); 123 CHECK_EQ(999999, r.Call(0u));
124 // TODO(titzer): offset 29-31 should also be OOB. 124 // TODO(titzer): offset 29-31 should also be OOB.
125 for (uint32_t offset = 32; offset < 40; offset++) { 125 for (uint32_t offset = 32; offset < 40; offset++) {
126 CHECK_EQ(0, r.Call(offset)); 126 CHECK_EQ(0, r.Call(offset));
127 } 127 }
128 128
129 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { 129 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) {
130 CHECK_EQ(0, r.Call(offset)); 130 CHECK_EQ(0, r.Call(offset));
131 } 131 }
132 } 132 }
133
134 TEST(Run_Wasm_LoadMemF32_oob_asm) {
135 TestingModule module;
136 module.origin = kAsmJsOrigin;
137 float* memory = module.AddMemoryElems<float>(8);
138 WasmRunner<float> r(&module, MachineType::Uint32());
139 module.RandomizeMemory(1112);
140
141 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0)));
142
143 memory[0] = 9999.5f;
144 CHECK_EQ(9999.5f, r.Call(0u));
145 // TODO(titzer): offset 29-31 should also be OOB.
146 for (uint32_t offset = 32; offset < 40; offset++) {
147 CHECK(std::isnan(r.Call(offset)));
148 }
149
150 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) {
151 CHECK(std::isnan(r.Call(offset)));
152 }
153 }
154
155 TEST(Run_Wasm_LoadMemF64_oob_asm) {
156 TestingModule module;
157 module.origin = kAsmJsOrigin;
158 double* memory = module.AddMemoryElems<double>(8);
159 WasmRunner<double> r(&module, MachineType::Uint32());
160 module.RandomizeMemory(1112);
161
162 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0)));
163
164 memory[0] = 9799.5;
165 CHECK_EQ(9799.5, r.Call(0u));
166 memory[1] = 11799.25;
167 CHECK_EQ(11799.25, r.Call(8u));
168 // TODO(titzer): offset 57-63 should also be OOB.
169 for (uint32_t offset = 64; offset < 80; offset++) {
170 CHECK(std::isnan(r.Call(offset)));
171 }
172
173 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) {
174 CHECK(std::isnan(r.Call(offset)));
175 }
176 }
177
178 TEST(Run_Wasm_StoreMemI32_oob_asm) {
ahaas 2016/05/11 11:10:14 Is there a reason why you skip the tests for the o
179 TestingModule module;
180 module.origin = kAsmJsOrigin;
181 int32_t* memory = module.AddMemoryElems<int32_t>(8);
182 WasmRunner<int32_t> r(&module, MachineType::Uint32(), MachineType::Uint32());
183 module.RandomizeMemory(1112);
184
185 BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0),
186 WASM_GET_LOCAL(1)));
187
188 memory[0] = 7777;
189 CHECK_EQ(999999, r.Call(0u, 999999));
190 CHECK_EQ(999999, memory[0]);
191 // TODO(titzer): offset 29-31 should also be OOB.
192 for (uint32_t offset = 32; offset < 40; offset++) {
193 CHECK_EQ(8888, r.Call(offset, 8888));
194 }
195
196 for (uint32_t offset = 0x10000000; offset < 0xF0000000; offset += 0x1000000) {
197 CHECK_EQ(7777, r.Call(offset, 7777));
198 }
199 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698