Closed Bug 1670104 Opened 5 years ago Closed 4 years ago

Add support for rtt based downcasting

Categories

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

task

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: rhunt, Assigned: rhunt)

References

Details

Attachments

(6 files)

Add support for the rtt value type, constructing types with an rtt, and downcasting values to an rtt.

Clean up from class-scoped enum to enum class and use switches as
appropriate.

The baseline compiler assumes the struct type given to an instruction
can be used to determine if the input value will be an inline or
outline struct. This is incorrect with subtyping. A test is added
and struct instructions are made dynamic upon the kind of TypedObject
given. Longer term we should optimize this further, but this was
simplest.

Depends on D104265

This commit replaces the struct.new instruction with the
struct.new_with_rtt and rtt.canon instructions. The new struct
instruction takes an rtt value as an operand. An rtt value is defined
to be the TypeDescr JSObject currently used by the constructor of
TypedObject's. This gives rtt values the same representation as
our reference values, although this doesn't need to be the case
in the future. rtt.canon is then implemented as a load of the
TypeDescr* stored in the TlsData global area for the specific
type index. When we implement type canonicalization, the
initialization of the instance will be changed to store the
canonical TypeDescr* for each type index in each slot.

The ValType representation is changed in this commit to support
the depth field of an rtt. As we're now packing 5 separate fields
in PackedTypeCode, the approach of manual shifts and masks isn't
scaling anymore. The PackedTypeCode representation is changed to
a POD union with bitfields to make access easier. The bit width
was increased to 64 to support a reasonable amount of depth
values. If we can decrease any of the other fields we may be
able to bring the size back down to 32.

Depends on D104266

This makes the purpose of these objects explicit.

Depends on D104267

This commit adds rtt.sub as an instruction to form new RttValue's with
an explicit subtyping chain. This is implemented as a link from sub
rtt to parent rtt. Validation ensures that chains can only be formed
from a T <: U. Each execution of an rtt.sub instruction creates a new
rtt value. This may be changed in the future to align with the proper
spec semantics.

With rtt.sub, we can now implement ref.test/ref.cast/br_on_cast
instructions that operate on structs with an rtt. The subtyping
check is implemented as an instance call performing a linear
search through rtt chains.

Depends on D104268

The struct.narrow instruction is no longer needed as we have the
ref.test/cast/br_on_null instructions.

Depends on D104269

Pushed by rhunt@eqrion.net: https://hg.mozilla.org/integration/autoland/rev/fb5c84ab0c29 Use switch and enum class for TypeDef::kind. r=lth https://hg.mozilla.org/integration/autoland/rev/65719287d608 Fix inline/outline TypedObject codegen. r=lth https://hg.mozilla.org/integration/autoland/rev/96a269bbe333 Add struct.new_with_rtt and rtt.canon. r=lth https://hg.mozilla.org/integration/autoland/rev/b2574104dc48 Rename TypeDescr to RttValue. r=lth https://hg.mozilla.org/integration/autoland/rev/c2ff9297a1ab Add rtt.sub and ref.test/ref.cast/br_on_cast. r=lth https://hg.mozilla.org/integration/autoland/rev/a49689e0154a Remove struct.narrow instruction and use ref.cast. r=lth
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: