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