Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Portability hazards of i31ref with non-native engines #543

@kb-1000

Description

@kb-1000

If I understand this right, i31ref is supposed to be implemented by the engine as a tagged pointer.

As mentioned in https://github.com/WebAssembly/gc/blob/master/proposals/gc/Overview.md#unboxed-scalars, a larger type could cause portability hazards by forcing the engine to do hidden allocations or use inefficient representations on some platforms.

However, something that was apparently missed (at least, my search in this repo's discussions did not reveal anything, forgive me if I'm mistaken) is the possibility of the runtime itself not having a concept of pointers or tagged pointers as native code does. Java for example has "pointers" as in object references, but those cannot encode integers without boxing into an Integer object, so a WASM engine written in and/or targeting Java would probably have to do that.

Similarly, .NET has reference types, which as far as I'm aware also cannot encode integers without boxing. Unlike Java, it has actual pointers too, but those are not tracked by the .NET GC.

(for somewhat related reasons I'm also not a fan of how the wasm test suite handles externref, but that's a different topic)

I'm not sure how to proceed from there... Is this an acceptable price to pay? What would alternatives look like?

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