-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reconcile reftype short hands wrt nullability #266
Comments
Yes, please. I'm always forgetting which ones are null and which are not. I suggest that we make them all nullable because writing |
Makes sense to me. Other opinions? |
We are already committed to |
I agree with making all the shorthands nullable. |
(Moving my comment from the PR) I think it would be nice to get some data: take as many GC-using Wasm modules as you can find, and count how often they use Note that I'm not opposed to flipping every single default if need be. I'm just saying it'd be good to have a solid reason for doing so. With Wasm being a compilation target, convenience, aesthetics, and symmetry/regularity/uniformity matter far less than they do in human-written languages, and hence are not convincing arguments for making design decisions. |
FWIW, I've mostly been thinking of this as a text format change and I only recently connected the dots and realized there would be a binary encoding change as well. I just measured the effect of never using the binary shorthands on the 10MB optimized J2CL module and it only increased code size by 13 bytes. I assume that's not representative of all use cases, but after seeing that I would certainly be in favor of making the text shorthands nullable and removing the binary shorthands that haven't already been standardized. Or removing the new text shorthands as well. |
Interesting. Does J2CL use non-concrete types or i31 much, though? I did the same experiments with removing all (new) binary shorthands and saw a +0.34% size increase on the total size of the Waml test suite modules and +0.64% for the Wob test suite. On the other hand, #277 costed +7 bytes in total on the Waml test suite, and made no difference whatsoever on the Wob one. With everything else being pretty much equal like this, I'd let consistency take precedent. |
No, I don't think so. Anyway, given the relatively small effect this choice seems to have on code size, I'd also be in favor of choosing the most self-consistent design. Since this does come with a backward-incompatible binary format change, we'll have to wait to batch up the change with other incompatible changes and won't be able to implement the change right away, but that's not a big deal. |
How likely are we to eventually regret having spent encoding space on these shorthands? We can use the entire range of 7 bits (where 0x7f..0x79 and 0x70..0x66 are used as of this proposal, and 0x65..0x0 are still free), right? In that case I think the answer is "unlikely", so no concerns there. |
We have the range from 0x40..0x7f for single-byte type constructors (since they have to be negative sleb's). That's quite a few for types. But we can go beyond a single byte, so it's effectively unlimited (or at least any negative s33). I would want to avoid overlapping constructors, even across different type sorts, since there may be reasons to unify some of the sorts later. Under that constraint, the shorthands don't occupy additional coding space. |
@jakobkummerow, do you have any remaining concerns about landing #277? |
Based on the data you collected (thanks for that!), I'm not convinced that adding new shorthands is useful, so if it was up to me, I'd just drop them. But I don't feel strongly about it, so you may consider this a "Neutral" vote. Note that this is a breaking change, so we'll have to be careful about logistics when we update implementations (both toolchains and engines). |
Anybody wants to approve #277 then? |
#277 was merged, so I'll go ahead and close this. |
Currently, i31ref, dataref, and arrayref expand to non-null, while anyref, eqref, funcref, and externref are null. Should probably be more principled.
The text was updated successfully, but these errors were encountered: