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

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

Issue 2548223002: [wasm] Update WasmMemoryObject correctly when module memory is exported. (Closed)
Patch Set: Rebase Created 4 years 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/mjsunit/regress/wasm/regression-670683.js ('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 5 // Flags: --expose-wasm
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 (function TestOne() { 10 (function TestOne() {
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 assertEquals(expected_pages, instances[i].exports.mem_size()); 359 assertEquals(expected_pages, instances[i].exports.mem_size());
360 } 360 }
361 } 361 }
362 var current_mem_size = 1; 362 var current_mem_size = 1;
363 for (var i = 0; i < 10; i++) { 363 for (var i = 0; i < 10; i++) {
364 function grow(pages) { return instances[i].exports.grow(pages); } 364 function grow(pages) { return instances[i].exports.grow(pages); }
365 assertEquals(current_mem_size, instances[i].exports.grow(1)); 365 assertEquals(current_mem_size, instances[i].exports.grow(1));
366 verify_mem_size(++current_mem_size); 366 verify_mem_size(++current_mem_size);
367 } 367 }
368 })(); 368 })();
369
370 (function TestExportGrow() {
371 print("TestExportGrow");
372 let builder = new WasmModuleBuilder();
373 builder.addMemory(1, 5, true);
374 builder.exportMemoryAs("exported_mem");
375 builder.addFunction("mem_size", kSig_i_v)
376 .addBody([kExprMemorySize, kMemoryZero])
377 .exportFunc();
378 builder.addFunction("grow", kSig_i_i)
379 .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero])
380 .exportFunc();
381 instance = builder.instantiate();
382 assertEquals(kPageSize, instance.exports.exported_mem.buffer.byteLength);
383 assertEquals(1, instance.exports.grow(2));
384 assertEquals(3, instance.exports.mem_size());
385 assertEquals(3*kPageSize, instance.exports.exported_mem.buffer.byteLength);
386 })();
OLDNEW
« no previous file with comments | « test/mjsunit/regress/wasm/regression-670683.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698