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

Side by Side Diff: test/mjsunit/wasm/grow-memory.js

Issue 2373613004: [wasm] Fix bounds check of a store instruction after a grow_memory instruction (Closed)
Patch Set: Ben's review Created 4 years, 2 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/common/wasm/wasm-module-runner.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 // Flags: --expose-wasm --expose-gc --stress-compaction 5 // Flags: --expose-wasm --expose-gc --stress-compaction
6 6
7 load("test/mjsunit/wasm/wasm-constants.js"); 7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js"); 8 load("test/mjsunit/wasm/wasm-module-builder.js");
9 9
10 var kPageSize = 0x10000; 10 var kPageSize = 0x10000;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 319
320 val = 0; 320 val = 0;
321 321
322 for(offset = 0; offset <= (kPageSize - 1); offset++, val++) { 322 for(offset = 0; offset <= (kPageSize - 1); offset++, val++) {
323 assertEquals(val, peek()); 323 assertEquals(val, peek());
324 if (val == 255) val = 0; 324 if (val == 255) val = 0;
325 } 325 }
326 } 326 }
327 327
328 testGrowMemoryPreservesDataMemOp8(); 328 testGrowMemoryPreservesDataMemOp8();
329
330 function testGrowMemoryOutOfBoundsOffset() {
331 var builder = genGrowMemoryBuilder();
332 builder.addMemory(1, 1, false);
333 var module = builder.instantiate();
334 var offset, val;
335 function peek() { return module.exports.load(offset); }
336 function poke(value) { return module.exports.store(offset, value); }
337 function growMem(pages) { return module.exports.grow_memory(pages); }
338
339 offset = 3*kPageSize + 4;
340 assertTraps(kTrapMemOutOfBounds, poke);
341
342 assertEquals(1, growMem(1));
343 assertTraps(kTrapMemOutOfBounds, poke);
344
345 assertEquals(2, growMem(1));
346 assertTraps(kTrapMemOutOfBounds, poke);
347
348 assertEquals(3, growMem(1));
349
350 for (offset = 3*kPageSize; offset <= 4*kPageSize - 4; offset++) {
351 poke(0xaced);
352 assertEquals(0xaced, peek());
353 }
354
355 for (offset = 4*kPageSize - 3; offset <= 4*kPageSize + 4; offset++) {
356 assertTraps(kTrapMemOutOfBounds, poke);
357 }
358 }
359
360 testGrowMemoryOutOfBoundsOffset();
OLDNEW
« no previous file with comments | « test/common/wasm/wasm-module-runner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698