| 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 var debug = false; |
| 11 |
| 10 (function BasicTest() { | 12 (function BasicTest() { |
| 11 var module = new WasmModuleBuilder(); | 13 var module = new WasmModuleBuilder(); |
| 12 module.addMemory(1, 2, false); | 14 module.addMemory(1, 2, false); |
| 13 module.addFunction("foo", [kAstI32]) | 15 module.addFunction("foo", [kAstI32]) |
| 14 .addBody([kExprI8Const, 11]) | 16 .addBody([kExprI8Const, 11]) |
| 15 .exportAs("blarg"); | 17 .exportAs("blarg"); |
| 16 | 18 |
| 17 var buffer = module.toBuffer(debug); | 19 var buffer = module.toBuffer(debug); |
| 18 var instance = _WASMEXP_.instantiateModule(buffer); | 20 var instance = _WASMEXP_.instantiateModule(buffer); |
| 19 assertEquals(11, instance.exports.blarg()); | 21 assertEquals(11, instance.exports.blarg()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 module.addMemory(1, 1, false); | 81 module.addMemory(1, 1, false); |
| 80 module.addFunction("load", [kAstI32, kAstI32]) | 82 module.addFunction("load", [kAstI32, kAstI32]) |
| 81 .addBody([kExprI32LoadMem, 0, kExprGetLocal, 0]) | 83 .addBody([kExprI32LoadMem, 0, kExprGetLocal, 0]) |
| 82 .exportAs("load"); | 84 .exportAs("load"); |
| 83 module.addDataSegment(0, [9, 9, 9, 9], true); | 85 module.addDataSegment(0, [9, 9, 9, 9], true); |
| 84 | 86 |
| 85 var buffer = module.toBuffer(debug); | 87 var buffer = module.toBuffer(debug); |
| 86 var instance = _WASMEXP_.instantiateModule(buffer); | 88 var instance = _WASMEXP_.instantiateModule(buffer); |
| 87 assertEquals(151587081, instance.exports.load(0)); | 89 assertEquals(151587081, instance.exports.load(0)); |
| 88 })(); | 90 })(); |
| OLD | NEW |