[wasm][anyref] Add test for the default value of anyfunc locals

The implementation already exists, but the test doesn't.

R=titzer@chromium.org

Bug: v8:7581
Change-Id: I42e1b0a1c930ec4cc1f1701d5613828acab4fc30
Reviewed-on: https://chromium-review.googlesource.com/c/1426123
Reviewed-by: Ben Titzer <titzer@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59038}
This commit is contained in:
Andreas Haas 2019-01-22 11:31:06 +01:00 committed by Commit Bot
parent 61ea7c48ad
commit ed3738975b
2 changed files with 19 additions and 5 deletions

View File

@ -7,7 +7,7 @@
load("test/mjsunit/wasm/wasm-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js");
(function testAnyRefIdentityFunction() {
(function testAnyFuncIdentityFunction() {
print(arguments.callee.name);
const builder = new WasmModuleBuilder();
builder.addFunction('main', kSig_a_a)
@ -23,7 +23,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
instance.exports.main, instance.exports.main(instance.exports.main));
})();
(function testPassAnyRefToImportedFunction() {
(function testPassAnyFuncToImportedFunction() {
print(arguments.callee.name);
const builder = new WasmModuleBuilder();
const sig_index = builder.addType(kSig_v_a);
@ -42,7 +42,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
main(main);
})();
(function testPassAnyRefWithGCWithLocals() {
(function testPassAnyFuncWithGCWithLocals() {
print(arguments.callee.name);
const builder = new WasmModuleBuilder();
const ref_sig = builder.addType(kSig_v_a);
@ -78,7 +78,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
main(main);
})();
(function testPassAnyRefWithGC() {
(function testPassAnyFuncWithGC() {
print(arguments.callee.name);
const builder = new WasmModuleBuilder();
const ref_sig = builder.addType(kSig_v_a);
@ -102,7 +102,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
main(main);
})();
(function testPassAnyRefWithGCInWrapper() {
(function testPassAnyFuncWithGCInWrapper() {
print(arguments.callee.name);
const builder = new WasmModuleBuilder();
const kSig_a_iai = makeSig([kWasmI32, kWasmAnyFunc, kWasmI32], [kWasmAnyFunc]);
@ -123,3 +123,16 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
const result = main(triggerGCParam, main, triggerGCParam);
assertSame(main, result);
})();
(function testAnyFuncDefaultValue() {
print(arguments.callee.name);
const builder = new WasmModuleBuilder();
const sig_index = builder.addType(kSig_a_v);
builder.addFunction('main', sig_index)
.addLocals({anyfunc_count: 1})
.addBody([kExprGetLocal, 0])
.exportFunc();
const main = builder.instantiate().exports.main;
assertEquals(null, main());
})();

View File

@ -152,6 +152,7 @@ let kSig_v_r = makeSig([kWasmAnyRef], []);
let kSig_v_a = makeSig([kWasmAnyFunc], []);
let kSig_v_rr = makeSig([kWasmAnyRef, kWasmAnyRef], []);
let kSig_r_v = makeSig([], [kWasmAnyRef]);
let kSig_a_v = makeSig([], [kWasmAnyFunc]);
function makeSig(params, results) {
return {params: params, results: results};