| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // |
| 2 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 4 | 5 |
| 5 // Flags: --expose-wasm | 6 // Flags: --expose-wasm |
| 7 // Flags: --wasm-jit-prototype |
| 6 | 8 |
| 7 load("test/mjsunit/wasm/wasm-constants.js"); | 9 load("test/mjsunit/wasm/wasm-constants.js"); |
| 8 load("test/mjsunit/wasm/wasm-module-builder.js"); | 10 load("test/mjsunit/wasm/wasm-module-builder.js"); |
| 9 | 11 |
| 10 var module = (function () { | 12 var module = (function () { |
| 11 var builder = new WasmModuleBuilder(); | 13 var builder = new WasmModuleBuilder(); |
| 12 | 14 |
| 13 var sig_index = builder.addType(kSig_i_ii); | 15 var sig_index = builder.addType(kSig_i_ii); |
| 16 builder.addPadFunctionTable(512); |
| 14 builder.addImport("add", sig_index); | 17 builder.addImport("add", sig_index); |
| 15 builder.addFunction("add", sig_index) | 18 builder.addFunction("add", sig_index) |
| 16 .addBody([ | 19 .addBody([ |
| 17 kExprGetLocal, 0, kExprGetLocal, 1, kExprCallImport, kArity2, 0 | 20 kExprGetLocal, 0, kExprGetLocal, 1, kExprCallImport, kArity2, 0 |
| 18 ]); | 21 ]); |
| 19 builder.addFunction("sub", sig_index) | 22 builder.addFunction("sub", sig_index) |
| 20 .addBody([ | 23 .addBody([ |
| 21 kExprGetLocal, 0, // -- | 24 kExprGetLocal, 0, // -- |
| 22 kExprGetLocal, 1, // -- | 25 kExprGetLocal, 1, // -- |
| 23 kExprI32Sub, // -- | 26 kExprI32Sub, // -- |
| (...skipping 15 matching lines...) Expand all Loading... |
| 39 assertFalse(module === undefined); | 42 assertFalse(module === undefined); |
| 40 assertFalse(module === null); | 43 assertFalse(module === null); |
| 41 assertFalse(module === 0); | 44 assertFalse(module === 0); |
| 42 assertEquals("object", typeof module.exports); | 45 assertEquals("object", typeof module.exports); |
| 43 assertEquals("function", typeof module.exports.main); | 46 assertEquals("function", typeof module.exports.main); |
| 44 | 47 |
| 45 assertEquals(5, module.exports.main(1, 12, 7)); | 48 assertEquals(5, module.exports.main(1, 12, 7)); |
| 46 assertEquals(19, module.exports.main(0, 12, 7)); | 49 assertEquals(19, module.exports.main(0, 12, 7)); |
| 47 | 50 |
| 48 assertTraps(kTrapFuncSigMismatch, "module.exports.main(2, 12, 33)"); | 51 assertTraps(kTrapFuncSigMismatch, "module.exports.main(2, 12, 33)"); |
| 49 assertTraps(kTrapFuncInvalid, "module.exports.main(3, 12, 33)"); | 52 assertTraps(kTrapFuncSigMismatch, "module.exports.main(4, 12, 33)"); |
| 53 assertTraps(kTrapFuncSigMismatch, "module.exports.main(511, 12, 33)"); |
| 54 assertTraps(kTrapFuncInvalid, "module.exports.main(512, 12, 33)"); |
| 55 assertTraps(kTrapFuncInvalid, "module.exports.main(1025, 12, 33)"); |
| 56 assertTraps(kTrapFuncInvalid, "module.exports.main(-1, 12, 33)"); |
| OLD | NEW |