Closed Bug 1561521 Opened 6 years ago Closed 5 years ago

Implement non-nullable references

Categories

(Core :: JavaScript: WebAssembly, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
81 Branch
Tracking Status
firefox81 --- fixed

People

(Reporter: lth, Assigned: rhunt)

References

Details

Attachments

(16 files, 2 obsolete files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review

As part of developing a separate proposal for typed function references, AR has proposed that the (ref T) syntax be reserved for non-nullable types and that (optref T) is instead used for nullable types. This will have some wide-ranging effects to text decoding and internally in the engine, I expect.

I'm going to take this bug.

Assignee: nobody → rhunt
Blocks: 1625595
Summary: (ref T) is non-nullable; (optref T) is nullable → Implement non-nullable references

Current patch stack that implements this [1]. Not posting for review while Lars is out.

[1] https://treeherder.mozilla.org/#/jobs?repo=try&revision=e7c40feff8f520ac9687e3bbcc69b63cad6398e7

When we removed subtyping, we kept the anyref text syntax as an alias of
externref. This commit completes the migration over to externref. A future
commit will switch uses of externref which should be anyref back.

Depends on D85052

The nullable reference syntax has changed from opt to null.

Depends on D85053

Wat now implements the module-linking proposal which includes one-level imports.

This commit removes tests of the text format which asserted these were not-valid.

Depends on D85054

The function-references spec refined ref.null to take a heaptype, which has a
slightly different text format for non-nullable references. This commit updates
tests to the new syntax.

Depends on D85055

The tests in this commit were switched to externref automatically, but
actually do require a universal supertype. This commit switches them back.

Depends on D85056

The tests in wasm/gc are a mix of reftypes/gc tests. This commit adds a
ref-types folder and moves relevant tests over.

Depends on D85057

Follow-up to the previous commit that moved these tests over to wasm/ref-types,
this commit renames the tests from 'anyref' to 'externref'.

Depends on D85059

This commit finishes the split of wasm/gc and wasm/ref-types tests by splitting
the disabled-ref.js test into a GC test and a ref-type test.

Depends on D85060

The following commits will change test messages for a couple tests, and this
commit fixes the breakage.

Depends on D85061

This commit renames the TypeCode/ValType/RefType occurrences of 'any' to 'extern'
to match what they actually represent. All public API facing occurrences have
already been switched to 'externref' so this should only be aligning the
internal names with their extern usage.

Comments that only apply to 'externref' code paths are renamed as well.

Depends on D85062

wasm::Table uses wasm::TableKind to determine the element type of the table,
which makes it difficult to extend tables to support more reference types. This
commit drops TableKind in favor of directly storing the element RefType, along
with a flag for whether this table is forAsmJS, which influences the funcref
ABI. RefType is extended to return the existing TableRepr enum, which indicates
the memory representation to use for the table.

wasm::ElemSegment uses wasm::ValType, which is a superset of the allowed
types of an elem segment. This commit switches it to use the proper
RefType class, and tweaks decoding.

Depends on D85063

This commit adds back an 'anyref' type pref'ed to only the GC proposal.

Depends on D85064

TypeCode::OptRef is currently used to represent any reference-typed value
for UnpackTypeCodeTypeAbstracted and IsReferenceType. I think it's actually
clearer to have this behind a named constant.

Depends on D85065

This commit adds decoding, validation, and JS-API type-checking for
non-nullable references.

Depends on D85066

ref.null takes a heaptype immediate. This is backwards compatible for
reference-types, but is a breaking change for the GC proposal. This commit
implements decoding for this refinement.

Depends on D85068

We need to report an error message here or else it will be reported as an OOM.

Depends on D85069

wasm::ToCString is losing relevance as we have more constructed types. This
commit removes ToCString and replaces all uses with wasm::ToString.

Depends on D85070

Attachment #9166419 - Attachment is obsolete: true
Attachment #9166411 - Attachment is obsolete: true
Pushed by rhunt@eqrion.net: https://hg.mozilla.org/integration/autoland/rev/41e46f9041bd Vendor the latest wat. r=lth https://hg.mozilla.org/integration/autoland/rev/fe600b71015f Tests: Automatically replace all uses of anyref with externref. r=lth https://hg.mozilla.org/integration/autoland/rev/b8c0cb8771b6 Tests: Rename (ref opt T) to (ref null T). r=lth https://hg.mozilla.org/integration/autoland/rev/a3abc2d14f78 Tests: Remove tests that assert one-level imports are invalid text. r=lth https://hg.mozilla.org/integration/autoland/rev/bc80a4372ba0 Tests: Rewrite (ref.null $reftype) to (ref.null $heaptype). r=lth https://hg.mozilla.org/integration/autoland/rev/a18f7f6320c4 Tests: Add wasm/ref-types/ folder, move non-gc specific tests there. r=lth https://hg.mozilla.org/integration/autoland/rev/1cb2561bf28f Tests: Rename ref-types/ tests that actually test externref. r=lth https://hg.mozilla.org/integration/autoland/rev/c827ecead12d Tests: Clean up disabled tests for gc/ref-types. r=lth https://hg.mozilla.org/integration/autoland/rev/3d3e3d124767 Tests: Change tests that rely on old test messages. r=lth https://hg.mozilla.org/integration/autoland/rev/538920d2d777 Rename TypeCode/ValType/RefType::Any to Extern. r=lth https://hg.mozilla.org/integration/autoland/rev/a7ad7e2b02c1 Generalize table/element code for future reference-types. r=lth https://hg.mozilla.org/integration/autoland/rev/cd847eba7f9c Add constant for abstracting reference-types values. r=lth https://hg.mozilla.org/integration/autoland/rev/00d2290648a7 Add non-nullable references. r=lth https://hg.mozilla.org/integration/autoland/rev/02ce4be46831 Refine ref.null decoding to decode heaptype instead of reftype. r=lth https://hg.mozilla.org/integration/autoland/rev/3d1a8283d2f8 Report error when decoding a value-type and there are no bytes. r=lth https://hg.mozilla.org/integration/autoland/rev/a850ff24c2ae Clean up wasm::ToString and drop wasm::ToCString. r=lth

Needed to rebase and fix compile error with new argument added to readValType.

Flags: needinfo?(rhunt)
Pushed by rhunt@eqrion.net: https://hg.mozilla.org/integration/autoland/rev/ea8dd38c1de0 Vendor the latest wat. r=lth https://hg.mozilla.org/integration/autoland/rev/6f317b53f2d9 Tests: Automatically replace all uses of anyref with externref. r=lth https://hg.mozilla.org/integration/autoland/rev/e131485d1705 Tests: Rename (ref opt T) to (ref null T). r=lth https://hg.mozilla.org/integration/autoland/rev/c05cad14170b Tests: Remove tests that assert one-level imports are invalid text. r=lth https://hg.mozilla.org/integration/autoland/rev/1d18a543d88e Tests: Rewrite (ref.null $reftype) to (ref.null $heaptype). r=lth https://hg.mozilla.org/integration/autoland/rev/c725d08d250e Tests: Add wasm/ref-types/ folder, move non-gc specific tests there. r=lth https://hg.mozilla.org/integration/autoland/rev/42ff212c7a38 Tests: Rename ref-types/ tests that actually test externref. r=lth https://hg.mozilla.org/integration/autoland/rev/30e6e85cc32c Tests: Clean up disabled tests for gc/ref-types. r=lth https://hg.mozilla.org/integration/autoland/rev/4fa52a0617de Tests: Change tests that rely on old test messages. r=lth https://hg.mozilla.org/integration/autoland/rev/7805ddfe2bfa Rename TypeCode/ValType/RefType::Any to Extern. r=lth https://hg.mozilla.org/integration/autoland/rev/8ce9bbcd26e3 Generalize table/element code for future reference-types. r=lth https://hg.mozilla.org/integration/autoland/rev/e055945526a2 Add constant for abstracting reference-types values. r=lth https://hg.mozilla.org/integration/autoland/rev/546d74acfb81 Add non-nullable references. r=lth https://hg.mozilla.org/integration/autoland/rev/008f196ed172 Refine ref.null decoding to decode heaptype instead of reftype. r=lth https://hg.mozilla.org/integration/autoland/rev/a72132acc190 Report error when decoding a value-type and there are no bytes. r=lth https://hg.mozilla.org/integration/autoland/rev/048c2bf91290 Clean up wasm::ToString and drop wasm::ToCString. r=lth
Regressions: 1659997
Regressions: 1663862
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: