Skip to content

Consider replacing the ValType enum with an opaque 32-bit integer. #2370

@alexcrichton

Description

@alexcrichton

In #2295 the ValType enum is going to be inflated from 4 bytes to 8 bytes due to the new representation of RefType. Previously RefType was [u8; 3] and in that PR it's changing to u32. There's some benchmarks and discussion of this at #2295 (comment). The tl;dr; is that the idea of having ValType and ValTypePacked is not going to work because it inevitably leads to runtime conversions between the two which is slower than just having one.

I wanted to open this though to at least record this as an issue. I don't believe that in Rust today the tradeoff of losing match-exhaustiveness is worth it. Perhaps in the future this may change (e.g. the speedups are worth it) or maybe some future Rust feature comes along (e.g. pattern types) which enables using enum and also having a 4-byte ValType. In the meantime though I think 8-byte ValType is the best we can do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wasmparserRelated to the binary format of WebAssembly (wasmparser)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions