summaryrefslogtreecommitdiff
path: root/src/wasm-binary.h
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-05-15 12:05:33 -0700
committerGitHub <noreply@github.com>2024-05-15 12:05:33 -0700
commitef4b57c2a491a2193435dccdc9305f6a79965715 (patch)
tree491562613897a0c467a456e05e8a92234509e02c /src/wasm-binary.h
parent8a5dc1880d962a7c31a7a219720be343a0866e5c (diff)
downloadbinaryen-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/wasm-binary.h')
-rw-r--r--src/wasm-binary.h26
1 files changed, 2 insertions, 24 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 9610aed9f..449c03699 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -369,10 +369,7 @@ enum EncodedType {
exnref = -0x17, // 0x69
nullexnref = -0xc, // 0x74
// string reference types
- stringref = -0x19, // 0x67
- stringview_wtf8 = -0x1a, // 0x66
- stringview_wtf16 = -0x1e, // 0x62
- stringview_iter = -0x1f, // 0x61
+ stringref = -0x19, // 0x67
// type forms
Func = -0x20, // 0x60
Cont = -0x23, // 0x5d
@@ -402,12 +399,6 @@ enum EncodedHeapType {
struct_ = -0x15, // 0x6b
array = -0x16, // 0x6a
string = -0x19, // 0x67
- // stringview/iter constants are identical to type, and cannot be duplicated
- // here as that would be a compiler error, so add _heap suffixes. See
- // https://github.com/WebAssembly/stringref/issues/12
- stringview_wtf8_heap = -0x1a, // 0x66
- stringview_wtf16_heap = -0x1e, // 0x62
- stringview_iter_heap = -0x1f, // 0x61
};
namespace CustomSections {
@@ -1146,18 +1137,9 @@ enum ASTNodes {
StringEncodeLossyUTF8 = 0x8d,
StringEncodeWTF8 = 0x8e,
StringNewUTF8Try = 0x8f,
- StringAsWTF8 = 0x90,
- StringViewWTF8Advance = 0x91,
- StringViewWTF8Slice = 0x93,
StringAsWTF16 = 0x98,
- StringViewWTF16Length = 0x99,
StringViewWTF16GetCodePoint = 0x9a,
StringViewWTF16Slice = 0x9c,
- StringAsIter = 0xa0,
- StringViewIterNext = 0xa1,
- StringViewIterAdvance = 0xa2,
- StringViewIterRewind = 0xa3,
- StringViewIterSlice = 0xa4,
StringCompare = 0xa8,
StringFromCodePoint = 0xa9,
StringHash = 0xaa,
@@ -1777,18 +1759,14 @@ public:
bool maybeVisitArrayFill(Expression*& out, uint32_t code);
bool maybeVisitArrayInit(Expression*& out, uint32_t code);
bool maybeVisitStringNew(Expression*& out, uint32_t code);
+ bool maybeVisitStringAsWTF16(Expression*& out, uint32_t code);
bool maybeVisitStringConst(Expression*& out, uint32_t code);
bool maybeVisitStringMeasure(Expression*& out, uint32_t code);
bool maybeVisitStringEncode(Expression*& out, uint32_t code);
bool maybeVisitStringConcat(Expression*& out, uint32_t code);
bool maybeVisitStringEq(Expression*& out, uint32_t code);
- bool maybeVisitStringAs(Expression*& out, uint32_t code);
- bool maybeVisitStringWTF8Advance(Expression*& out, uint32_t code);
bool maybeVisitStringWTF16Get(Expression*& out, uint32_t code);
- bool maybeVisitStringIterNext(Expression*& out, uint32_t code);
- bool maybeVisitStringIterMove(Expression*& out, uint32_t code);
bool maybeVisitStringSliceWTF(Expression*& out, uint32_t code);
- bool maybeVisitStringSliceIter(Expression*& out, uint32_t code);
void visitSelect(Select* curr, uint8_t code);
void visitReturn(Return* curr);
void visitMemorySize(MemorySize* curr);