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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 .exportFunc(); | 375 .exportFunc(); |
376 builder.addFunction("grow", kSig_i_i) | 376 builder.addFunction("grow", kSig_i_i) |
377 .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero]) | 377 .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero]) |
378 .exportFunc(); | 378 .exportFunc(); |
379 instance = builder.instantiate(); | 379 instance = builder.instantiate(); |
380 assertEquals(kPageSize, instance.exports.exported_mem.buffer.byteLength); | 380 assertEquals(kPageSize, instance.exports.exported_mem.buffer.byteLength); |
381 assertEquals(1, instance.exports.grow(2)); | 381 assertEquals(1, instance.exports.grow(2)); |
382 assertEquals(3, instance.exports.mem_size()); | 382 assertEquals(3, instance.exports.mem_size()); |
383 assertEquals(3*kPageSize, instance.exports.exported_mem.buffer.byteLength); | 383 assertEquals(3*kPageSize, instance.exports.exported_mem.buffer.byteLength); |
384 })(); | 384 })(); |
| 385 |
| 386 (function TestImportTooLarge() { |
| 387 print("TestImportTooLarge"); |
| 388 let builder = new WasmModuleBuilder(); |
| 389 builder.addImportedMemory("m", "m", 1, 2); |
| 390 |
| 391 // initial size is too large |
| 392 assertThrows(() => builder.instantiate({m: {m: new WebAssembly.Memory({initial
: 3, maximum: 3})}})); |
| 393 |
| 394 // maximum size is too large |
| 395 assertThrows(() => builder.instantiate({m: {m: new WebAssembly.Memory({initial
: 1, maximum: 4})}})); |
| 396 |
| 397 // no maximum |
| 398 assertThrows(() => builder.instantiate({m: {m: new WebAssembly.Memory({initial
: 1})}})); |
| 399 })(); |
OLD | NEW |