Heya, I'm trying to figure out how the whole component model works, including the canonical ABI (with the goal of compiling my own language to it). I've noticed a few things:
From https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md:
As an optimization, flags are represented as packed bit-vectors. Like variant discriminants, flags use the smallest integer that fits all the bits, falling back to sequences of i32s when there are more than 32 flags.
def alignment_flags(labels):
n = len(labels)
assert(0 < n <= 32)
if n <= 8: return 1
if n <= 16: return 2
return 4
First, that assert kinda confuses me. The whole case of "more than 32 flags" is not handled... anywhere, as far as I can tell. Additionally, why not use 64-bit integers too? They're primitives too. I would also say the same thing about Variant discriminators only using up to 32 bits, but honestly 4 billion variants seems like a pretty reasonable limit.
From https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md:
record-fields ::= record-field
| record-field ',' record-fields?
More generally, it seems like zero-sized types (and impossible types like variants with no variants) are impossible. I guess they're expected to be stripped by whatever generator that makes the WIT data?
I'll probably add further questions to this thread later, but that's it for now.
On zero-sized types you can see the rationale here: https://github.com/WebAssembly/component-model/pull/218
Interesting, thank you!
For flags we recently limited flags to 32 and haven't gotten to go back and update the abi representation
The plan is to increase the limit to 64 in the future and use i64 for the representation
Some minor extra changes are needed in the spec though to fully handle this
Ah, fair enough!
What are "refines"? They're mentioned when storing/loading variants, but not specified anywhere from what I can tell?
It looks like the feature was effectively "disabled" in https://github.com/WebAssembly/component-model/pull/255
Fair enough! Makes my life easier lol
https://github.com/WebAssembly/component-model/issues/414
Haha, I was thinking about opening an issue. Thanks!
Last updated: Nov 22 2024 at 16:03 UTC