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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 .addBody([ | 51 .addBody([ |
52 kExprGetLocal, 0, | 52 kExprGetLocal, 0, |
53 kExprI32LoadMem, 0, 0]) | 53 kExprI32LoadMem, 0, 0]) |
54 .exportAs("foo"); | 54 .exportAs("foo"); |
55 i1 = builder.instantiate(); | 55 i1 = builder.instantiate(); |
56 } | 56 } |
57 | 57 |
58 var i2; | 58 var i2; |
59 { | 59 { |
60 let builder = new WasmModuleBuilder(); | 60 let builder = new WasmModuleBuilder(); |
61 builder.addMemory(1, 1, false); | |
62 builder.addImportedMemory("fil", "imported_mem"); | 61 builder.addImportedMemory("fil", "imported_mem"); |
63 builder.addFunction("bar", kSig_i_i) | 62 builder.addFunction("bar", kSig_i_i) |
64 .addBody([ | 63 .addBody([ |
65 kExprGetLocal, 0, | 64 kExprGetLocal, 0, |
66 kExprI32LoadMem, 0, 0]) | 65 kExprI32LoadMem, 0, 0]) |
67 .exportAs("bar"); | 66 .exportAs("bar"); |
68 i2 = builder.instantiate({fil: {imported_mem: i1.exports.exported_mem}}); | 67 i2 = builder.instantiate({fil: {imported_mem: i1.exports.exported_mem}}); |
69 } | 68 } |
70 | 69 |
71 let i32 = new Int32Array(i1.exports.exported_mem.buffer); | 70 let i32 = new Int32Array(i1.exports.exported_mem.buffer); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 .exportFunc(); | 375 .exportFunc(); |
377 builder.addFunction("grow", kSig_i_i) | 376 builder.addFunction("grow", kSig_i_i) |
378 .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero]) | 377 .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero]) |
379 .exportFunc(); | 378 .exportFunc(); |
380 instance = builder.instantiate(); | 379 instance = builder.instantiate(); |
381 assertEquals(kPageSize, instance.exports.exported_mem.buffer.byteLength); | 380 assertEquals(kPageSize, instance.exports.exported_mem.buffer.byteLength); |
382 assertEquals(1, instance.exports.grow(2)); | 381 assertEquals(1, instance.exports.grow(2)); |
383 assertEquals(3, instance.exports.mem_size()); | 382 assertEquals(3, instance.exports.mem_size()); |
384 assertEquals(3*kPageSize, instance.exports.exported_mem.buffer.byteLength); | 383 assertEquals(3*kPageSize, instance.exports.exported_mem.buffer.byteLength); |
385 })(); | 384 })(); |
OLD | NEW |