Closed dhil closed 1 month ago
I think typeidx
makes more sense here, since it is supposed to be the index of a type. Tags also use typeidx
in a very similar situation. If we need to encode more information in the future, we can use a different introductory encoding, just like we do for shared
heap types, for example. s33
(or rather heaptype
) would only make sense if we were going to allow abstract heap types like func
in this location, but that's not the case.
@tlively, tag types have a reserved zero byte as an extension point. Of course, we could do the same here. The space for type codes is already becoming somewhat crowded, so we may want to avoid more duplicate/flattened type codes where we can.
FWIW, I used the s33
encoding in the implementation in wasm-tools (https://github.com/bytecodealliance/wasm-tools/pull/1802) to stay in sync with the reference interpreter (which I currently use as an assembler for my experiments).
I have a slight preference for adding the zero byte for future extension, but I wouldn't want to block progress on this.
@tlively how about we go ahead and merge this PR in order to maintain consistency between the spec and the various implementations, but also create an issue so that we don't forget to return to this question later?
Sounds perfect, thanks!
@tlively how about we go ahead and merge this PR in order to maintain consistency between the spec and the various implementations, but also create an issue so that we don't forget to return to this question later?
I've opened issue #97 to track this question.
There is a small inconsistency between the reference implementation in #84 and the explainer. In the explainer we write that the type index
$ft
oncont $ft
should be encoded as anu32
in the binary format. However, the reference interpreter actually encodes it ass33
, similarly to how concrete heap types are encoded.I do not have a strong preference for either encoding, but I suppose one can argue that the
s33
approach is more forward compatible in the sense that we can encode additional metadata.