Skip to content

Group reference types in binary format #4773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kripken opened this issue Jul 6, 2022 · 0 comments
Closed

Group reference types in binary format #4773

kripken opened this issue Jul 6, 2022 · 0 comments

Comments

@kripken
Copy link
Member

kripken commented Jul 6, 2022

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant