Closed Bug 1686755 Opened 4 months ago Closed 3 months ago

WebAssembly.Table API doesn't support ref-types correctly

Categories

(Core :: Javascript: WebAssembly, defect, P3)

defect

Tracking

()

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: rhunt, Assigned: rhunt)

Details

Attachments

(1 file)

See [1] and [2].

let object = new Number(3);
let table = new WebAssembly.Table({"element": "externref", initial: 3}, object);
table.length; // 3
table.get(0); // fails: should be object, is currently null

[1] https://searchfox.org/mozilla-central/rev/2a24205479519e70c0574929f45730d285141584/js/src/wasm/WasmJS.cpp#2724
[2] https://webassembly.github.io/reference-types/js-api/index.html#dom-table-table

This is more general and impacts table.grow() and table.set() as well.

Summary: WebAssembly.Table constructor ignores default value parameter → WebAssembly.Table API doesn't support ref-types correctly

The following operations on WebAssembly.Table can take an optional parameter.

  • new WebAssembly.Table(descr, <initvalue>)
  • table.set(index, <newvalue>)
  • table.grow(delta, <initvalue>)

Current support is inconsistent. The constructor didn't support the parameter at
all, the setter always required the parameter, and grow supported the parameter
as optional.

One additional wrinkle is that the behavior for an omitted parameter depends on
the table type. funcref (and presumably eqref, but unspecified) defaults to null
when the value is not specified. externref is to default to undefined. [1]

This behavior is odd, but appears to be required to be backwards compatible with
respect to funcref, and to be consistent with JS semantics of optional parameters
meaning 'undefined' for externref.

[1] https://webassembly.github.io/reference-types/js-api/index.html#dom-table-table

Pushed by rhunt@eqrion.net:
https://hg.mozilla.org/integration/autoland/rev/b1a8aed5a1da
Add support for optional parameters in WebAssembly.Table API. r=lth

