Index: test/mjsunit/wasm/jit-single-function.js |
diff --git a/test/mjsunit/wasm/default-func-call.js b/test/mjsunit/wasm/jit-single-function.js |
similarity index 52% |
copy from test/mjsunit/wasm/default-func-call.js |
copy to test/mjsunit/wasm/jit-single-function.js |
index 14567d3844595ee896ea58c0a4b2b7f50abe2628..bb907f5d0df0005379dd02301a68c686fa3d02cc 100644 |
--- a/test/mjsunit/wasm/default-func-call.js |
+++ b/test/mjsunit/wasm/jit-single-function.js |
@@ -1,10 +1,9 @@ |
// Copyright 2015 the V8 project authors. All rights reserved. |
-// |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// Flags: --expose-wasm |
// Flags: --wasm-jit-prototype |
Mircea Trofin
2016/07/12 02:49:13
why flip these switches?
ritesht
2016/07/13 23:58:45
This basically enables the flag to gate the experi
Mircea Trofin
2016/07/14 00:16:15
Sorry, I meant, why is wasm-jit-prototype on top n
ritesht
2016/07/14 00:18:38
Ok. Fixed.
|
+// Flags: --expose-wasm |
load("test/mjsunit/wasm/wasm-constants.js"); |
load("test/mjsunit/wasm/wasm-module-builder.js"); |
@@ -12,45 +11,56 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); |
var module = (function () { |
var builder = new WasmModuleBuilder(); |
+ var kSig_i_iiiii = makeSig([kAstI32, kAstI32, kAstI32, kAstI32, kAstI32], [kAstI32]); |
John
2016/07/13 19:56:59
this line is too long.
ritesht
2016/07/13 23:58:45
Done.
|
var sig_index = builder.addType(kSig_i_ii); |
- builder.addPadFunctionTable(512); |
+ |
+ builder.addMemory(1, 1, true); |
+ var wasm_bytes_sub = [ |
+ 1, 2, kAstI32, |
+ kExprGetLocal, 0, |
+ kExprGetLocal, 1, |
+ kExprI32Sub |
+ ]; |
+ builder.addDataSegment(0, wasm_bytes_sub, false); |
+ |
+ var wasm_bytes_mul = [ |
+ 1, 2, kAstI32, |
+ kExprGetLocal, 0, |
+ kExprGetLocal, 1, |
+ kExprI32Mul |
+ ]; |
+ builder.addDataSegment(8, wasm_bytes_mul, false); |
+ |
+ builder.addPadFunctionTable(10); |
builder.addImport("add", sig_index); |
builder.addFunction("add", sig_index) |
.addBody([ |
kExprGetLocal, 0, kExprGetLocal, 1, kExprCallImport, kArity2, 0 |
]); |
- builder.addFunction("sub", sig_index) |
- .addBody([ |
- kExprGetLocal, 0, // -- |
- kExprGetLocal, 1, // -- |
- kExprI32Sub, // -- |
- ]); |
- builder.addFunction("main", kSig_i_iii) |
+ builder.addFunction("main", kSig_i_iiiii) |
.addBody([ |
kExprGetLocal, 0, |
kExprGetLocal, 1, |
kExprGetLocal, 2, |
+ kExprJITSingleFunction, sig_index, |
+ kExprGetLocal, 2, |
+ kExprGetLocal, 3, |
+ kExprGetLocal, 4, |
kExprCallIndirect, kArity2, sig_index |
]) |
.exportFunc() |
- builder.appendToTable([0, 1, 2]); |
+ builder.appendToTable([0, 1]); |
return builder.instantiate({add: function(a, b) { return a + b | 0; }}); |
})(); |
-// Check the module exists. |
+// Check that the module exists |
assertFalse(module === undefined); |
assertFalse(module === null); |
assertFalse(module === 0); |
assertEquals("object", typeof module.exports); |
assertEquals("function", typeof module.exports.main); |
-assertEquals(5, module.exports.main(1, 12, 7)); |
-assertEquals(19, module.exports.main(0, 12, 7)); |
- |
-assertTraps(kTrapFuncSigMismatch, "module.exports.main(2, 12, 33)"); |
-assertTraps(kTrapFuncSigMismatch, "module.exports.main(4, 12, 33)"); |
-assertTraps(kTrapFuncSigMismatch, "module.exports.main(511, 12, 33)"); |
-assertTraps(kTrapFuncInvalid, "module.exports.main(512, 12, 33)"); |
-assertTraps(kTrapFuncInvalid, "module.exports.main(1025, 12, 33)"); |
-assertTraps(kTrapFuncInvalid, "module.exports.main(-1, 12, 33)"); |
+// args: base offset, size of func_bytes, index, param1, param2 |
+assertEquals(13, module.exports.main(0, 8, 3, 45, 32)); // JIT sub function |
+assertEquals(187, module.exports.main(8, 8, 6, 17, 11)); // JIT sub function |