-
Notifications
You must be signed in to change notification settings - Fork 40
[spec/interpreter/test] Reintroduce bottom type #116
Conversation
This (re)introduces a value type that has no fixed(-per-engine) size. It also violates the property that two value types are (effective) subtypes only if they have the same size, or that distinctly-sized value types have no common (effective) subtypes. It also has the same property that The purpose of this change seems to be solely the same purpose as WebAssembly/design#1379. So WebAssembly/design#1379 would make this change completely redundant. And having both introduces warts, like If we don't want the reference types proposal to wait on resolving the discussion in WebAssembly/design#1379, I already outlined how to fix the type-checker in #111 without requiring any changes to the proposal. |
The fix you proposed would require introducing a new form of auxiliary type into the typing algorithm that has not been needed before. Consequently, it is a larger and more intrusive change to implementations than this PR, with potentially more loose ends. The solution here has already been in engines until recently, so we know it's implementable and we know that it is a minimal change to what engines have been doing all along. We also know that the value size argument is not an actual problem, otherwise engines would be having it in the MVP already. The property you're alluding to never held in algorithmic checking, so there is no regression in that regard. We certainly do not want to block on something like WebAssembly/design#1379, which will likely take months to resolve, since the implementation impact across engines is not clear at all. |
+1 on not blocking on a long, drawn-out discussion about unreachable code. |
Both introduce an auxiliary type. #111's fix requires no changes to the spec. The main difference between the two is whether |
No, please read what I said and see the diff. This PR requires no new type in the algorithmic formulation that's used in every engine I'm aware of. It requires zero changes to their type representation, and merely a change to how they check br_table, which reverts back to what it was before #87. |
document/core/valid/instructions.rst
Outdated
The types describe the required input stack with argument values of types :math:`t_1^\ast` that an instruction pops off | ||
and the provided output stack with result values of types :math:`t_2^\ast` that it pushes back. | ||
|
||
.. _match-opdtype: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the text here would be more understandable with a clarification what opd
stands for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reordered and changed wording to clarify.
Oh shoot, I forgot to say that I'm fine with this change if it's just a holdover until WebAssembly/design#1379. My concerns are about long-term issues, and WebAssembly/design#1379 would resolve those concerns before the long-term issues have a chance to manifest. |
This CL implements the spec change done in WebAssembly/reference-types#116. R=manoskouk@chromium.org Bug: v8:10994 Change-Id: Ic2b4e0a52af225b5640447fe051a9c36e6d41be2 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2534818 Commit-Queue: Andreas Haas <ahaas@chromium.org> Reviewed-by: Manos Koukoutos <manoskouk@chromium.org> Cr-Commit-Position: refs/heads/master@{#71260}
This addresses #111, which was a collateral damage of removing subtyping in #87. The fix here is to reintroduce the bottom operand type as before, though without the general subtype relation. This change
More far-reaching revisits of the Wasm typing machinery, as e.g. discussed in WebAssembly/design#1379, ought to be considered as separate proposals. The fix here is conservative over such broader relaxations.
Background:
In [spec/interpreter/test] Avoid lubs and glbs #43, we added the type-annotated version of
select
and introduced a simple bottom type. This was in order to avoid the need for computing lubs and glbs during type-checking with subtypes. The bottom type elevated the "unknown" type present in algorithmic validation to a proper citizen of the semantics, and as such required almost no changes to implementations. See also the presentation from the 2019/05 F2F meeting, where this was discussed.In Remove subtyping #87, we removed subtyping (based on discussions in the 2020/03 F2F meeting). This also removed the bottom type, because short of subtyping, it no longer worked and seemed no longer necessary. However, one consequence we overlooked is a corner case that occurs in the interference with the new restriction on the
select
instruction, as noted by @RossTate in Typeability Bug in Reference Implementation #111. That restriction has to remain, in order for typing ofselect
to be future-proof.This PR hence reintroduces the bottom type in the simplest possible fashion, without reliance on a general subtype relation. For implementations, this boils down to reverting the change in the typing of the
br_table
instruction that came with Remove subtyping #87, and possibly tweaks to typingselect
(depending on whether they currently accept the example in Typeability Bug in Reference Implementation #111 or not). Both can be seen in the changes to algorithm.rst and the reference interpreter in this PR.The PR is forward-compatible with the typing rules in the function references proposal.