Are i32
and s32
the same? #86
Description
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
ands32
are the same type. Interface adapters would only list interface types as parameters and results, and to matchi32
you'd have to writes32
. The downside of this approach is that we're unifying these two types and implicitly saying that anyi32
coming from the core wasm module is signed, which isn't necessarily always correct. Additionally if the core wasm spec later gets au16
type, for example, we'd have to be careful to also ensure that it unifies with the adapter typeu16
, but this may not be the easiest thing to do. -
The
i32
ands32
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 thei32
type as a parameter or a result, so we still have to define what ani32
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