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

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

Issue 2440953002: [wasm] Binary 0xD: update encoding of opcodes, types, and add immediates. (Closed)
Patch Set: Update after moving copysign 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
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 --stress-compaction 5 // Flags: --expose-wasm --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;
11 11
12 function genGrowMemoryBuilder() { 12 function genGrowMemoryBuilder() {
13 var builder = new WasmModuleBuilder(); 13 var builder = new WasmModuleBuilder();
14 builder.addFunction("grow_memory", kSig_i_i) 14 builder.addFunction("grow_memory", kSig_i_i)
15 .addBody([kExprGetLocal, 0, kExprGrowMemory]) 15 .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero])
16 .exportFunc(); 16 .exportFunc();
17 builder.addFunction("load", kSig_i_i) 17 builder.addFunction("load", kSig_i_i)
18 .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) 18 .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0])
19 .exportFunc(); 19 .exportFunc();
20 builder.addFunction("store", kSig_i_ii) 20 builder.addFunction("store", kSig_i_ii)
21 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0, 21 .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32StoreMem, 0, 0,
22 kExprGetLocal, 1]) 22 kExprGetLocal, 1])
23 .exportFunc(); 23 .exportFunc();
24 builder.addFunction("load16", kSig_i_i) 24 builder.addFunction("load16", kSig_i_i)
25 .addBody([kExprGetLocal, 0, kExprI32LoadMem16U, 0, 0]) 25 .addBody([kExprGetLocal, 0, kExprI32LoadMem16U, 0, 0])
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // UINT32_MIN, which cannot be represented as SMI. 318 // UINT32_MIN, which cannot be represented as SMI.
319 assertEquals(-1, growMem(-1)); 319 assertEquals(-1, growMem(-1));
320 }; 320 };
321 321
322 testGrowMemoryTrapsWithNonSmiInput(); 322 testGrowMemoryTrapsWithNonSmiInput();
323 323
324 function testGrowMemoryCurrentMemory() { 324 function testGrowMemoryCurrentMemory() {
325 var builder = genGrowMemoryBuilder(); 325 var builder = genGrowMemoryBuilder();
326 builder.addMemory(1, 1, false); 326 builder.addMemory(1, 1, false);
327 builder.addFunction("memory_size", kSig_i_v) 327 builder.addFunction("memory_size", kSig_i_v)
328 .addBody([kExprMemorySize]) 328 .addBody([kExprMemorySize, kMemoryZero])
329 .exportFunc(); 329 .exportFunc();
330 var module = builder.instantiate(); 330 var module = builder.instantiate();
331 function growMem(pages) { return module.exports.grow_memory(pages); } 331 function growMem(pages) { return module.exports.grow_memory(pages); }
332 function MemSize() { return module.exports.memory_size(); } 332 function MemSize() { return module.exports.memory_size(); }
333 assertEquals(1, MemSize()); 333 assertEquals(1, MemSize());
334 assertEquals(1, growMem(1)); 334 assertEquals(1, growMem(1));
335 assertEquals(2, MemSize()); 335 assertEquals(2, MemSize());
336 } 336 }
337 337
338 testGrowMemoryCurrentMemory(); 338 testGrowMemoryCurrentMemory();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 442
443 testGrowMemoryOutOfBoundsOffset(); 443 testGrowMemoryOutOfBoundsOffset();
444 444
445 function testGrowMemoryOutOfBoundsOffset2() { 445 function testGrowMemoryOutOfBoundsOffset2() {
446 var builder = new WasmModuleBuilder(); 446 var builder = new WasmModuleBuilder();
447 builder.addMemory(16, 128, false); 447 builder.addMemory(16, 128, false);
448 builder.addFunction("main", kSig_v_v) 448 builder.addFunction("main", kSig_v_v)
449 .addBody([ 449 .addBody([
450 kExprI32Const, 20, 450 kExprI32Const, 20,
451 kExprI32Const, 29, 451 kExprI32Const, 29,
452 kExprGrowMemory, 452 kExprGrowMemory, kMemoryZero,
453 kExprI32StoreMem, 0, 0xFF, 0xFF, 0xFF, 0x3a 453 kExprI32StoreMem, 0, 0xFF, 0xFF, 0xFF, 0x3a
454 ]) 454 ])
455 .exportAs("main"); 455 .exportAs("main");
456 var module = builder.instantiate(); 456 var module = builder.instantiate();
457 assertTraps(kTrapMemOutOfBounds, module.exports.main); 457 assertTraps(kTrapMemOutOfBounds, module.exports.main);
458 } 458 }
459 459
460 testGrowMemoryOutOfBoundsOffset2(); 460 testGrowMemoryOutOfBoundsOffset2();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698