From ed3738975b2f171b4aa44c45726f38e1a0b03268 Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Tue, 22 Jan 2019 11:31:06 +0100 Subject: [PATCH] [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 Commit-Queue: Andreas Haas Cr-Commit-Position: refs/heads/master@{#59038} --- test/mjsunit/wasm/anyfunc.js | 23 ++++++++++++++++++----- test/mjsunit/wasm/wasm-constants.js | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/test/mjsunit/wasm/anyfunc.js b/test/mjsunit/wasm/anyfunc.js index 8c5bfacd72..45ae2a48ef 100644 --- a/test/mjsunit/wasm/anyfunc.js +++ b/test/mjsunit/wasm/anyfunc.js @@ -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()); +})(); diff --git a/test/mjsunit/wasm/wasm-constants.js b/test/mjsunit/wasm/wasm-constants.js index 7583d39a9b..ccb691c844 100644 --- a/test/mjsunit/wasm/wasm-constants.js +++ b/test/mjsunit/wasm/wasm-constants.js @@ -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};