Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
FPIIM-449
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/test/mjsunit/wasm/default-func-call.js b/test/mjsunit/wasm/default-func-call.js
new file mode 100644
index 0000000..14567d3
--- /dev/null
+++ b/test/mjsunit/wasm/default-func-call.js
@@ -0,0 +1,56 @@
+// 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
+
+load("test/mjsunit/wasm/wasm-constants.js");
+load("test/mjsunit/wasm/wasm-module-builder.js");
+
+var module = (function () {
+ var builder = new WasmModuleBuilder();
+
+ var sig_index = builder.addType(kSig_i_ii);
+ builder.addPadFunctionTable(512);
+ 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)
+ .addBody([
+ kExprGetLocal, 0,
+ kExprGetLocal, 1,
+ kExprGetLocal, 2,
+ kExprCallIndirect, kArity2, sig_index
+ ])
+ .exportFunc()
+ builder.appendToTable([0, 1, 2]);
+
+ return builder.instantiate({add: function(a, b) { return a + b | 0; }});
+})();
+
+// Check 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)");