OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 // |
| 5 // Flags: --expose-wasm |
| 6 |
| 7 load('test/mjsunit/wasm/wasm-constants.js'); |
| 8 load('test/mjsunit/wasm/wasm-module-builder.js'); |
| 9 |
| 10 let module1 = (() => { |
| 11 let builder = new WasmModuleBuilder(); |
| 12 builder.addMemory(1, 1); |
| 13 builder.addFunction('load', kSig_i_i) |
| 14 .addBody([kExprI32Const, 0, kExprI32LoadMem, 0, 0]) |
| 15 .exportAs('load'); |
| 16 return new WebAssembly.Module(builder.toBuffer()); |
| 17 })(); |
| 18 |
| 19 let module2 = (() => { |
| 20 let builder = new WasmModuleBuilder(); |
| 21 builder.addMemory(1, 1); |
| 22 builder.addImport('A', 'load', kSig_i_i); |
| 23 builder.addExportOfKind('load', kExternalFunction, 0); |
| 24 return new WebAssembly.Module(builder.toBuffer()); |
| 25 })(); |
| 26 |
| 27 let instance1 = new WebAssembly.Instance(module1); |
| 28 let instance2 = new WebAssembly.Instance(module2, {A: instance1.exports}); |
| 29 |
| 30 assertEquals(0, instance2.exports.load()); |
OLD | NEW |