Backed out changeset b1a8aed5a1da (bug 1686755) for /wasm/jsapi/table/* wpt failures.

Push with failures: https://treeherder.mozilla.org/jobs?repo=autoland&group_state=expanded&selectedTaskRun=ZdPaniVrTmuV9RnEOZFhBg.0&test_paths=wasm%2Fjsapi%2Ftable&fromchange=64fcfd386e9241994a5f332e9c96d4abd677e29a&tochange=87d16e2aa8a174d3c844521edd21dbf000b30506

Backout link: https://hg.mozilla.org/integration/autoland/rev/87d16e2aa8a174d3c844521edd21dbf000b30506

Failure log: https://treeherder.mozilla.org/logviewer?job_id=327407146&repo=autoland&lineNumber=2168

[task 2021-01-21T21:01:50.340Z] 21:01:50     INFO - TEST-START | /wasm/jsapi/table/constructor-reftypes.tentative.any.html
[task 2021-01-21T21:01:50.710Z] 21:01:50     INFO - 
[task 2021-01-21T21:01:50.710Z] 21:01:50     INFO - TEST-PASS | /referrer-policy/4K-1/gen/top.meta/unset/script-tag.http.html | Referrer Policy: Expects stripped-referrer for script-tag to same-http origin and keep-origin redirection from http context. 
[task 2021-01-21T21:01:50.710Z] 21:01:50     INFO - TEST-PASS | /referrer-policy/4K-1/gen/top.meta/unset/script-tag.http.html | Referrer Policy: Expects stripped-referrer for script-tag to same-http origin and no-redirect redirection from http context. 
[task 2021-01-21T21:01:50.710Z] 21:01:50     INFO - TEST-PASS | /referrer-policy/4K-1/gen/top.meta/unset/sharedworker-classic.http.html | Referrer Policy: Expects stripped-referrer for sharedworker-classic to same-http origin and keep-origin redirection from http context. 
[task 2021-01-21T21:01:50.710Z] 21:01:50     INFO - TEST-PASS | /referrer-policy/4K-1/gen/top.meta/unset/sharedworker-classic.http.html | Referrer Policy: Expects stripped-referrer for sharedworker-classic to same-http origin and no-redirect redirection from http context. 
[task 2021-01-21T21:01:50.710Z] 21:01:50     INFO - TEST-PASS | /referrer-policy/4K-1/gen/top.meta/unset/worker-classic.http.html | Referrer Policy: Expects stripped-referrer for worker-classic to same-http origin and keep-origin redirection from http context. 
[task 2021-01-21T21:01:50.710Z] 21:01:50     INFO - TEST-PASS | /referrer-policy/4K-1/gen/top.meta/unset/worker-classic.http.html | Referrer Policy: Expects stripped-referrer for worker-classic to same-http origin and no-redirect redirection from http context. 
[task 2021-01-21T21:01:50.710Z] 21:01:50     INFO - TEST-PASS | /referrer-policy/4K-1/gen/top.meta/unset/worker-module.http.html | Referrer Policy: Expects stripped-referrer for worker-module to same-http origin and keep-origin redirection from http context. 
[task 2021-01-21T21:01:50.711Z] 21:01:50     INFO - TEST-PASS | /referrer-policy/4K-1/gen/top.meta/unset/worker-module.http.html | Referrer Policy: Expects stripped-referrer for worker-module to same-http origin and no-redirect redirection from http context. 
[task 2021-01-21T21:01:50.711Z] 21:01:50     INFO - TEST-PASS | /referrer-policy/4K-1/gen/top.meta/unset/xhr.http.html | Referrer Policy: Expects stripped-referrer for xhr to same-http origin and keep-origin redirection from http context. 
[task 2021-01-21T21:01:50.711Z] 21:01:50     INFO - TEST-PASS | /referrer-policy/4K-1/gen/top.meta/unset/xhr.http.html | Referrer Policy: Expects stripped-referrer for xhr to same-http origin and no-redirect redirection from http context. 
[task 2021-01-21T21:01:50.711Z] 21:01:50     INFO - TEST-UNEXPECTED-PASS | /wasm/jsapi/table/constructor-reftypes.tentative.any.html | initialize externref table with default value - expected FAIL
[task 2021-01-21T21:01:50.711Z] 21:01:50     INFO - TEST-INFO | expected FAIL
[task 2021-01-21T21:01:50.712Z] 21:01:50     INFO - 
[task 2021-01-21T21:01:50.712Z] 21:01:50     INFO - TEST-PASS | /wasm/jsapi/table/constructor-reftypes.tentative.any.html | initialize table with a wrong element value 
[task 2021-01-21T21:01:50.712Z] 21:01:50     INFO - TEST-UNEXPECTED-PASS | /wasm/jsapi/table/constructor-reftypes.tentative.any.html | initialize anyfunc table with default value - expected FAIL
[task 2021-01-21T21:01:50.712Z] 21:01:50     INFO - TEST-INFO | expected FAIL
[task 2021-01-21T21:01:50.713Z] 21:01:50     INFO - 
[task 2021-01-21T21:01:50.713Z] 21:01:50     INFO - TEST-UNEXPECTED-PASS | /wasm/jsapi/table/constructor-reftypes.tentative.any.html | initialize anyfunc table with a bad default value - expected FAIL
[task 2021-01-21T21:01:50.713Z] 21:01:50     INFO - TEST-INFO | expected FAIL
[task 2021-01-21T21:01:50.816Z] 21:01:50     INFO - TEST-OK | /wasm/jsapi/table/constructor-reftypes.tentative.any.html | took 476ms
Flags: needinfo?(rhunt)

Ah, upstream tests for this behavior landed before my patch and then become unexpected passes, as I was testing off an older base revision.

Flags: needinfo?(rhunt)
Pushed by rhunt@eqrion.net:
https://hg.mozilla.org/integration/autoland/rev/c50d53e2bcac
Add support for optional parameters in WebAssembly.Table API. r=lth
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/27297 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 86 Branch
You need to log in before you can comment on or make changes to this bug.