Closed Bug 1598009 Opened 5 years ago Closed 4 years ago

Generalize ValType reference types

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
mozilla73
Tracking Status
firefox73 --- fixed

People

(Reporter: lth, Assigned: lth)

References

Details

Attachments

(1 file, 2 obsolete files)

At the moment, we have AnyRef, FuncRef, NullRef, Ref, and I'm about to add ExnRef, and there's a lot of churn when we add a new one, and in the long term this is not going to be sustainable. Better to have a single "Ref" idea and some ways of talking about the opaque subtypes.

This will amount to removing ValType::AnyRef, ValType::FuncRef, and ValType::NullRef, and inserting special cases when those are handled differently from just ValType::Ref, but this is less often than you'd think, so generally this will be a simplification for a lot of the code.

We'll then introduce type-safe dispatch when we have a reftype. Code will still initially switch on the typecode and what is now multiple cases, one for each reftype, will move in under a secondary switch under the ValType::Ref case.

Attached file Bug 1598009 - Simplify ValType (obsolete) —
Attached file Bug 1598009 - Use the simpler ValType (obsolete) —

Depends on D54003

Those patches compile but I haven't tested them yet because my Linux install borked itself when I tried to upgrade to Fedora 31 this morning; I can't currently run jit_tests, something is really, really broken with Python. (Also, those patches are somewhat WIP, the style of the rewrite is not quite consistent.)

Blocks: 1599125

ValType is changed so that it only has one reference type, ValType::Ref.
That type now subsumes FuncRef, AnyRef, NullRef, GC ref types, and in
the future also exnref and other event references.

Most consumers of ValType need know nothing more than Ref, so we can
remove a lot of code in switches and importantly won't need to add code
many places in the future.

Other consumers do need to distinguish different types, and for them we
provide ValType::refType(), which returns a RefType value, which does
distinguish among the reference types. Thus most switches will first be
on ValType to get to ValType::Ref, and then in some cases further switch
on the refType to implement specialized code.

By and large, NullRef is being rolled into other Ref cases in this patch,
since Ref is frequently either the generic case ("what's the size of a
pointer?") or an error case ("no (ref T) support here yet"), this is going
to be a fine basis on which to implement further nullref support when we
need it.

The main cost for this in the present patch is that ValType retains its old
representation as a PackedTypeCode datum, and so to return ValType::Ref
from ValType::code() we need to perform an extra test. This test slows
down baseline single-threaded compilation of Zen Garden by 1-2%. I think
this is affordable. The alternative is to change the representation of
ValType so that those that are dependent on its PackedTypeCode representation
instead compute that; I judged that to be more brittle, but we can
revisit it if need be.

Attachment #9111268 - Attachment description: Bug 1598009 - Generalize ValType reference types. r?luke → Bug 1598009 - Generalize ValType reference types. r=luke
Attachment #9110314 - Attachment is obsolete: true
Attachment #9110315 - Attachment is obsolete: true
Pushed by lhansen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/6438be326666
Generalize ValType reference types.  r=luke
Flags: needinfo?(lhansen)
Pushed by lhansen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/348f26ca8d22
Generalize ValType reference types.  r=luke
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla73
Regressions: 1620748
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: