This repository was archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Avoid the need for computing lubs/glbs #42
Comments
I am on board with the proposed solution here.
Just to make this clearer for the broader audience: trivial subtyping for numeric types in wasm means no subtyping between any of the numeric types: there are no implicit conversions or subsumption. |
@titzer, right, with the one exception that, technically, a bottom type would of course be a subtype of all numeric types. But that's what actually makes this work. |
moz-v2v-gh
pushed a commit
to mozilla/gecko-dev
that referenced
this issue
Sep 26, 2019
…ypes. r=lth Issue: WebAssembly/reference-types#42 The existing select instruction contains no typing information. As more complicated types are added, we will need to infer the result type as the least upper bound of the operands. This may be a complicated operation, so we will restrict the existing untyped instruction to operate only on the MVP value types, and add a new select instruction with type information. Differential Revision: https://phabricator.services.mozilla.com/D45863 --HG-- extra : moz-landing-system : lando
moz-v2v-gh
pushed a commit
to mozilla/gecko-dev
that referenced
this issue
Sep 26, 2019
…=lth This commit renames TVar to represent the new Bottom type introduced in the reference types spec. Issue: WebAssembly/reference-types#42 The only observable spec change so far is in validation of br_table which requires that the operand type is a subtype of all label types. With a bottom type, this may allow more code to validate than before. Differential Revision: https://phabricator.services.mozilla.com/D46641 --HG-- extra : moz-landing-system : lando
moz-v2v-gh
pushed a commit
to mozilla/gecko-dev
that referenced
this issue
Sep 26, 2019
Issue: WebAssembly/reference-types#42 Text: https://webassembly.github.io/reference-types/core/text/instructions.html#parametric-instructions Binary: https://webassembly.github.io/reference-types/core/binary/instructions.html#parametric-instructions This commit adds 'select t*'. The instruction is allowed to encode/decode multiple result types for compatibility with multi-value, but only one is currently supported. Differential Revision: https://phabricator.services.mozilla.com/D45866 --HG-- extra : moz-landing-system : lando
xeonchen
pushed a commit
to xeonchen/gecko
that referenced
this issue
Sep 26, 2019
…ypes. r=lth Issue: WebAssembly/reference-types#42 The existing select instruction contains no typing information. As more complicated types are added, we will need to infer the result type as the least upper bound of the operands. This may be a complicated operation, so we will restrict the existing untyped instruction to operate only on the MVP value types, and add a new select instruction with type information. Differential Revision: https://phabricator.services.mozilla.com/D45863
xeonchen
pushed a commit
to xeonchen/gecko
that referenced
this issue
Sep 26, 2019
…=lth This commit renames TVar to represent the new Bottom type introduced in the reference types spec. Issue: WebAssembly/reference-types#42 The only observable spec change so far is in validation of br_table which requires that the operand type is a subtype of all label types. With a bottom type, this may allow more code to validate than before. Differential Revision: https://phabricator.services.mozilla.com/D46641
xeonchen
pushed a commit
to xeonchen/gecko
that referenced
this issue
Sep 26, 2019
Issue: WebAssembly/reference-types#42 Text: https://webassembly.github.io/reference-types/core/text/instructions.html#parametric-instructions Binary: https://webassembly.github.io/reference-types/core/binary/instructions.html#parametric-instructions This commit adds 'select t*'. The instruction is allowed to encode/decode multiple result types for compatibility with multi-value, but only one is currently supported. Differential Revision: https://phabricator.services.mozilla.com/D45866
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-comments-removed
that referenced
this issue
Oct 4, 2019
…ypes. r=lth Issue: WebAssembly/reference-types#42 The existing select instruction contains no typing information. As more complicated types are added, we will need to infer the result type as the least upper bound of the operands. This may be a complicated operation, so we will restrict the existing untyped instruction to operate only on the MVP value types, and add a new select instruction with type information. Differential Revision: https://phabricator.services.mozilla.com/D45863 UltraBlame original commit: 16bba4255fff3cc6b10f43fb82d6d5e126509077
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-comments-removed
that referenced
this issue
Oct 4, 2019
…=lth This commit renames TVar to represent the new Bottom type introduced in the reference types spec. Issue: WebAssembly/reference-types#42 The only observable spec change so far is in validation of br_table which requires that the operand type is a subtype of all label types. With a bottom type, this may allow more code to validate than before. Differential Revision: https://phabricator.services.mozilla.com/D46641 UltraBlame original commit: c1a81d62ead5ea21db50b90dd116b73abbed4e03
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-comments-removed
that referenced
this issue
Oct 4, 2019
Issue: WebAssembly/reference-types#42 Text: https://webassembly.github.io/reference-types/core/text/instructions.html#parametric-instructions Binary: https://webassembly.github.io/reference-types/core/binary/instructions.html#parametric-instructions This commit adds 'select t*'. The instruction is allowed to encode/decode multiple result types for compatibility with multi-value, but only one is currently supported. Differential Revision: https://phabricator.services.mozilla.com/D45866 UltraBlame original commit: b01aab238aa0293e21f204be90eea391e35c71ec
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-wordified-and-comments-removed
that referenced
this issue
Oct 4, 2019
…ypes. r=lth Issue: WebAssembly/reference-types#42 The existing select instruction contains no typing information. As more complicated types are added, we will need to infer the result type as the least upper bound of the operands. This may be a complicated operation, so we will restrict the existing untyped instruction to operate only on the MVP value types, and add a new select instruction with type information. Differential Revision: https://phabricator.services.mozilla.com/D45863 UltraBlame original commit: 16bba4255fff3cc6b10f43fb82d6d5e126509077
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-wordified-and-comments-removed
that referenced
this issue
Oct 4, 2019
…=lth This commit renames TVar to represent the new Bottom type introduced in the reference types spec. Issue: WebAssembly/reference-types#42 The only observable spec change so far is in validation of br_table which requires that the operand type is a subtype of all label types. With a bottom type, this may allow more code to validate than before. Differential Revision: https://phabricator.services.mozilla.com/D46641 UltraBlame original commit: c1a81d62ead5ea21db50b90dd116b73abbed4e03
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-wordified-and-comments-removed
that referenced
this issue
Oct 4, 2019
Issue: WebAssembly/reference-types#42 Text: https://webassembly.github.io/reference-types/core/text/instructions.html#parametric-instructions Binary: https://webassembly.github.io/reference-types/core/binary/instructions.html#parametric-instructions This commit adds 'select t*'. The instruction is allowed to encode/decode multiple result types for compatibility with multi-value, but only one is currently supported. Differential Revision: https://phabricator.services.mozilla.com/D45866 UltraBlame original commit: b01aab238aa0293e21f204be90eea391e35c71ec
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-wordified
that referenced
this issue
Oct 5, 2019
…ypes. r=lth Issue: WebAssembly/reference-types#42 The existing select instruction contains no typing information. As more complicated types are added, we will need to infer the result type as the least upper bound of the operands. This may be a complicated operation, so we will restrict the existing untyped instruction to operate only on the MVP value types, and add a new select instruction with type information. Differential Revision: https://phabricator.services.mozilla.com/D45863 UltraBlame original commit: 16bba4255fff3cc6b10f43fb82d6d5e126509077
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-wordified
that referenced
this issue
Oct 5, 2019
…=lth This commit renames TVar to represent the new Bottom type introduced in the reference types spec. Issue: WebAssembly/reference-types#42 The only observable spec change so far is in validation of br_table which requires that the operand type is a subtype of all label types. With a bottom type, this may allow more code to validate than before. Differential Revision: https://phabricator.services.mozilla.com/D46641 UltraBlame original commit: c1a81d62ead5ea21db50b90dd116b73abbed4e03
gecko-dev-updater
pushed a commit
to marco-c/gecko-dev-wordified
that referenced
this issue
Oct 5, 2019
Issue: WebAssembly/reference-types#42 Text: https://webassembly.github.io/reference-types/core/text/instructions.html#parametric-instructions Binary: https://webassembly.github.io/reference-types/core/binary/instructions.html#parametric-instructions This commit adds 'select t*'. The instruction is allowed to encode/decode multiple result types for compatibility with multi-value, but only one is currently supported. Differential Revision: https://phabricator.services.mozilla.com/D45866 UltraBlame original commit: b01aab238aa0293e21f204be90eea391e35c71ec
Was fixed by $43. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
With subtyping, and lacking sufficient type annotations, some operations may require the validation algorithm to compute the least upper bound (lub) or greatest lower bond (glb) of two types to accurately infer an output or input type, respectively. In current Wasm, this comes up with two instructions:
select
: the result type is the lub of the two operand typesbr_table
: the operand type is the glb of the label types(Similar issues would come up with ops like
dup
orpick
, which might also require a glb of the use edges when the input type is not known a priori, i.e., in unreachable code.)While lub and glb are easy to compute with the tiny subtyping lattice introduced by this proposal itself, it will not stay that way with future reference extensions (e.g., typed functions or GC types), which will make it both more complex and more costly. In accordance with the design goals for Wasm validation, we should make sure to avoid the need for computing lubs/glbs altogether.
Possible Solution:
For
select
, the only option seems to be introducing a new type-annotated version, and restricting the pre-existing unannotated version to numeric types for backwards compatibility (fortunately, only trivial subtyping is available on numeric types).Without going into technical details, the glb cases (
br_table
,dup
,pick
) can most easily be avoided by adding a bottom type to the type system (a least type in the subtype lattice). Effectively, this is already present in the MVP validation algorithm, to type unreachable stack slots; promoting it to a proper type itself is a natural generalisation in the presence of subtyping. (Note that this type doesn't need not to be expressible in programs, it's sufficient if it exists in the typing rules.)The text was updated successfully, but these errors were encountered: