diff options
author | Thomas Lively <tlively@google.com> | 2024-05-15 12:05:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-15 12:05:33 -0700 |
commit | ef4b57c2a491a2193435dccdc9305f6a79965715 (patch) | |
tree | 491562613897a0c467a456e05e8a92234509e02c /src/ir/effects.h | |
parent | 8a5dc1880d962a7c31a7a219720be343a0866e5c (diff) | |
download | binaryen-ef4b57c2a491a2193435dccdc9305f6a79965715.tar.gz binaryen-ef4b57c2a491a2193435dccdc9305f6a79965715.tar.bz2 binaryen-ef4b57c2a491a2193435dccdc9305f6a79965715.zip |
[Strings] Remove stringview types and instructions (#6579)
The stringview types from the stringref proposal have three irregularities that
break common invariants and require pervasive special casing to handle properly:
they are supertypes of `none` but not subtypes of `any`, they cannot be the
targets of casts, and they cannot be used to construct nullable references. At
the same time, the stringref proposal has been superseded by the imported
strings proposal, which does not have these irregularities. The cost of
maintaing and improving our support for stringview types is no longer worth the
benefit of supporting them.
Simplify the code base by entirely removing the stringview types and related
instructions that do not have analogues in the imported strings proposal and do
not make sense in the absense of stringviews.
Three remaining instructions, `stringview_wtf16.get_codeunit`,
`stringview_wtf16.slice`, and `stringview_wtf16.length` take stringview operands
in the stringref proposal but cannot be removed because they lower to operations
from the imported strings proposal. These instructions are changed to take
stringref operands in Binaryen IR, and to allow a graceful upgrade path for
users of these instructions, the text and binary parsers still accept but ignore
`string.as_wtf16`, which is the instruction used to convert stringrefs to
stringviews. The binary writer emits code sequences that use scratch locals and `string.as_wtf16` to keep the output valid.
Future PRs will further align binaryen with the imported strings proposal
instead of the stringref proposal, for example by making `string` a subtype of
`extern` instead of a subtype of `any` and by removing additional instructions
that do not have analogues in the imported strings proposal.
Diffstat (limited to 'src/ir/effects.h')
-rw-r--r-- | src/ir/effects.h | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/src/ir/effects.h b/src/ir/effects.h index b1b4c7053..87b77601f 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -997,45 +997,14 @@ private: } } } - void visitStringAs(StringAs* curr) { - // traps when ref is null. - parent.implicitTrap = true; - } - void visitStringWTF8Advance(StringWTF8Advance* curr) { - // traps when ref is null. - parent.implicitTrap = true; - } void visitStringWTF16Get(StringWTF16Get* curr) { // traps when ref is null. parent.implicitTrap = true; } - void visitStringIterNext(StringIterNext* curr) { - // traps when ref is null. - parent.implicitTrap = true; - // modifies state in the iterator. we model that as accessing heap memory - // in an array atm TODO consider adding a new effect type for this (we - // added one for arrays because struct/array operations often interleave, - // say with vtable accesses, but it's not clear adding overhead to this - // class is worth it for string iters) - parent.readsArray = true; - parent.writesArray = true; - } - void visitStringIterMove(StringIterMove* curr) { - // traps when ref is null. - parent.implicitTrap = true; - // see StringIterNext. - parent.readsArray = true; - parent.writesArray = true; - } void visitStringSliceWTF(StringSliceWTF* curr) { // traps when ref is null. parent.implicitTrap = true; } - void visitStringSliceIter(StringSliceIter* curr) { - // traps when ref is null. - parent.implicitTrap = true; - } - void visitContBind(ContBind* curr) { // traps when curr->cont is null ref. parent.implicitTrap = true; |