Skip to content

Overloading of RMW and wait operations #114

@tlively

Description

@tlively

As @rossberg brought up in #110 (review) and as we discussed at the recent CG meeting, the current design overloads the new RMW and wait operations to work with several types. For example struct.atomic.rmw.add x y works on both i32 and i64 fields. This does not violate our principal types properties because the type of the field is determined by the type and field immediates x and y. However, the execution of the instruction needs to handle addition on both i32 and i64 fields in a way we have historically avoided, by e.g. making i32.add and i64.add separate instructions. (Although it is the case that separating i32.add and i64.add is necessary to preserve principal types as well.)

The "no overloading" rule is also already somewhat fuzzy in practice. Instructions like ref.is_null are parametric over all heap types, so need to handle comparisons with potentially different null values and representations for each heap type hierarchy. Instructions like struct.get obviously have different implementations for different field types in real implementations, even if the spec can be written to handle all types generically.

So I argue that the "no overloading" rule is not buying us much in practice, and it would be well worth dropping it to reduce the need to introduce dozens of new instructions. We won't immediately descend into chaos because we still have the principal types properties imposing order on the instruction set.

In the CG meeting, @titzer raised the point that in-place interpreters need to do extra work when instructions are overloaded. @kmiller68 said he would have to go see how this would affect the JSC interpreter. My question is: given that these interpreters already have to handle e.g. struct.get, is it really worth adding dozens of instructions to save them this work on instructions that will be much less common than struct.get?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions