Commit b01d2f45 authored by Andreas Haas's avatar Andreas Haas Committed by V8 LUCI CQ

Reland "[wasm][externref] Support default value for the table.set"

Reason for revert: There was an out-dated wpt test in blink that
failed after this CL. I adjusted the test expectations in https://chromium-review.googlesource.com/c/chromium/src/+/3162980 so that I can land this CL.

Original change's description:
> Revert "[wasm][externref] Support default value for the table.set"
>
> This reverts commit 6b578980.
>
> Reason for revert: Fails layout tests: https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Blink%20Linux/13751/overview
>
> Original change's description:
> > [wasm][externref] Support default value for the table.set
> >
> > WebAssembly.Table.set allows a default value instead of the second
> > parameter, which was not supported by V8 so far.
> >
> > R=​thibaudm@chromium.org
> >
> > Bug: v8:7581
> > Change-Id: I417790722b1cb4f854cd0056ecb8377c330c45fa
> > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3141574
> > Reviewed-by: Thibaud Michaud <thibaudm@chromium.org>
> > Commit-Queue: Andreas Haas <ahaas@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#76846}
>
> Bug: v8:7581
> Change-Id: I83d9be59c66ece3184b5708e5b8a3b401e4938ed
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3163257
> Auto-Submit: Clemens Backes <clemensb@chromium.org>
> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Cr-Commit-Position: refs/heads/main@{#76852}

Bug: v8:7581
Change-Id: I248f836ba4de2a4e3f3d80c00e6f1ac0b46a38d7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3162608
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76873}
parent ed045977
......@@ -1899,7 +1899,12 @@ void WebAssemblyTableSet(const v8::FunctionCallbackInfo<v8::Value>& args) {
return;
}
i::Handle<i::Object> element = Utils::OpenHandle(*args[1]);
i::Handle<i::Object> element;
if (args.Length() >= 2) {
element = Utils::OpenHandle(*args[1]);
} else {
element = i_isolate->factory()->null_value();
}
if (!i::WasmTableObject::IsValidElement(i_isolate, table_object, element)) {
thrower.TypeError(
"Argument 1 must be null or a WebAssembly function of type compatible "
......
......@@ -92,18 +92,19 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
assertEquals(table.get(2), testObject);
})();
function getDummy(val) {
let builder = new WasmModuleBuilder();
builder.addFunction('dummy', kSig_i_v)
.addBody([kExprI32Const, val])
.exportAs('dummy');
return builder.instantiate().exports.dummy;
}
(function TestFuncRefTableConstructorWithDefaultValue() {
print(arguments.callee.name);
const expected = 6;
let dummy =
(() => {
let builder = new WasmModuleBuilder();
builder.addFunction('dummy', kSig_i_v)
.addBody([kExprI32Const, expected])
.exportAs('dummy');
return builder.instantiate().exports.dummy;
})();
let dummy = getDummy(expected);
const argument = { "element": "anyfunc", "initial": 3 };
const table = new WebAssembly.Table(argument, dummy);
......@@ -112,3 +113,26 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
assertEquals(table.get(1)(), expected);
assertEquals(table.get(2)(), expected);
})();
(function TestExternFuncTableSetWithoutValue() {
print(arguments.callee.name);
const expected = 6;
const dummy = getDummy(expected);
const argument = { "element": "externref", "initial": 3 };
const table = new WebAssembly.Table(argument, dummy);
assertEquals(table.get(1)(), expected);
table.set(1);
assertEquals(table.get(1), null);
})();
(function TestExternRefTableSetWithoutValue() {
print(arguments.callee.name);
const testObject = {};
const argument = { "element": "externref", "initial": 3 };
const table = new WebAssembly.Table(argument, testObject);
assertEquals(table.get(1), testObject);
table.set(1);
assertEquals(table.get(1), null);
})();
......@@ -697,8 +697,6 @@ assertThrows(
() => set.call(), TypeError, /Receiver is not a WebAssembly.Table/);
assertThrows(
() => set.call({}), TypeError, /Receiver is not a WebAssembly.Table/);
assertThrows(
() => set.call(tbl1, 0), TypeError, /must be null or a WebAssembly function/);
assertThrows(
() => set.call(tbl1, undefined), TypeError,
/must be convertible to a valid number/);
......
......@@ -196,7 +196,6 @@ function assertTableIsValid(table, length) {
assertThrows(() => table.set(key, f), RangeError);
}
assertThrows(() => table.set(0), TypeError);
for (let val of [undefined, 0, "", {}, [], () => {}]) {
assertThrows(() => table.set(0, val), TypeError);
}
......
......@@ -21,7 +21,12 @@
'wpt/prototypes': [FAIL],
'wpt/table/constructor-types.tentative': [FAIL],
'wpt/table/grow-reftypes.tentative': [FAIL],
'wpt/table/set-reftypes.tentative': [FAIL],
# Outdated proposal tests.
'proposals/js-types/table/get-set': [FAIL],
'proposals/memory64/table/get-set': [FAIL],
'proposals/simd/table/get-set': [FAIL],
'proposals/tail-call/table/get-set': [FAIL],
# TODO(v8:10556): Remove sub-typing in the reference-types implementation
'proposals/js-types/constructor/instantiate': [FAIL],
......
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