Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Are i32 and s32 the same? #86

Open
@alexcrichton

Description

@alexcrichton

The wasm core spec has the i32 type, and the interface types spec currently has the s32 (signed 32-bit integer) type. We also have the ability to connect the core wasm module's imports with an adapter function, such as:

(module 
    (import "" "" (func (param i32)))
    (@interface implement (import "" "") (param ??) (; ... ;)))

What should ?? be here? I can see one of two options here for validators to implement:

  • Both i32 and s32 are the same type. Interface adapters would only list interface types as parameters and results, and to match i32 you'd have to write s32. The downside of this approach is that we're unifying these two types and implicitly saying that any i32 coming from the core wasm module is signed, which isn't necessarily always correct. Additionally if the core wasm spec later gets a u16 type, for example, we'd have to be careful to also ensure that it unifies with the adapter type u16, but this may not be the easiest thing to do.

  • The i32 and s32 types are distinct, so they do not unify. This means that adapter functions must be able to list core wasm types as parameters/results. The upside of this approach is that the two worlds are a bit more sequestered from each other. The downside, however, is that you can export an adapter function with the i32 type as a parameter or a result, so we still have to define what an i32 is, which is probably going to be a signed integer.

Do others have thoughts on how best to tackle this? This is the same issue for i64 and s64. I don't think this is an issue for f32 and f64 since there's clearly only one way to interpret it there.

I would personally lean towards keeping these distinct types, but also having a validation pass that the exported adapter functions are not allowed to have core wasm type i32/i64 in their type signatures.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to 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