Commit 4e20a62a authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Fix missing default value for anyref local.

R=titzer@chromium.org
TEST=mjsunit/wasm/anyref

Change-Id: Ia79c78038f6cc92f657ee1b48474323bde981155
Reviewed-on: https://chromium-review.googlesource.com/1201784Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55583}
parent 6041afe4
......@@ -597,6 +597,7 @@ class WasmGraphBuildingInterface {
return builder_->Float64Constant(0);
case kWasmS128:
return builder_->S128Zero();
case kWasmAnyRef:
case kWasmExceptRef:
return builder_->RefNull();
default:
......
......@@ -76,7 +76,6 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
.addBody([kExprRefNull])
.exportFunc();
const instance = builder.instantiate();
assertEquals(null, instance.exports.main());
......@@ -98,5 +97,17 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
assertEquals(0, instance.exports.main(undefined));
assertEquals(1, instance.exports.main(null));
assertEquals(0, instance.exports.main(print));
})();
(function testAnyRefLocalDefaultValue() {
print(arguments.callee.name);
const builder = new WasmModuleBuilder();
builder.addFunction('main', kSig_r_v)
.addBody([kExprGetLocal, 0])
.addLocals({anyref_count: 1})
.exportFunc();
const instance = builder.instantiate();
assertEquals(null, instance.exports.main());
})();
......@@ -569,6 +569,9 @@ class WasmModuleBuilder {
if (l.s128_count > 0) {
local_decls.push({count: l.s128_count, type: kWasmS128});
}
if (l.anyref_count > 0) {
local_decls.push({count: l.anyref_count, type: kWasmAnyRef});
}
if (l.except_count > 0) {
local_decls.push({count: l.except_count, type: kWasmExceptRef});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment