OLD | NEW |
---|---|
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 Loading... | |
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(1, instance.exports.grow(2)); | |
383 assertEquals(3, instance.exports.mem_size()); | |
384 assertEquals(kPageSize, instance.exports.exported_mem.buffer.byteLength); | |
gdeepti
2016/12/04 17:48:37
As per my understanding, this should be the correc
titzer
2016/12/05 09:40:54
Yes, that's right.
gdeepti
2016/12/05 17:31:07
Thanks! Bot failures fixed with latest patch.
| |
385 })(); | |
OLD | NEW |