Index: test/mjsunit/wasm/indirect-calls.js |
diff --git a/test/mjsunit/wasm/indirect-calls.js b/test/mjsunit/wasm/indirect-calls.js |
index b07ce0d58a8448de9058438318181b5da9c98698..c49361cfd299117efdddc4785ab765b2793cd9b8 100644 |
--- a/test/mjsunit/wasm/indirect-calls.js |
+++ b/test/mjsunit/wasm/indirect-calls.js |
@@ -73,7 +73,7 @@ module = (function () { |
kExprGetLocal, 0, |
kExprCallIndirect, sig_i_ii |
]) |
- .exportFunc() |
+ .exportFunc(); |
builder.appendToTable([mul.index, add.index, popcnt.index, main.index]); |
return builder.instantiate({mul: function(a, b) { return a * b | 0; }}); |
@@ -85,10 +85,7 @@ assertTraps(kTrapFuncSigMismatch, "module.exports.main(2, 12, 33)"); |
assertTraps(kTrapFuncSigMismatch, "module.exports.main(3, 12, 33)"); |
assertTraps(kTrapFuncInvalid, "module.exports.main(4, 12, 33)"); |
- |
-module = (function () { |
- var builder = new WasmModuleBuilder(); |
- |
+function AddFunctions(builder) { |
var mul = builder.addFunction("mul", kSig_i_ii) |
.addBody([ |
kExprGetLocal, 0, // -- |
@@ -107,6 +104,14 @@ module = (function () { |
kExprGetLocal, 1, // -- |
kExprI32Sub // -- |
]); |
+ return {mul: mul, add: add, sub: sub}; |
+} |
+ |
+ |
+module = (function () { |
+ var builder = new WasmModuleBuilder(); |
+ |
+ var f = AddFunctions(builder); |
builder.addFunction("main", kSig_i_ii) |
.addBody([ |
kExprI32Const, 33, // -- |
@@ -115,7 +120,7 @@ module = (function () { |
kExprCallIndirect, 0]) // -- |
.exportAs("main"); |
- builder.appendToTable([mul.index, add.index, sub.index]); |
+ builder.appendToTable([f.mul.index, f.add.index, f.sub.index]); |
return builder.instantiate(); |
})(); |
@@ -133,24 +138,7 @@ assertTraps(kTrapFuncInvalid, "module.exports.main(12, 3)"); |
function instanceWithTable(base, length) { |
var builder = new WasmModuleBuilder(); |
- var mul = builder.addFunction("mul", kSig_i_ii) |
- .addBody([ |
- kExprGetLocal, 0, // -- |
- kExprGetLocal, 1, // -- |
- kExprI32Mul // -- |
- ]); |
- var add = builder.addFunction("add", kSig_i_ii) |
- .addBody([ |
- kExprGetLocal, 0, // -- |
- kExprGetLocal, 1, // -- |
- kExprI32Add // -- |
- ]); |
- var sub = builder.addFunction("sub", kSig_i_ii) |
- .addBody([ |
- kExprGetLocal, 0, // -- |
- kExprGetLocal, 1, // -- |
- kExprI32Sub // -- |
- ]); |
+ var f = AddFunctions(builder); |
builder.addFunction("main", kSig_i_ii) |
.addBody([ |
kExprI32Const, 33, // -- |
@@ -160,7 +148,7 @@ assertTraps(kTrapFuncInvalid, "module.exports.main(12, 3)"); |
.exportAs("main"); |
builder.setFunctionTableLength(length); |
- builder.addFunctionTableInit(base, false, [add.index, sub.index, mul.index]); |
+ builder.addFunctionTableInit(base, false, [f.add.index, f.sub.index, f.mul.index]); |
return builder.instantiate(); |
} |
@@ -187,24 +175,7 @@ assertTraps(kTrapFuncInvalid, "module.exports.main(12, 3)"); |
var builder = new WasmModuleBuilder(); |
- var mul = builder.addFunction("mul", kSig_i_ii) |
- .addBody([ |
- kExprGetLocal, 0, // -- |
- kExprGetLocal, 1, // -- |
- kExprI32Mul // -- |
- ]); |
- var add = builder.addFunction("add", kSig_i_ii) |
- .addBody([ |
- kExprGetLocal, 0, // -- |
- kExprGetLocal, 1, // -- |
- kExprI32Add // -- |
- ]); |
- var sub = builder.addFunction("sub", kSig_i_ii) |
- .addBody([ |
- kExprGetLocal, 0, // -- |
- kExprGetLocal, 1, // -- |
- kExprI32Sub // -- |
- ]); |
+ var f = AddFunctions(builder); |
builder.addFunction("main", kSig_i_ii) |
.addBody([ |
kExprI32Const, 33, // -- |
@@ -215,7 +186,7 @@ assertTraps(kTrapFuncInvalid, "module.exports.main(12, 3)"); |
builder.setFunctionTableLength(10); |
var g = builder.addImportedGlobal("base", undefined, kAstI32); |
- builder.addFunctionTableInit(g, true, [mul.index, add.index, sub.index]); |
+ builder.addFunctionTableInit(g, true, [f.mul.index, f.add.index, f.sub.index]); |
var module = new WebAssembly.Module(builder.toBuffer()); |