Skip to content

Group reference types in binary format #4773

@kripken

Description

@kripken

We already group by type in the binary format in BinaryInstWriter::mapLocalsAndEmitHeader. That means we don't emit locals like this:

(local $a i32)
(local $b f64)
(local $c i32)

Instead all i32s would be in sequence:

(local $a i32)
(local $c i32)
(local $b f64)

We do the same for reference types, but we could also easily group them separately from MVP types. That is, we could avoid this:

(local $a (ref null $A)
(local $b i32)
(local $c (ref null $C)

This would be better even though the reference types are different:

(local $a (ref null $A)
(local $c (ref null $C)
(local $b i32)

The benefit is that VMs have work to do that may be different for references versus MVP types. Putting all reference types in one contiguous block would let the VM clear them out more efficiently. For more details see WebAssembly/function-references#44 (comment)

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