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

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

Issue 2344853002: [wasm] Do proper bounds checking in the wasm interpreter for grow memory. (Closed)
Patch Set: Created 4 years, 3 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-interpreter.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 <memory> 9 #include <memory>
10 10
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 int32_t value = 2335; 299 int32_t value = 2335;
300 TestingModule module(kExecuteInterpreted); 300 TestingModule module(kExecuteInterpreted);
301 WasmRunner<int32_t> r(&module, MachineType::Uint32()); 301 WasmRunner<int32_t> r(&module, MachineType::Uint32());
302 module.AddMemory(WasmModule::kPageSize); 302 module.AddMemory(WasmModule::kPageSize);
303 BUILD(r, WASM_BLOCK(WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index), 303 BUILD(r, WASM_BLOCK(WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index),
304 WASM_I32V(value)), 304 WASM_I32V(value)),
305 WASM_GROW_MEMORY(WASM_GET_LOCAL(0)), 305 WASM_GROW_MEMORY(WASM_GET_LOCAL(0)),
306 WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index)))); 306 WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index))));
307 CHECK_EQ(value, r.Call(1)); 307 CHECK_EQ(value, r.Call(1));
308 } 308 }
309
310 TEST(GrowMemoryInvalidSize) {
311 {
312 // Grow memory by an invalid amount without initial memory.
313 TestingModule module(kExecuteInterpreted);
314 WasmRunner<int32_t> r(&module, MachineType::Uint32());
315 BUILD(r, WASM_BLOCK(WASM_GROW_MEMORY(WASM_GET_LOCAL(0))));
316 CHECK_EQ(-1, r.Call(1048575));
317 }
318 {
319 // Grow memory by an invalid amount without initial memory.
320 TestingModule module(kExecuteInterpreted);
321 WasmRunner<int32_t> r(&module, MachineType::Uint32());
322 module.AddMemory(WasmModule::kPageSize);
323 BUILD(r, WASM_BLOCK(WASM_GROW_MEMORY(WASM_GET_LOCAL(0))));
324 CHECK_EQ(-1, r.Call(1048575));
325 }
326 }
327
309 } // namespace wasm 328 } // namespace wasm
310 } // namespace internal 329 } // namespace internal
311 } // namespace v8 330 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-interpreter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698