summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/gen-s-parser.py23
-rw-r--r--src/binaryen-c.cpp86
-rw-r--r--src/binaryen-c.h39
-rw-r--r--src/gen-s-parser.inc367
-rw-r--r--src/ir/child-typer.h41
-rw-r--r--src/ir/cost.h6
-rw-r--r--src/ir/effects.h36
-rw-r--r--src/js/binaryen.js-post.js14
-rw-r--r--src/parser/contexts.h48
-rw-r--r--src/parser/parsers.h33
-rw-r--r--src/passes/Precompute.cpp6
-rw-r--r--src/passes/Print.cpp53
-rw-r--r--src/passes/StringLowering.cpp11
-rw-r--r--src/tools/fuzzing/fuzzing.cpp5
-rw-r--r--src/wasm-binary.h15
-rw-r--r--src/wasm-builder.h31
-rw-r--r--src/wasm-delegations-fields.def8
-rw-r--r--src/wasm-interpreter.h35
-rw-r--r--src/wasm-ir-builder.h4
-rw-r--r--src/wasm-s-parser.h2
-rw-r--r--src/wasm.h44
-rw-r--r--src/wasm/wasm-binary.cpp111
-rw-r--r--src/wasm/wasm-ir-builder.cpp73
-rw-r--r--src/wasm/wasm-s-parser.cpp33
-rw-r--r--src/wasm/wasm-stack.cpp65
-rw-r--r--src/wasm/wasm-validator.cpp42
-rw-r--r--src/wasm/wasm.cpp9
-rw-r--r--test/example/c-api-kitchen-sink.c117
-rw-r--r--test/example/c-api-kitchen-sink.txt99
-rw-r--r--test/lit/passes/simplify-locals-strings.wast404
-rw-r--r--test/lit/strings.wast282
-rw-r--r--test/lit/wat-kitchen-sink.wast349
32 files changed, 380 insertions, 2111 deletions
diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py
index ed2ef72c3..4cf2e8ee9 100755
--- a/scripts/gen-s-parser.py
+++ b/scripts/gen-s-parser.py
@@ -605,31 +605,14 @@ instructions = [
("ref.as_non_null", "makeRefAs(s, RefAsNonNull)"),
("extern.internalize", "makeRefAs(s, ExternInternalize)"),
("extern.externalize", "makeRefAs(s, ExternExternalize)"),
- ("string.new_utf8", "makeStringNew(s, StringNewUTF8, false)"),
- ("string.new_lossy_utf8", "makeStringNew(s, StringNewLossyUTF8, false)"),
- ("string.new_wtf8", "makeStringNew(s, StringNewWTF8, false)"),
- ("string.new_wtf16", "makeStringNew(s, StringNewWTF16, false)"),
- ("string.new_utf8_array", "makeStringNew(s, StringNewUTF8Array, false)"),
- ("string.new_lossy_utf8_array", "makeStringNew(s, StringNewLossyUTF8Array, false)"),
- ("string.new_wtf8_array", "makeStringNew(s, StringNewWTF8Array, false)"),
- ("string.new_wtf16_array", "makeStringNew(s, StringNewWTF16Array, false)"),
- ("string.from_code_point", "makeStringNew(s, StringNewFromCodePoint, false)"),
- ("string.new_utf8_try", "makeStringNew(s, StringNewUTF8, true)"),
- ("string.new_utf8_array_try", "makeStringNew(s, StringNewUTF8Array, true)"),
+ ("string.new_lossy_utf8_array", "makeStringNew(s, StringNewLossyUTF8Array)"),
+ ("string.new_wtf16_array", "makeStringNew(s, StringNewWTF16Array)"),
+ ("string.from_code_point", "makeStringNew(s, StringNewFromCodePoint)"),
("string.const", "makeStringConst(s)"),
("string.measure_utf8", "makeStringMeasure(s, StringMeasureUTF8)"),
- ("string.measure_wtf8", "makeStringMeasure(s, StringMeasureWTF8)"),
("string.measure_wtf16", "makeStringMeasure(s, StringMeasureWTF16)"),
("stringview_wtf16.length", "makeStringMeasure(s, StringMeasureWTF16)"),
- ("string.is_usv_sequence", "makeStringMeasure(s, StringMeasureIsUSV)"),
- ("string.hash", "makeStringMeasure(s, StringMeasureHash)"),
- ("string.encode_utf8", "makeStringEncode(s, StringEncodeUTF8)"),
- ("string.encode_lossy_utf8", "makeStringEncode(s, StringEncodeLossyUTF8)"),
- ("string.encode_wtf8", "makeStringEncode(s, StringEncodeWTF8)"),
- ("string.encode_wtf16", "makeStringEncode(s, StringEncodeWTF16)"),
- ("string.encode_utf8_array", "makeStringEncode(s, StringEncodeUTF8Array)"),
("string.encode_lossy_utf8_array", "makeStringEncode(s, StringEncodeLossyUTF8Array)"),
- ("string.encode_wtf8_array", "makeStringEncode(s, StringEncodeWTF8Array)"),
("string.encode_wtf16_array", "makeStringEncode(s, StringEncodeWTF16Array)"),
("string.concat", "makeStringConcat(s)"),
("string.eq", "makeStringEq(s, StringEqEqual)"),
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp
index a9a21bc14..f60e5ec59 100644
--- a/src/binaryen-c.cpp
+++ b/src/binaryen-c.cpp
@@ -1019,12 +1019,6 @@ BinaryenOp BinaryenBrOnNull(void) { return BrOnNull; }
BinaryenOp BinaryenBrOnNonNull(void) { return BrOnNonNull; }
BinaryenOp BinaryenBrOnCast(void) { return BrOnCast; }
BinaryenOp BinaryenBrOnCastFail(void) { return BrOnCastFail; };
-BinaryenOp BinaryenStringNewUTF8(void) { return StringNewUTF8; }
-BinaryenOp BinaryenStringNewWTF8(void) { return StringNewWTF8; }
-BinaryenOp BinaryenStringNewLossyUTF8(void) { return StringNewLossyUTF8; }
-BinaryenOp BinaryenStringNewWTF16(void) { return StringNewWTF16; }
-BinaryenOp BinaryenStringNewUTF8Array(void) { return StringNewUTF8Array; }
-BinaryenOp BinaryenStringNewWTF8Array(void) { return StringNewWTF8Array; }
BinaryenOp BinaryenStringNewLossyUTF8Array(void) {
return StringNewLossyUTF8Array;
}
@@ -1033,18 +1027,10 @@ BinaryenOp BinaryenStringNewFromCodePoint(void) {
return StringNewFromCodePoint;
}
BinaryenOp BinaryenStringMeasureUTF8(void) { return StringMeasureUTF8; }
-BinaryenOp BinaryenStringMeasureWTF8(void) { return StringMeasureWTF8; }
BinaryenOp BinaryenStringMeasureWTF16(void) { return StringMeasureWTF16; }
-BinaryenOp BinaryenStringMeasureIsUSV(void) { return StringMeasureIsUSV; }
-BinaryenOp BinaryenStringEncodeUTF8(void) { return StringEncodeUTF8; }
-BinaryenOp BinaryenStringEncodeLossyUTF8(void) { return StringEncodeLossyUTF8; }
-BinaryenOp BinaryenStringEncodeWTF8(void) { return StringEncodeWTF8; }
-BinaryenOp BinaryenStringEncodeWTF16(void) { return StringEncodeWTF16; }
-BinaryenOp BinaryenStringEncodeUTF8Array(void) { return StringEncodeUTF8Array; }
BinaryenOp BinaryenStringEncodeLossyUTF8Array(void) {
return StringEncodeLossyUTF8Array;
}
-BinaryenOp BinaryenStringEncodeWTF8Array(void) { return StringEncodeWTF8Array; }
BinaryenOp BinaryenStringEncodeWTF16Array(void) {
return StringEncodeWTF16Array;
}
@@ -1848,19 +1834,11 @@ BinaryenExpressionRef BinaryenArrayCopy(BinaryenModuleRef module,
BinaryenExpressionRef BinaryenStringNew(BinaryenModuleRef module,
BinaryenOp op,
BinaryenExpressionRef ptr,
- BinaryenExpressionRef length,
BinaryenExpressionRef start,
- BinaryenExpressionRef end,
- bool try_) {
+ BinaryenExpressionRef end) {
Builder builder(*(Module*)module);
- return static_cast<Expression*>(
- length ? builder.makeStringNew(
- StringNewOp(op), (Expression*)ptr, (Expression*)length, try_)
- : builder.makeStringNew(StringNewOp(op),
- (Expression*)ptr,
- (Expression*)start,
- (Expression*)end,
- try_));
+ return static_cast<Expression*>(builder.makeStringNew(
+ StringNewOp(op), (Expression*)ptr, (Expression*)start, (Expression*)end));
}
BinaryenExpressionRef BinaryenStringConst(BinaryenModuleRef module,
const char* name) {
@@ -4444,29 +4422,17 @@ void BinaryenStringNewSetOp(BinaryenExpressionRef expr, BinaryenOp op) {
assert(expression->is<StringNew>());
static_cast<StringNew*>(expression)->op = StringNewOp(op);
}
-BinaryenExpressionRef BinaryenStringNewGetPtr(BinaryenExpressionRef expr) {
- auto* expression = (Expression*)expr;
- assert(expression->is<StringNew>());
- return static_cast<StringNew*>(expression)->ptr;
-}
-void BinaryenStringNewSetPtr(BinaryenExpressionRef expr,
- BinaryenExpressionRef ptrExpr) {
+BinaryenExpressionRef BinaryenStringNewGetRef(BinaryenExpressionRef expr) {
auto* expression = (Expression*)expr;
assert(expression->is<StringNew>());
- assert(ptrExpr);
- static_cast<StringNew*>(expression)->ptr = (Expression*)ptrExpr;
+ return static_cast<StringNew*>(expression)->ref;
}
-BinaryenExpressionRef BinaryenStringNewGetLength(BinaryenExpressionRef expr) {
- auto* expression = (Expression*)expr;
- assert(expression->is<StringNew>());
- return static_cast<StringNew*>(expression)->length;
-}
-void BinaryenStringNewSetLength(BinaryenExpressionRef expr,
- BinaryenExpressionRef lengthExpr) {
+void BinaryenStringNewSetRef(BinaryenExpressionRef expr,
+ BinaryenExpressionRef refExpr) {
auto* expression = (Expression*)expr;
assert(expression->is<StringNew>());
- // may be null (linear memory only)
- static_cast<StringNew*>(expression)->length = (Expression*)lengthExpr;
+ assert(refExpr);
+ static_cast<StringNew*>(expression)->ref = (Expression*)refExpr;
}
BinaryenExpressionRef BinaryenStringNewGetStart(BinaryenExpressionRef expr) {
auto* expression = (Expression*)expr;
@@ -4492,16 +4458,6 @@ void BinaryenStringNewSetEnd(BinaryenExpressionRef expr,
// may be null (GC only)
static_cast<StringNew*>(expression)->end = (Expression*)endExpr;
}
-void BinaryenStringNewSetTry(BinaryenExpressionRef expr, bool try_) {
- auto* expression = (Expression*)expr;
- assert(expression->is<StringNew>());
- static_cast<StringNew*>(expression)->try_ = try_;
-}
-bool BinaryenStringNewIsTry(BinaryenExpressionRef expr) {
- auto* expression = (Expression*)expr;
- assert(expression->is<StringNew>());
- return static_cast<StringNew*>(expression)->try_;
-}
// StringConst
const char* BinaryenStringConstGetString(BinaryenExpressionRef expr) {
auto* expression = (Expression*)expr;
@@ -4549,29 +4505,29 @@ void BinaryenStringEncodeSetOp(BinaryenExpressionRef expr, BinaryenOp op) {
assert(expression->is<StringEncode>());
static_cast<StringEncode*>(expression)->op = StringEncodeOp(op);
}
-BinaryenExpressionRef BinaryenStringEncodeGetRef(BinaryenExpressionRef expr) {
+BinaryenExpressionRef BinaryenStringEncodeGetStr(BinaryenExpressionRef expr) {
auto* expression = (Expression*)expr;
assert(expression->is<StringEncode>());
- return static_cast<StringEncode*>(expression)->ref;
+ return static_cast<StringEncode*>(expression)->str;
}
-void BinaryenStringEncodeSetRef(BinaryenExpressionRef expr,
- BinaryenExpressionRef refExpr) {
+void BinaryenStringEncodeSetStr(BinaryenExpressionRef expr,
+ BinaryenExpressionRef strExpr) {
auto* expression = (Expression*)expr;
assert(expression->is<StringEncode>());
- assert(refExpr);
- static_cast<StringEncode*>(expression)->ref = (Expression*)refExpr;
+ assert(strExpr);
+ static_cast<StringEncode*>(expression)->str = (Expression*)strExpr;
}
-BinaryenExpressionRef BinaryenStringEncodeGetPtr(BinaryenExpressionRef expr) {
+BinaryenExpressionRef BinaryenStringEncodeGetArray(BinaryenExpressionRef expr) {
auto* expression = (Expression*)expr;
assert(expression->is<StringEncode>());
- return static_cast<StringEncode*>(expression)->ptr;
+ return static_cast<StringEncode*>(expression)->array;
}
-void BinaryenStringEncodeSetPtr(BinaryenExpressionRef expr,
- BinaryenExpressionRef ptrExpr) {
+void BinaryenStringEncodeSetArray(BinaryenExpressionRef expr,
+ BinaryenExpressionRef arrayExpr) {
auto* expression = (Expression*)expr;
assert(expression->is<StringEncode>());
- assert(ptrExpr);
- static_cast<StringEncode*>(expression)->ptr = (Expression*)ptrExpr;
+ assert(arrayExpr);
+ static_cast<StringEncode*>(expression)->array = (Expression*)arrayExpr;
}
BinaryenExpressionRef BinaryenStringEncodeGetStart(BinaryenExpressionRef expr) {
auto* expression = (Expression*)expr;
diff --git a/src/binaryen-c.h b/src/binaryen-c.h
index f01b4c3be..3f2cab20c 100644
--- a/src/binaryen-c.h
+++ b/src/binaryen-c.h
@@ -682,26 +682,12 @@ BINARYEN_API BinaryenOp BinaryenBrOnNull(void);
BINARYEN_API BinaryenOp BinaryenBrOnNonNull(void);
BINARYEN_API BinaryenOp BinaryenBrOnCast(void);
BINARYEN_API BinaryenOp BinaryenBrOnCastFail(void);
-BINARYEN_API BinaryenOp BinaryenStringNewUTF8(void);
-BINARYEN_API BinaryenOp BinaryenStringNewWTF8(void);
-BINARYEN_API BinaryenOp BinaryenStringNewLossyUTF8(void);
-BINARYEN_API BinaryenOp BinaryenStringNewWTF16(void);
-BINARYEN_API BinaryenOp BinaryenStringNewUTF8Array(void);
-BINARYEN_API BinaryenOp BinaryenStringNewWTF8Array(void);
BINARYEN_API BinaryenOp BinaryenStringNewLossyUTF8Array(void);
BINARYEN_API BinaryenOp BinaryenStringNewWTF16Array(void);
BINARYEN_API BinaryenOp BinaryenStringNewFromCodePoint(void);
BINARYEN_API BinaryenOp BinaryenStringMeasureUTF8(void);
-BINARYEN_API BinaryenOp BinaryenStringMeasureWTF8(void);
BINARYEN_API BinaryenOp BinaryenStringMeasureWTF16(void);
-BINARYEN_API BinaryenOp BinaryenStringMeasureIsUSV(void);
-BINARYEN_API BinaryenOp BinaryenStringEncodeUTF8(void);
-BINARYEN_API BinaryenOp BinaryenStringEncodeLossyUTF8(void);
-BINARYEN_API BinaryenOp BinaryenStringEncodeWTF8(void);
-BINARYEN_API BinaryenOp BinaryenStringEncodeWTF16(void);
-BINARYEN_API BinaryenOp BinaryenStringEncodeUTF8Array(void);
BINARYEN_API BinaryenOp BinaryenStringEncodeLossyUTF8Array(void);
-BINARYEN_API BinaryenOp BinaryenStringEncodeWTF8Array(void);
BINARYEN_API BinaryenOp BinaryenStringEncodeWTF16Array(void);
BINARYEN_API BinaryenOp BinaryenStringEqEqual(void);
BINARYEN_API BinaryenOp BinaryenStringEqCompare(void);
@@ -1092,11 +1078,9 @@ BinaryenArrayCopy(BinaryenModuleRef module,
BINARYEN_API BinaryenExpressionRef
BinaryenStringNew(BinaryenModuleRef module,
BinaryenOp op,
- BinaryenExpressionRef ptr,
- BinaryenExpressionRef length,
+ BinaryenExpressionRef ref,
BinaryenExpressionRef start,
- BinaryenExpressionRef end,
- bool try_);
+ BinaryenExpressionRef end);
BINARYEN_API BinaryenExpressionRef BinaryenStringConst(BinaryenModuleRef module,
const char* name);
BINARYEN_API BinaryenExpressionRef BinaryenStringMeasure(
@@ -2522,14 +2506,10 @@ BINARYEN_API BinaryenOp BinaryenStringNewGetOp(BinaryenExpressionRef expr);
BINARYEN_API void BinaryenStringNewSetOp(BinaryenExpressionRef expr,
BinaryenOp op);
BINARYEN_API BinaryenExpressionRef
-BinaryenStringNewGetPtr(BinaryenExpressionRef expr);
-BINARYEN_API void BinaryenStringNewSetPtr(BinaryenExpressionRef expr,
+BinaryenStringNewGetRef(BinaryenExpressionRef expr);
+BINARYEN_API void BinaryenStringNewSetRef(BinaryenExpressionRef expr,
BinaryenExpressionRef ptrExpr);
BINARYEN_API BinaryenExpressionRef
-BinaryenStringNewGetLength(BinaryenExpressionRef expr);
-BINARYEN_API void BinaryenStringNewSetLength(BinaryenExpressionRef expr,
- BinaryenExpressionRef lengthExpr);
-BINARYEN_API BinaryenExpressionRef
BinaryenStringNewGetStart(BinaryenExpressionRef expr);
BINARYEN_API void BinaryenStringNewSetStart(BinaryenExpressionRef expr,
BinaryenExpressionRef startExpr);
@@ -2539,7 +2519,6 @@ BINARYEN_API void BinaryenStringNewSetEnd(BinaryenExpressionRef expr,
BinaryenExpressionRef endExpr);
BINARYEN_API void BinaryenStringNewSetTry(BinaryenExpressionRef expr,
bool try_);
-BINARYEN_API bool BinaryenStringNewIsTry(BinaryenExpressionRef expr);
// StringConst
@@ -2564,13 +2543,13 @@ BINARYEN_API BinaryenOp BinaryenStringEncodeGetOp(BinaryenExpressionRef expr);
BINARYEN_API void BinaryenStringEncodeSetOp(BinaryenExpressionRef expr,
BinaryenOp op);
BINARYEN_API BinaryenExpressionRef
-BinaryenStringEncodeGetRef(BinaryenExpressionRef expr);
-BINARYEN_API void BinaryenStringEncodeSetRef(BinaryenExpressionRef expr,
+BinaryenStringEncodeGetStr(BinaryenExpressionRef expr);
+BINARYEN_API void BinaryenStringEncodeSetStr(BinaryenExpressionRef expr,
BinaryenExpressionRef refExpr);
BINARYEN_API BinaryenExpressionRef
-BinaryenStringEncodeGetPtr(BinaryenExpressionRef expr);
-BINARYEN_API void BinaryenStringEncodeSetPtr(BinaryenExpressionRef expr,
- BinaryenExpressionRef ptrExpr);
+BinaryenStringEncodeGetArray(BinaryenExpressionRef expr);
+BINARYEN_API void BinaryenStringEncodeSetArray(BinaryenExpressionRef expr,
+ BinaryenExpressionRef ptrExpr);
BINARYEN_API BinaryenExpressionRef
BinaryenStringEncodeGetStart(BinaryenExpressionRef expr);
BINARYEN_API void BinaryenStringEncodeSetStart(BinaryenExpressionRef expr,
diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc
index b76a26ea1..a451805db 100644
--- a/src/gen-s-parser.inc
+++ b/src/gen-s-parser.inc
@@ -3098,55 +3098,12 @@ switch (buf[0]) {
switch (buf[8]) {
case 'n': {
switch (buf[14]) {
- case 'l': {
- switch (buf[24]) {
- case '\0':
- if (op == "string.encode_lossy_utf8"sv) { return makeStringEncode(s, StringEncodeLossyUTF8); }
- goto parse_error;
- case '_':
- if (op == "string.encode_lossy_utf8_array"sv) { return makeStringEncode(s, StringEncodeLossyUTF8Array); }
- goto parse_error;
- default: goto parse_error;
- }
- }
- case 'u': {
- switch (buf[18]) {
- case '\0':
- if (op == "string.encode_utf8"sv) { return makeStringEncode(s, StringEncodeUTF8); }
- goto parse_error;
- case '_':
- if (op == "string.encode_utf8_array"sv) { return makeStringEncode(s, StringEncodeUTF8Array); }
- goto parse_error;
- default: goto parse_error;
- }
- }
- case 'w': {
- switch (buf[17]) {
- case '1': {
- switch (buf[19]) {
- case '\0':
- if (op == "string.encode_wtf16"sv) { return makeStringEncode(s, StringEncodeWTF16); }
- goto parse_error;
- case '_':
- if (op == "string.encode_wtf16_array"sv) { return makeStringEncode(s, StringEncodeWTF16Array); }
- goto parse_error;
- default: goto parse_error;
- }
- }
- case '8': {
- switch (buf[18]) {
- case '\0':
- if (op == "string.encode_wtf8"sv) { return makeStringEncode(s, StringEncodeWTF8); }
- goto parse_error;
- case '_':
- if (op == "string.encode_wtf8_array"sv) { return makeStringEncode(s, StringEncodeWTF8Array); }
- goto parse_error;
- default: goto parse_error;
- }
- }
- default: goto parse_error;
- }
- }
+ case 'l':
+ if (op == "string.encode_lossy_utf8_array"sv) { return makeStringEncode(s, StringEncodeLossyUTF8Array); }
+ goto parse_error;
+ case 'w':
+ if (op == "string.encode_wtf16_array"sv) { return makeStringEncode(s, StringEncodeWTF16Array); }
+ goto parse_error;
default: goto parse_error;
}
}
@@ -3157,100 +3114,27 @@ switch (buf[0]) {
}
}
case 'f':
- if (op == "string.from_code_point"sv) { return makeStringNew(s, StringNewFromCodePoint, false); }
- goto parse_error;
- case 'h':
- if (op == "string.hash"sv) { return makeStringMeasure(s, StringMeasureHash); }
- goto parse_error;
- case 'i':
- if (op == "string.is_usv_sequence"sv) { return makeStringMeasure(s, StringMeasureIsUSV); }
+ if (op == "string.from_code_point"sv) { return makeStringNew(s, StringNewFromCodePoint); }
goto parse_error;
case 'm': {
switch (buf[15]) {
case 'u':
if (op == "string.measure_utf8"sv) { return makeStringMeasure(s, StringMeasureUTF8); }
goto parse_error;
- case 'w': {
- switch (buf[18]) {
- case '1':
- if (op == "string.measure_wtf16"sv) { return makeStringMeasure(s, StringMeasureWTF16); }
- goto parse_error;
- case '8':
- if (op == "string.measure_wtf8"sv) { return makeStringMeasure(s, StringMeasureWTF8); }
- goto parse_error;
- default: goto parse_error;
- }
- }
+ case 'w':
+ if (op == "string.measure_wtf16"sv) { return makeStringMeasure(s, StringMeasureWTF16); }
+ goto parse_error;
default: goto parse_error;
}
}
case 'n': {
switch (buf[11]) {
- case 'l': {
- switch (buf[21]) {
- case '\0':
- if (op == "string.new_lossy_utf8"sv) { return makeStringNew(s, StringNewLossyUTF8, false); }
- goto parse_error;
- case '_':
- if (op == "string.new_lossy_utf8_array"sv) { return makeStringNew(s, StringNewLossyUTF8Array, false); }
- goto parse_error;
- default: goto parse_error;
- }
- }
- case 'u': {
- switch (buf[15]) {
- case '\0':
- if (op == "string.new_utf8"sv) { return makeStringNew(s, StringNewUTF8, false); }
- goto parse_error;
- case '_': {
- switch (buf[16]) {
- case 'a': {
- switch (buf[21]) {
- case '\0':
- if (op == "string.new_utf8_array"sv) { return makeStringNew(s, StringNewUTF8Array, false); }
- goto parse_error;
- case '_':
- if (op == "string.new_utf8_array_try"sv) { return makeStringNew(s, StringNewUTF8Array, true); }
- goto parse_error;
- default: goto parse_error;
- }
- }
- case 't':
- if (op == "string.new_utf8_try"sv) { return makeStringNew(s, StringNewUTF8, true); }
- goto parse_error;
- default: goto parse_error;
- }
- }
- default: goto parse_error;
- }
- }
- case 'w': {
- switch (buf[14]) {
- case '1': {
- switch (buf[16]) {
- case '\0':
- if (op == "string.new_wtf16"sv) { return makeStringNew(s, StringNewWTF16, false); }
- goto parse_error;
- case '_':
- if (op == "string.new_wtf16_array"sv) { return makeStringNew(s, StringNewWTF16Array, false); }
- goto parse_error;
- default: goto parse_error;
- }
- }
- case '8': {
- switch (buf[15]) {
- case '\0':
- if (op == "string.new_wtf8"sv) { return makeStringNew(s, StringNewWTF8, false); }
- goto parse_error;
- case '_':
- if (op == "string.new_wtf8_array"sv) { return makeStringNew(s, StringNewWTF8Array, false); }
- goto parse_error;
- default: goto parse_error;
- }
- }
- default: goto parse_error;
- }
- }
+ case 'l':
+ if (op == "string.new_lossy_utf8_array"sv) { return makeStringNew(s, StringNewLossyUTF8Array); }
+ goto parse_error;
+ case 'w':
+ if (op == "string.new_wtf16_array"sv) { return makeStringNew(s, StringNewWTF16Array); }
+ goto parse_error;
default: goto parse_error;
}
}
@@ -8205,79 +8089,18 @@ switch (buf[0]) {
switch (buf[8]) {
case 'n': {
switch (buf[14]) {
- case 'l': {
- switch (buf[24]) {
- case '\0':
- if (op == "string.encode_lossy_utf8"sv) {
- CHECK_ERR(makeStringEncode(ctx, pos, annotations, StringEncodeLossyUTF8));
- return Ok{};
- }
- goto parse_error;
- case '_':
- if (op == "string.encode_lossy_utf8_array"sv) {
- CHECK_ERR(makeStringEncode(ctx, pos, annotations, StringEncodeLossyUTF8Array));
- return Ok{};
- }
- goto parse_error;
- default: goto parse_error;
- }
- }
- case 'u': {
- switch (buf[18]) {
- case '\0':
- if (op == "string.encode_utf8"sv) {
- CHECK_ERR(makeStringEncode(ctx, pos, annotations, StringEncodeUTF8));
- return Ok{};
- }
- goto parse_error;
- case '_':
- if (op == "string.encode_utf8_array"sv) {
- CHECK_ERR(makeStringEncode(ctx, pos, annotations, StringEncodeUTF8Array));
- return Ok{};
- }
- goto parse_error;
- default: goto parse_error;
+ case 'l':
+ if (op == "string.encode_lossy_utf8_array"sv) {
+ CHECK_ERR(makeStringEncode(ctx, pos, annotations, StringEncodeLossyUTF8Array));
+ return Ok{};
}
- }
- case 'w': {
- switch (buf[17]) {
- case '1': {
- switch (buf[19]) {
- case '\0':
- if (op == "string.encode_wtf16"sv) {
- CHECK_ERR(makeStringEncode(ctx, pos, annotations, StringEncodeWTF16));
- return Ok{};
- }
- goto parse_error;
- case '_':
- if (op == "string.encode_wtf16_array"sv) {
- CHECK_ERR(makeStringEncode(ctx, pos, annotations, StringEncodeWTF16Array));
- return Ok{};
- }
- goto parse_error;
- default: goto parse_error;
- }
- }
- case '8': {
- switch (buf[18]) {
- case '\0':
- if (op == "string.encode_wtf8"sv) {
- CHECK_ERR(makeStringEncode(ctx, pos, annotations, StringEncodeWTF8));
- return Ok{};
- }
- goto parse_error;
- case '_':
- if (op == "string.encode_wtf8_array"sv) {
- CHECK_ERR(makeStringEncode(ctx, pos, annotations, StringEncodeWTF8Array));
- return Ok{};
- }
- goto parse_error;
- default: goto parse_error;
- }
- }
- default: goto parse_error;
+ goto parse_error;
+ case 'w':
+ if (op == "string.encode_wtf16_array"sv) {
+ CHECK_ERR(makeStringEncode(ctx, pos, annotations, StringEncodeWTF16Array));
+ return Ok{};
}
- }
+ goto parse_error;
default: goto parse_error;
}
}
@@ -8292,19 +8115,7 @@ switch (buf[0]) {
}
case 'f':
if (op == "string.from_code_point"sv) {
- CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewFromCodePoint, false));
- return Ok{};
- }
- goto parse_error;
- case 'h':
- if (op == "string.hash"sv) {
- CHECK_ERR(makeStringMeasure(ctx, pos, annotations, StringMeasureHash));
- return Ok{};
- }
- goto parse_error;
- case 'i':
- if (op == "string.is_usv_sequence"sv) {
- CHECK_ERR(makeStringMeasure(ctx, pos, annotations, StringMeasureIsUSV));
+ CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewFromCodePoint));
return Ok{};
}
goto parse_error;
@@ -8316,123 +8127,29 @@ switch (buf[0]) {
return Ok{};
}
goto parse_error;
- case 'w': {
- switch (buf[18]) {
- case '1':
- if (op == "string.measure_wtf16"sv) {
- CHECK_ERR(makeStringMeasure(ctx, pos, annotations, StringMeasureWTF16));
- return Ok{};
- }
- goto parse_error;
- case '8':
- if (op == "string.measure_wtf8"sv) {
- CHECK_ERR(makeStringMeasure(ctx, pos, annotations, StringMeasureWTF8));
- return Ok{};
- }
- goto parse_error;
- default: goto parse_error;
+ case 'w':
+ if (op == "string.measure_wtf16"sv) {
+ CHECK_ERR(makeStringMeasure(ctx, pos, annotations, StringMeasureWTF16));
+ return Ok{};
}
- }
+ goto parse_error;
default: goto parse_error;
}
}
case 'n': {
switch (buf[11]) {
- case 'l': {
- switch (buf[21]) {
- case '\0':
- if (op == "string.new_lossy_utf8"sv) {
- CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewLossyUTF8, false));
- return Ok{};
- }
- goto parse_error;
- case '_':
- if (op == "string.new_lossy_utf8_array"sv) {
- CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewLossyUTF8Array, false));
- return Ok{};
- }
- goto parse_error;
- default: goto parse_error;
- }
- }
- case 'u': {
- switch (buf[15]) {
- case '\0':
- if (op == "string.new_utf8"sv) {
- CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewUTF8, false));
- return Ok{};
- }
- goto parse_error;
- case '_': {
- switch (buf[16]) {
- case 'a': {
- switch (buf[21]) {
- case '\0':
- if (op == "string.new_utf8_array"sv) {
- CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewUTF8Array, false));
- return Ok{};
- }
- goto parse_error;
- case '_':
- if (op == "string.new_utf8_array_try"sv) {
- CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewUTF8Array, true));
- return Ok{};
- }
- goto parse_error;
- default: goto parse_error;
- }
- }
- case 't':
- if (op == "string.new_utf8_try"sv) {
- CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewUTF8, true));
- return Ok{};
- }
- goto parse_error;
- default: goto parse_error;
- }
- }
- default: goto parse_error;
+ case 'l':
+ if (op == "string.new_lossy_utf8_array"sv) {
+ CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewLossyUTF8Array));
+ return Ok{};
}
- }
- case 'w': {
- switch (buf[14]) {
- case '1': {
- switch (buf[16]) {
- case '\0':
- if (op == "string.new_wtf16"sv) {
- CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewWTF16, false));
- return Ok{};
- }
- goto parse_error;
- case '_':
- if (op == "string.new_wtf16_array"sv) {
- CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewWTF16Array, false));
- return Ok{};
- }
- goto parse_error;
- default: goto parse_error;
- }
- }
- case '8': {
- switch (buf[15]) {
- case '\0':
- if (op == "string.new_wtf8"sv) {
- CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewWTF8, false));
- return Ok{};
- }
- goto parse_error;
- case '_':
- if (op == "string.new_wtf8_array"sv) {
- CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewWTF8Array, false));
- return Ok{};
- }
- goto parse_error;
- default: goto parse_error;
- }
- }
- default: goto parse_error;
+ goto parse_error;
+ case 'w':
+ if (op == "string.new_wtf16_array"sv) {
+ CHECK_ERR(makeStringNew(ctx, pos, annotations, StringNewWTF16Array));
+ return Ok{};
}
- }
+ goto parse_error;
default: goto parse_error;
}
}
diff --git a/src/ir/child-typer.h b/src/ir/child-typer.h
index e015f3db8..7c09dddb0 100644
--- a/src/ir/child-typer.h
+++ b/src/ir/child-typer.h
@@ -962,27 +962,17 @@ template<typename Subtype> struct ChildTyper : OverriddenVisitor<Subtype> {
void visitStringNew(StringNew* curr,
std::optional<HeapType> ht = std::nullopt) {
switch (curr->op) {
- case StringNewUTF8:
- case StringNewWTF8:
- case StringNewLossyUTF8:
- case StringNewWTF16:
- // TODO: This should be notePointer, but we don't have a memory.
- note(&curr->ptr, Type::i32);
- note(&curr->length, Type::i32);
- return;
- case StringNewUTF8Array:
- case StringNewWTF8Array:
case StringNewLossyUTF8Array:
case StringNewWTF16Array:
if (!ht) {
- ht = curr->ptr->type.getHeapType();
+ ht = curr->ref->type.getHeapType();
}
- note(&curr->ptr, Type(*ht, Nullable));
+ note(&curr->ref, Type(*ht, Nullable));
note(&curr->start, Type::i32);
note(&curr->end, Type::i32);
return;
case StringNewFromCodePoint:
- note(&curr->ptr, Type::i32);
+ note(&curr->ref, Type::i32);
return;
}
WASM_UNREACHABLE("unexpected op");
@@ -996,27 +986,12 @@ template<typename Subtype> struct ChildTyper : OverriddenVisitor<Subtype> {
void visitStringEncode(StringEncode* curr,
std::optional<HeapType> ht = std::nullopt) {
- note(&curr->ref, Type(HeapType::string, Nullable));
- switch (curr->op) {
- case StringEncodeUTF8:
- case StringEncodeLossyUTF8:
- case StringEncodeWTF8:
- case StringEncodeWTF16:
- // TODO: This should be notePointer, but we don't have a memory.
- note(&curr->ptr, Type::i32);
- return;
- case StringEncodeUTF8Array:
- case StringEncodeLossyUTF8Array:
- case StringEncodeWTF8Array:
- case StringEncodeWTF16Array:
- if (!ht) {
- ht = curr->ptr->type.getHeapType();
- }
- note(&curr->ptr, Type(*ht, Nullable));
- note(&curr->start, Type::i32);
- return;
+ if (!ht) {
+ ht = curr->array->type.getHeapType();
}
- WASM_UNREACHABLE("unexpected op");
+ note(&curr->str, Type(HeapType::string, Nullable));
+ note(&curr->array, Type(*ht, Nullable));
+ note(&curr->start, Type::i32);
}
void visitStringConcat(StringConcat* curr) {
diff --git a/src/ir/cost.h b/src/ir/cost.h
index 8af68dbf1..6622561b8 100644
--- a/src/ir/cost.h
+++ b/src/ir/cost.h
@@ -689,15 +689,15 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, CostType> {
}
CostType visitRefAs(RefAs* curr) { return 1 + visit(curr->value); }
CostType visitStringNew(StringNew* curr) {
- return 8 + visit(curr->ptr) + maybeVisit(curr->length) +
- maybeVisit(curr->start) + maybeVisit(curr->end);
+ return 8 + visit(curr->ref) + maybeVisit(curr->start) +
+ maybeVisit(curr->end);
}
CostType visitStringConst(StringConst* curr) { return 4; }
CostType visitStringMeasure(StringMeasure* curr) {
return 6 + visit(curr->ref);
}
CostType visitStringEncode(StringEncode* curr) {
- return 6 + visit(curr->ref) + visit(curr->ptr);
+ return 6 + visit(curr->str) + visit(curr->array) + visit(curr->start);
}
CostType visitStringConcat(StringConcat* curr) {
return 10 + visit(curr->left) + visit(curr->right);
diff --git a/src/ir/effects.h b/src/ir/effects.h
index 87b77601f..28de83850 100644
--- a/src/ir/effects.h
+++ b/src/ir/effects.h
@@ -941,23 +941,10 @@ private:
// cycle may be needed in some cases.
}
void visitStringNew(StringNew* curr) {
- // traps when out of bounds in linear memory or ref is null
+ // traps when ref is null
parent.implicitTrap = true;
- switch (curr->op) {
- case StringNewUTF8:
- case StringNewWTF8:
- case StringNewLossyUTF8:
- case StringNewWTF16:
- parent.readsMemory = true;
- break;
- case StringNewUTF8Array:
- case StringNewWTF8Array:
- case StringNewLossyUTF8Array:
- case StringNewWTF16Array:
- parent.readsArray = true;
- break;
- default: {
- }
+ if (curr->op != StringNewFromCodePoint) {
+ parent.readsArray = true;
}
}
void visitStringConst(StringConst* curr) {}
@@ -968,22 +955,7 @@ private:
void visitStringEncode(StringEncode* curr) {
// traps when ref is null or we write out of bounds.
parent.implicitTrap = true;
- switch (curr->op) {
- case StringEncodeUTF8:
- case StringEncodeLossyUTF8:
- case StringEncodeWTF8:
- case StringEncodeWTF16:
- parent.writesMemory = true;
- break;
- case StringEncodeUTF8Array:
- case StringEncodeLossyUTF8Array:
- case StringEncodeWTF8Array:
- case StringEncodeWTF16Array:
- parent.writesArray = true;
- break;
- default: {
- }
- }
+ parent.writesArray = true;
}
void visitStringConcat(StringConcat* curr) {
// traps when an input is null.
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index 86a6e8df9..8d7bd6d7f 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -568,26 +568,12 @@ function initializeConstants() {
'BrOnNonNull',
'BrOnCast',
'BrOnCastFail',
- 'StringNewUTF8',
- 'StringNewWTF8',
- 'StringNewLossyUTF8',
- 'StringNewWTF16',
- 'StringNewUTF8Array',
- 'StringNewWTF8Array',
'StringNewLossyUTF8Array',
'StringNewWTF16Array',
'StringNewFromCodePoint',
'StringMeasureUTF8',
- 'StringMeasureWTF8',
'StringMeasureWTF16',
- 'StringMeasureIsUSV',
- 'StringEncodeUTF8',
- 'StringEncodeLossyUTF8',
- 'StringEncodeWTF8',
- 'StringEncodeWTF16',
- 'StringEncodeUTF8Array',
'StringEncodeLossyUTF8Array',
- 'StringEncodeWTF8Array',
'StringEncodeWTF16Array',
'StringEqEqual',
'StringEqCompare'
diff --git a/src/parser/contexts.h b/src/parser/contexts.h
index b32e32a15..2243c6065 100644
--- a/src/parser/contexts.h
+++ b/src/parser/contexts.h
@@ -772,8 +772,7 @@ struct NullInstrParserCtx {
Result<> makeRefAs(Index, const std::vector<Annotation>&, RefAsOp) {
return Ok{};
}
- Result<> makeStringNew(
- Index, const std::vector<Annotation>&, StringNewOp, bool, MemoryIdxT*) {
+ Result<> makeStringNew(Index, const std::vector<Annotation>&, StringNewOp) {
return Ok{};
}
Result<>
@@ -784,10 +783,8 @@ struct NullInstrParserCtx {
makeStringMeasure(Index, const std::vector<Annotation>&, StringMeasureOp) {
return Ok{};
}
- Result<> makeStringEncode(Index,
- const std::vector<Annotation>&,
- StringEncodeOp,
- MemoryIdxT*) {
+ Result<>
+ makeStringEncode(Index, const std::vector<Annotation>&, StringEncodeOp) {
return Ok{};
}
Result<> makeStringConcat(Index, const std::vector<Annotation>&) {
@@ -2478,24 +2475,8 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> {
Result<> makeStringNew(Index pos,
const std::vector<Annotation>& annotations,
- StringNewOp op,
- bool try_,
- Name* mem) {
- Name memName;
- switch (op) {
- case StringNewUTF8:
- case StringNewWTF8:
- case StringNewLossyUTF8:
- case StringNewWTF16: {
- auto m = getMemory(pos, mem);
- CHECK_ERR(m);
- memName = *m;
- break;
- }
- default:
- break;
- }
- return withLoc(pos, irBuilder.makeStringNew(op, try_, memName));
+ StringNewOp op) {
+ return withLoc(pos, irBuilder.makeStringNew(op));
}
Result<> makeStringConst(Index pos,
@@ -2518,23 +2499,8 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> {
Result<> makeStringEncode(Index pos,
const std::vector<Annotation>& annotations,
- StringEncodeOp op,
- Name* mem) {
- Name memName;
- switch (op) {
- case StringEncodeUTF8:
- case StringEncodeLossyUTF8:
- case StringEncodeWTF8:
- case StringEncodeWTF16: {
- auto m = getMemory(pos, mem);
- CHECK_ERR(m);
- memName = *m;
- break;
- }
- default:
- break;
- }
- return withLoc(pos, irBuilder.makeStringEncode(op, memName));
+ StringEncodeOp op) {
+ return withLoc(pos, irBuilder.makeStringEncode(op));
}
Result<> makeStringConcat(Index pos,
diff --git a/src/parser/parsers.h b/src/parser/parsers.h
index 60d3f0391..88600fec3 100644
--- a/src/parser/parsers.h
+++ b/src/parser/parsers.h
@@ -266,8 +266,8 @@ Result<> makeArrayInitElem(Ctx&, Index, const std::vector<Annotation>&);
template<typename Ctx>
Result<> makeRefAs(Ctx&, Index, const std::vector<Annotation>&, RefAsOp op);
template<typename Ctx>
-Result<> makeStringNew(
- Ctx&, Index, const std::vector<Annotation>&, StringNewOp op, bool try_);
+Result<>
+makeStringNew(Ctx&, Index, const std::vector<Annotation>&, StringNewOp op);
template<typename Ctx>
Result<> makeStringConst(Ctx&, Index, const std::vector<Annotation>&);
template<typename Ctx>
@@ -2336,20 +2336,8 @@ template<typename Ctx>
Result<> makeStringNew(Ctx& ctx,
Index pos,
const std::vector<Annotation>& annotations,
- StringNewOp op,
- bool try_) {
- switch (op) {
- case StringNewUTF8:
- case StringNewWTF8:
- case StringNewLossyUTF8:
- case StringNewWTF16: {
- auto mem = maybeMemidx(ctx);
- CHECK_ERR(mem);
- return ctx.makeStringNew(pos, annotations, op, try_, mem.getPtr());
- }
- default:
- return ctx.makeStringNew(pos, annotations, op, try_, nullptr);
- }
+ StringNewOp op) {
+ return ctx.makeStringNew(pos, annotations, op);
}
template<typename Ctx>
@@ -2376,18 +2364,7 @@ Result<> makeStringEncode(Ctx& ctx,
Index pos,
const std::vector<Annotation>& annotations,
StringEncodeOp op) {
- switch (op) {
- case StringEncodeUTF8:
- case StringEncodeLossyUTF8:
- case StringEncodeWTF8:
- case StringEncodeWTF16: {
- auto mem = maybeMemidx(ctx);
- CHECK_ERR(mem);
- return ctx.makeStringEncode(pos, annotations, op, mem.getPtr());
- }
- default:
- return ctx.makeStringEncode(pos, annotations, op, nullptr);
- }
+ return ctx.makeStringEncode(pos, annotations, op);
}
template<typename Ctx>
diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp
index 4f9ad046d..295d86b40 100644
--- a/src/passes/Precompute.cpp
+++ b/src/passes/Precompute.cpp
@@ -203,9 +203,9 @@ public:
// string.encode_wtf16_array is effectively an Array read operation, so
// just like ArrayGet above we must check for immutability.
- auto ptrType = curr->ptr->type;
- if (ptrType.isRef()) {
- auto heapType = ptrType.getHeapType();
+ auto refType = curr->ref->type;
+ if (refType.isRef()) {
+ auto heapType = refType.getHeapType();
if (heapType.isArray()) {
if (heapType.getArray().element.mutable_ == Immutable) {
return Super::visitStringNew(curr);
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index ab5e0db90..c57ab29c3 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -2237,32 +2237,6 @@ struct PrintExpressionContents
}
void visitStringNew(StringNew* curr) {
switch (curr->op) {
- case StringNewUTF8:
- if (!curr->try_) {
- printMedium(o, "string.new_utf8");
- } else {
- printMedium(o, "string.new_utf8_try");
- }
- break;
- case StringNewWTF8:
- printMedium(o, "string.new_wtf8");
- break;
- case StringNewLossyUTF8:
- printMedium(o, "string.new_lossy_utf8");
- break;
- case StringNewWTF16:
- printMedium(o, "string.new_wtf16");
- break;
- case StringNewUTF8Array:
- if (!curr->try_) {
- printMedium(o, "string.new_utf8_array");
- } else {
- printMedium(o, "string.new_utf8_array_try");
- }
- break;
- case StringNewWTF8Array:
- printMedium(o, "string.new_wtf8_array");
- break;
case StringNewLossyUTF8Array:
printMedium(o, "string.new_lossy_utf8_array");
break;
@@ -2291,45 +2265,18 @@ struct PrintExpressionContents
case StringMeasureUTF8:
printMedium(o, "string.measure_utf8");
break;
- case StringMeasureWTF8:
- printMedium(o, "string.measure_wtf8");
- break;
case StringMeasureWTF16:
printMedium(o, "string.measure_wtf16");
break;
- case StringMeasureIsUSV:
- printMedium(o, "string.is_usv_sequence");
- break;
- case StringMeasureHash:
- printMedium(o, "string.hash");
- break;
default:
WASM_UNREACHABLE("invalid string.measure*");
}
}
void visitStringEncode(StringEncode* curr) {
switch (curr->op) {
- case StringEncodeUTF8:
- printMedium(o, "string.encode_utf8");
- break;
- case StringEncodeLossyUTF8:
- printMedium(o, "string.encode_lossy_utf8");
- break;
- case StringEncodeWTF8:
- printMedium(o, "string.encode_wtf8");
- break;
- case StringEncodeWTF16:
- printMedium(o, "string.encode_wtf16");
- break;
- case StringEncodeUTF8Array:
- printMedium(o, "string.encode_utf8_array");
- break;
case StringEncodeLossyUTF8Array:
printMedium(o, "string.encode_lossy_utf8_array");
break;
- case StringEncodeWTF8Array:
- printMedium(o, "string.encode_wtf8_array");
- break;
case StringEncodeWTF16Array:
printMedium(o, "string.encode_wtf16_array");
break;
diff --git a/src/passes/StringLowering.cpp b/src/passes/StringLowering.cpp
index 27f4e9c07..9903f090e 100644
--- a/src/passes/StringLowering.cpp
+++ b/src/passes/StringLowering.cpp
@@ -375,12 +375,12 @@ struct StringLowering : public StringGathering {
switch (curr->op) {
case StringNewWTF16Array:
replaceCurrent(builder.makeCall(lowering.fromCharCodeArrayImport,
- {curr->ptr, curr->start, curr->end},
+ {curr->ref, curr->start, curr->end},
lowering.nnExt));
return;
case StringNewFromCodePoint:
replaceCurrent(builder.makeCall(
- lowering.fromCodePointImport, {curr->ptr}, lowering.nnExt));
+ lowering.fromCodePointImport, {curr->ref}, lowering.nnExt));
return;
default:
WASM_UNREACHABLE("TODO: all of string.new*");
@@ -397,9 +397,10 @@ struct StringLowering : public StringGathering {
Builder builder(*getModule());
switch (curr->op) {
case StringEncodeWTF16Array:
- replaceCurrent(builder.makeCall(lowering.intoCharCodeArrayImport,
- {curr->ref, curr->ptr, curr->start},
- Type::i32));
+ replaceCurrent(
+ builder.makeCall(lowering.intoCharCodeArrayImport,
+ {curr->str, curr->array, curr->start},
+ Type::i32));
return;
default:
WASM_UNREACHABLE("TODO: all of string.encode*");
diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp
index d6f8e0f12..1b1d2cb01 100644
--- a/src/tools/fuzzing/fuzzing.cpp
+++ b/src/tools/fuzzing/fuzzing.cpp
@@ -2754,13 +2754,12 @@ Expression* TranslateToFuzzReader::makeStringNewArray() {
auto* array = makeTrappingRefUse(getArrayTypeForString());
auto* start = make(Type::i32);
auto* end = make(Type::i32);
- return builder.makeStringNew(StringNewWTF16Array, array, start, end, false);
+ return builder.makeStringNew(StringNewWTF16Array, array, start, end);
}
Expression* TranslateToFuzzReader::makeStringNewCodePoint() {
auto codePoint = make(Type::i32);
- return builder.makeStringNew(
- StringNewFromCodePoint, codePoint, nullptr, false);
+ return builder.makeStringNew(StringNewFromCodePoint, codePoint);
}
Expression* TranslateToFuzzReader::makeStringConst() {
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 449c03699..71de2f915 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -1121,37 +1121,22 @@ enum ASTNodes {
// stringref opcodes
- StringNewUTF8 = 0x80,
- StringNewWTF16 = 0x81,
StringConst = 0x82,
StringMeasureUTF8 = 0x83,
- StringMeasureWTF8 = 0x84,
StringMeasureWTF16 = 0x85,
- StringEncodeUTF8 = 0x86,
- StringEncodeWTF16 = 0x87,
StringConcat = 0x88,
StringEq = 0x89,
StringIsUSV = 0x8a,
- StringNewLossyUTF8 = 0x8b,
- StringNewWTF8 = 0x8c,
- StringEncodeLossyUTF8 = 0x8d,
- StringEncodeWTF8 = 0x8e,
- StringNewUTF8Try = 0x8f,
StringAsWTF16 = 0x98,
StringViewWTF16GetCodePoint = 0x9a,
StringViewWTF16Slice = 0x9c,
StringCompare = 0xa8,
StringFromCodePoint = 0xa9,
StringHash = 0xaa,
- StringNewUTF8Array = 0xb0,
StringNewWTF16Array = 0xb1,
- StringEncodeUTF8Array = 0xb2,
StringEncodeWTF16Array = 0xb3,
StringNewLossyUTF8Array = 0xb4,
- StringNewWTF8Array = 0xb5,
StringEncodeLossyUTF8Array = 0xb6,
- StringEncodeWTF8Array = 0xb7,
- StringNewUTF8ArrayTry = 0xb8,
// typed continuation opcodes
ContNew = 0xe0,
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index 784521c73..8f86b3647 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -1086,28 +1086,15 @@ public:
return ret;
}
StringNew* makeStringNew(StringNewOp op,
- Expression* ptr,
- Expression* length,
- bool try_) {
- auto* ret = wasm.allocator.alloc<StringNew>();
- ret->op = op;
- ret->ptr = ptr;
- ret->length = length;
- ret->try_ = try_;
- ret->finalize();
- return ret;
- }
- StringNew* makeStringNew(StringNewOp op,
- Expression* ptr,
- Expression* start,
- Expression* end,
- bool try_) {
+ Expression* ref,
+ Expression* start = nullptr,
+ Expression* end = nullptr) {
+ assert((start && end) != (op == StringNewFromCodePoint));
auto* ret = wasm.allocator.alloc<StringNew>();
ret->op = op;
- ret->ptr = ptr;
+ ret->ref = ref;
ret->start = start;
ret->end = end;
- ret->try_ = try_;
ret->finalize();
return ret;
}
@@ -1125,13 +1112,13 @@ public:
return ret;
}
StringEncode* makeStringEncode(StringEncodeOp op,
- Expression* ref,
- Expression* ptr,
+ Expression* str,
+ Expression* array,
Expression* start = nullptr) {
auto* ret = wasm.allocator.alloc<StringEncode>();
ret->op = op;
- ret->ref = ref;
- ret->ptr = ptr;
+ ret->str = str;
+ ret->array = array;
ret->start = start;
ret->finalize();
return ret;
diff --git a/src/wasm-delegations-fields.def b/src/wasm-delegations-fields.def
index 898c3a361..03d46020e 100644
--- a/src/wasm-delegations-fields.def
+++ b/src/wasm-delegations-fields.def
@@ -714,11 +714,9 @@ DELEGATE_FIELD_CASE_END(RefAs)
DELEGATE_FIELD_CASE_START(StringNew)
DELEGATE_FIELD_INT(StringNew, op)
-DELEGATE_FIELD_INT(StringNew, try_)
DELEGATE_FIELD_OPTIONAL_CHILD(StringNew, end)
DELEGATE_FIELD_OPTIONAL_CHILD(StringNew, start)
-DELEGATE_FIELD_OPTIONAL_CHILD(StringNew, length)
-DELEGATE_FIELD_CHILD(StringNew, ptr)
+DELEGATE_FIELD_CHILD(StringNew, ref)
DELEGATE_FIELD_CASE_END(StringNew)
DELEGATE_FIELD_CASE_START(StringConst)
@@ -733,8 +731,8 @@ DELEGATE_FIELD_CASE_END(StringMeasure)
DELEGATE_FIELD_CASE_START(StringEncode)
DELEGATE_FIELD_INT(StringEncode, op)
DELEGATE_FIELD_OPTIONAL_CHILD(StringEncode, start)
-DELEGATE_FIELD_CHILD(StringEncode, ptr)
-DELEGATE_FIELD_CHILD(StringEncode, ref)
+DELEGATE_FIELD_CHILD(StringEncode, array)
+DELEGATE_FIELD_CHILD(StringEncode, str)
DELEGATE_FIELD_CASE_END(StringEncode)
DELEGATE_FIELD_CASE_START(StringConcat)
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index bd7d78a6e..fa129f14a 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -1866,7 +1866,7 @@ public:
WASM_UNREACHABLE("unimplemented ref.as_*");
}
Flow visitStringNew(StringNew* curr) {
- Flow ptr = visit(curr->ptr);
+ Flow ptr = visit(curr->ref);
if (ptr.breaking()) {
return ptr;
}
@@ -1976,39 +1976,38 @@ public:
return Flow(NONCONSTANT_FLOW);
}
- Flow ref = visit(curr->ref);
- if (ref.breaking()) {
- return ref;
+ Flow str = visit(curr->str);
+ if (str.breaking()) {
+ return str;
}
- // TODO: "WTF-16 position treatment", as in stringview_wtf16.slice?
- Flow ptr = visit(curr->ptr);
- if (ptr.breaking()) {
- return ptr;
+ Flow array = visit(curr->array);
+ if (array.breaking()) {
+ return array;
}
Flow start = visit(curr->start);
if (start.breaking()) {
return start;
}
- auto refData = ref.getSingleValue().getGCData();
- auto ptrData = ptr.getSingleValue().getGCData();
- if (!refData || !ptrData) {
+ auto strData = str.getSingleValue().getGCData();
+ auto arrayData = array.getSingleValue().getGCData();
+ if (!strData || !arrayData) {
trap("null ref");
}
auto startVal = start.getSingleValue().getUnsigned();
- auto& refValues = refData->values;
- auto& ptrValues = ptrData->values;
+ auto& strValues = strData->values;
+ auto& arrayValues = arrayData->values;
size_t end;
- if (std::ckd_add<size_t>(&end, startVal, refValues.size()) ||
- end > ptrValues.size()) {
+ if (std::ckd_add<size_t>(&end, startVal, strValues.size()) ||
+ end > arrayValues.size()) {
trap("oob");
}
- for (Index i = 0; i < refValues.size(); i++) {
- ptrValues[startVal + i] = refValues[i];
+ for (Index i = 0; i < strValues.size(); i++) {
+ arrayValues[startVal + i] = strValues[i];
}
- return Literal(int32_t(refData->values.size()));
+ return Literal(int32_t(strData->values.size()));
}
Flow visitStringEq(StringEq* curr) {
NOTE_ENTER("StringEq");
diff --git a/src/wasm-ir-builder.h b/src/wasm-ir-builder.h
index 17ec28f2f..16c3b7570 100644
--- a/src/wasm-ir-builder.h
+++ b/src/wasm-ir-builder.h
@@ -206,10 +206,10 @@ public:
[[nodiscard]] Result<> makeArrayInitData(HeapType type, Name data);
[[nodiscard]] Result<> makeArrayInitElem(HeapType type, Name elem);
[[nodiscard]] Result<> makeRefAs(RefAsOp op);
- [[nodiscard]] Result<> makeStringNew(StringNewOp op, bool try_, Name mem);
+ [[nodiscard]] Result<> makeStringNew(StringNewOp op);
[[nodiscard]] Result<> makeStringConst(Name string);
[[nodiscard]] Result<> makeStringMeasure(StringMeasureOp op);
- [[nodiscard]] Result<> makeStringEncode(StringEncodeOp op, Name mem);
+ [[nodiscard]] Result<> makeStringEncode(StringEncodeOp op);
[[nodiscard]] Result<> makeStringConcat();
[[nodiscard]] Result<> makeStringEq(StringEqOp op);
[[nodiscard]] Result<> makeStringWTF8Advance();
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index cfd21661d..fe2bda1c7 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -315,7 +315,7 @@ private:
Expression* makeArrayInitElem(Element& s);
Expression* makeRefAs(Element& s, RefAsOp op);
Expression* makeRefAsNonNull(Element& s);
- Expression* makeStringNew(Element& s, StringNewOp op, bool try_);
+ Expression* makeStringNew(Element& s, StringNewOp op);
Expression* makeStringConst(Element& s);
Expression* makeStringMeasure(Element& s, StringMeasureOp op);
Expression* makeStringEncode(Element& s, StringEncodeOp op);
diff --git a/src/wasm.h b/src/wasm.h
index e39d3d527..ebb5a04f6 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -573,36 +573,18 @@ enum BrOnOp {
};
enum StringNewOp {
- // Linear memory
- StringNewUTF8,
- StringNewWTF8,
- StringNewLossyUTF8,
- StringNewWTF16,
- // GC
- StringNewUTF8Array,
- StringNewWTF8Array,
StringNewLossyUTF8Array,
StringNewWTF16Array,
- // Other
StringNewFromCodePoint,
};
enum StringMeasureOp {
StringMeasureUTF8,
- StringMeasureWTF8,
StringMeasureWTF16,
- StringMeasureIsUSV,
- StringMeasureHash,
};
enum StringEncodeOp {
- StringEncodeUTF8,
- StringEncodeLossyUTF8,
- StringEncodeWTF8,
- StringEncodeWTF16,
- StringEncodeUTF8Array,
StringEncodeLossyUTF8Array,
- StringEncodeWTF8Array,
StringEncodeWTF16Array,
};
@@ -1799,21 +1781,14 @@ public:
StringNewOp op;
- // In linear memory variations this is the pointer in linear memory. In the
- // GC variations this is an Array. In from_codepoint this is the code point.
- Expression* ptr;
-
- // Used only in linear memory variations.
- Expression* length = nullptr;
+ // In the GC variations this is an Array. In from_codepoint this is the code
+ // point.
+ Expression* ref;
// Used only in GC variations.
Expression* start = nullptr;
Expression* end = nullptr;
- // The "try" variants will return null if an encoding error happens, rather
- // than trap.
- bool try_ = false;
-
void finalize();
};
@@ -1848,16 +1823,9 @@ public:
StringEncode(MixedArena& allocator) {}
StringEncodeOp op;
-
- Expression* ref;
-
- // In linear memory variations this is the pointer in linear memory. In the
- // GC variations this is an Array.
- Expression* ptr;
-
- // Used only in GC variations, where it is the index in |ptr| to start
- // encoding from.
- Expression* start = nullptr;
+ Expression* str;
+ Expression* array;
+ Expression* start;
void finalize();
};
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index c8dd7bace..befafde59 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -7501,77 +7501,21 @@ bool WasmBinaryReader::maybeVisitArrayInit(Expression*& out, uint32_t code) {
bool WasmBinaryReader::maybeVisitStringNew(Expression*& out, uint32_t code) {
StringNewOp op;
- Expression* length = nullptr;
- Expression* start = nullptr;
- Expression* end = nullptr;
- bool try_ = false;
- if (code == BinaryConsts::StringNewUTF8) {
- // FIXME: the memory index should be an LEB like all other places
- if (getInt8() != 0) {
- throwError("Unexpected nonzero memory index");
- }
- op = StringNewUTF8;
- length = popNonVoidExpression();
- } else if (code == BinaryConsts::StringNewLossyUTF8) {
- // FIXME: the memory index should be an LEB like all other places
- if (getInt8() != 0) {
- throwError("Unexpected nonzero memory index");
- }
- op = StringNewLossyUTF8;
- length = popNonVoidExpression();
- } else if (code == BinaryConsts::StringNewWTF8) {
- // FIXME: the memory index should be an LEB like all other places
- if (getInt8() != 0) {
- throwError("Unexpected nonzero memory index");
- }
- op = StringNewWTF8;
- length = popNonVoidExpression();
- } else if (code == BinaryConsts::StringNewUTF8Try) {
- // FIXME: the memory index should be an LEB like all other places
- if (getInt8() != 0) {
- throwError("Unexpected nonzero memory index");
- }
- op = StringNewUTF8;
- try_ = true;
- length = popNonVoidExpression();
- } else if (code == BinaryConsts::StringNewWTF16) {
- if (getInt8() != 0) {
- throwError("Unexpected nonzero memory index");
- }
- op = StringNewWTF16;
- length = popNonVoidExpression();
- } else if (code == BinaryConsts::StringNewUTF8Array) {
- op = StringNewUTF8Array;
- end = popNonVoidExpression();
- start = popNonVoidExpression();
- } else if (code == BinaryConsts::StringNewLossyUTF8Array) {
+ if (code == BinaryConsts::StringNewLossyUTF8Array) {
op = StringNewLossyUTF8Array;
- end = popNonVoidExpression();
- start = popNonVoidExpression();
- } else if (code == BinaryConsts::StringNewWTF8Array) {
- op = StringNewWTF8Array;
- end = popNonVoidExpression();
- start = popNonVoidExpression();
- } else if (code == BinaryConsts::StringNewUTF8ArrayTry) {
- op = StringNewUTF8Array;
- try_ = true;
- end = popNonVoidExpression();
- start = popNonVoidExpression();
} else if (code == BinaryConsts::StringNewWTF16Array) {
op = StringNewWTF16Array;
- end = popNonVoidExpression();
- start = popNonVoidExpression();
} else if (code == BinaryConsts::StringFromCodePoint) {
- op = StringNewFromCodePoint;
+ out = Builder(wasm).makeStringNew(StringNewFromCodePoint,
+ popNonVoidExpression());
+ return true;
} else {
return false;
}
- auto* ptr = popNonVoidExpression();
- if (length) {
- out = Builder(wasm).makeStringNew(op, ptr, length, try_);
- } else {
- out = Builder(wasm).makeStringNew(op, ptr, start, end, try_);
- }
+ Expression* end = popNonVoidExpression();
+ Expression* start = popNonVoidExpression();
+ auto* ref = popNonVoidExpression();
+ out = Builder(wasm).makeStringNew(op, ref, start, end);
return true;
}
@@ -7605,14 +7549,8 @@ bool WasmBinaryReader::maybeVisitStringMeasure(Expression*& out,
StringMeasureOp op;
if (code == BinaryConsts::StringMeasureUTF8) {
op = StringMeasureUTF8;
- } else if (code == BinaryConsts::StringMeasureWTF8) {
- op = StringMeasureWTF8;
} else if (code == BinaryConsts::StringMeasureWTF16) {
op = StringMeasureWTF16;
- } else if (code == BinaryConsts::StringIsUSV) {
- op = StringMeasureIsUSV;
- } else if (code == BinaryConsts::StringHash) {
- op = StringMeasureHash;
} else {
return false;
}
@@ -7623,43 +7561,14 @@ bool WasmBinaryReader::maybeVisitStringMeasure(Expression*& out,
bool WasmBinaryReader::maybeVisitStringEncode(Expression*& out, uint32_t code) {
StringEncodeOp op;
- Expression* start = nullptr;
- // TODO: share this code with string.measure?
- if (code == BinaryConsts::StringEncodeUTF8) {
- if (getInt8() != 0) {
- throwError("Unexpected nonzero memory index");
- }
- op = StringEncodeUTF8;
- } else if (code == BinaryConsts::StringEncodeLossyUTF8) {
- if (getInt8() != 0) {
- throwError("Unexpected nonzero memory index");
- }
- op = StringEncodeLossyUTF8;
- } else if (code == BinaryConsts::StringEncodeWTF8) {
- if (getInt8() != 0) {
- throwError("Unexpected nonzero memory index");
- }
- op = StringEncodeWTF8;
- } else if (code == BinaryConsts::StringEncodeWTF16) {
- if (getInt8() != 0) {
- throwError("Unexpected nonzero memory index");
- }
- op = StringEncodeWTF16;
- } else if (code == BinaryConsts::StringEncodeUTF8Array) {
- op = StringEncodeUTF8Array;
- start = popNonVoidExpression();
- } else if (code == BinaryConsts::StringEncodeLossyUTF8Array) {
+ if (code == BinaryConsts::StringEncodeLossyUTF8Array) {
op = StringEncodeLossyUTF8Array;
- start = popNonVoidExpression();
- } else if (code == BinaryConsts::StringEncodeWTF8Array) {
- op = StringEncodeWTF8Array;
- start = popNonVoidExpression();
} else if (code == BinaryConsts::StringEncodeWTF16Array) {
op = StringEncodeWTF16Array;
- start = popNonVoidExpression();
} else {
return false;
}
+ auto* start = popNonVoidExpression();
auto* ptr = popNonVoidExpression();
auto* ref = popNonVoidExpression();
out = Builder(wasm).makeStringEncode(op, ref, ptr, start);
diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp
index a4b7becf8..bf737bbd6 100644
--- a/src/wasm/wasm-ir-builder.cpp
+++ b/src/wasm/wasm-ir-builder.cpp
@@ -1804,35 +1804,21 @@ Result<> IRBuilder::makeRefAs(RefAsOp op) {
return Ok{};
}
-Result<> IRBuilder::makeStringNew(StringNewOp op, bool try_, Name mem) {
+Result<> IRBuilder::makeStringNew(StringNewOp op) {
StringNew curr;
curr.op = op;
- // TODO: Store the memory in the IR.
- switch (op) {
- case StringNewUTF8:
- case StringNewWTF8:
- case StringNewLossyUTF8:
- case StringNewWTF16:
- CHECK_ERR(visitStringNew(&curr));
- push(builder.makeStringNew(op, curr.ptr, curr.length, try_));
- return Ok{};
- case StringNewUTF8Array:
- case StringNewWTF8Array:
- case StringNewLossyUTF8Array:
- case StringNewWTF16Array:
- // There's no type annotation on these instructions due to a bug in the
- // stringref proposal, so we just fudge it and pass `array` instead of a
- // defined heap type. This will allow us to pop a child with an invalid
- // array type, but that's just too bad.
- CHECK_ERR(ChildPopper{*this}.visitStringNew(&curr, HeapType::array));
- push(builder.makeStringNew(op, curr.ptr, curr.start, curr.end, try_));
- return Ok{};
- case StringNewFromCodePoint:
- CHECK_ERR(visitStringNew(&curr));
- push(builder.makeStringNew(op, curr.ptr, nullptr, try_));
- return Ok{};
- }
- WASM_UNREACHABLE("unexpected op");
+ if (op == StringNewFromCodePoint) {
+ CHECK_ERR(visitStringNew(&curr));
+ push(builder.makeStringNew(op, curr.ref));
+ return Ok{};
+ }
+ // There's no type annotation on these instructions due to a bug in the
+ // stringref proposal, so we just fudge it and pass `array` instead of a
+ // defined heap type. This will allow us to pop a child with an invalid
+ // array type, but that's just too bad.
+ CHECK_ERR(ChildPopper{*this}.visitStringNew(&curr, HeapType::array));
+ push(builder.makeStringNew(op, curr.ref, curr.start, curr.end));
+ return Ok{};
}
Result<> IRBuilder::makeStringConst(Name string) {
@@ -1848,33 +1834,16 @@ Result<> IRBuilder::makeStringMeasure(StringMeasureOp op) {
return Ok{};
}
-Result<> IRBuilder::makeStringEncode(StringEncodeOp op, Name mem) {
+Result<> IRBuilder::makeStringEncode(StringEncodeOp op) {
StringEncode curr;
curr.op = op;
- // TODO: Store the memory in the IR.
- switch (op) {
- case StringEncodeUTF8:
- case StringEncodeLossyUTF8:
- case StringEncodeWTF8:
- case StringEncodeWTF16: {
- CHECK_ERR(visitStringEncode(&curr));
- push(builder.makeStringEncode(op, curr.ref, curr.ptr, curr.start));
- return Ok{};
- }
- case StringEncodeUTF8Array:
- case StringEncodeLossyUTF8Array:
- case StringEncodeWTF8Array:
- case StringEncodeWTF16Array: {
- // There's no type annotation on these instructions due to a bug in the
- // stringref proposal, so we just fudge it and pass `array` instead of a
- // defined heap type. This will allow us to pop a child with an invalid
- // array type, but that's just too bad.
- CHECK_ERR(ChildPopper{*this}.visitStringEncode(&curr, HeapType::array));
- push(builder.makeStringEncode(op, curr.ref, curr.ptr, curr.start));
- return Ok{};
- }
- }
- WASM_UNREACHABLE("unexpected op");
+ // There's no type annotation on these instructions due to a bug in the
+ // stringref proposal, so we just fudge it and pass `array` instead of a
+ // defined heap type. This will allow us to pop a child with an invalid
+ // array type, but that's just too bad.
+ CHECK_ERR(ChildPopper{*this}.visitStringEncode(&curr, HeapType::array));
+ push(builder.makeStringEncode(op, curr.str, curr.array, curr.start));
+ return Ok{};
}
Result<> IRBuilder::makeStringConcat() {
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 978ea6a9b..f9eae14b8 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -3301,30 +3301,13 @@ Expression* SExpressionWasmBuilder::makeRefAs(Element& s, RefAsOp op) {
return Builder(wasm).makeRefAs(op, value);
}
-Expression*
-SExpressionWasmBuilder::makeStringNew(Element& s, StringNewOp op, bool try_) {
- Expression* length = nullptr;
- if (op == StringNewWTF8) {
- length = parseExpression(s[2]);
- return Builder(wasm).makeStringNew(op, parseExpression(s[1]), length, try_);
- } else if (op == StringNewUTF8 || op == StringNewLossyUTF8 ||
- op == StringNewWTF16) {
- length = parseExpression(s[2]);
- return Builder(wasm).makeStringNew(op, parseExpression(s[1]), length, try_);
- } else if (op == StringNewWTF8Array) {
- auto* start = parseExpression(s[2]);
- auto* end = parseExpression(s[3]);
- return Builder(wasm).makeStringNew(
- op, parseExpression(s[1]), start, end, try_);
- } else if (op == StringNewUTF8Array || op == StringNewLossyUTF8Array ||
- op == StringNewWTF16Array) {
+Expression* SExpressionWasmBuilder::makeStringNew(Element& s, StringNewOp op) {
+ if (op == StringNewLossyUTF8Array || op == StringNewWTF16Array) {
auto* start = parseExpression(s[2]);
auto* end = parseExpression(s[3]);
- return Builder(wasm).makeStringNew(
- op, parseExpression(s[1]), start, end, try_);
+ return Builder(wasm).makeStringNew(op, parseExpression(s[1]), start, end);
} else if (op == StringNewFromCodePoint) {
- return Builder(wasm).makeStringNew(
- op, parseExpression(s[1]), nullptr, try_);
+ return Builder(wasm).makeStringNew(op, parseExpression(s[1]));
} else {
throw SParseException("bad string.new op", s);
}
@@ -3350,13 +3333,9 @@ Expression* SExpressionWasmBuilder::makeStringMeasure(Element& s,
Expression* SExpressionWasmBuilder::makeStringEncode(Element& s,
StringEncodeOp op) {
- Expression* start = nullptr;
- if (op == StringEncodeWTF8Array || op == StringEncodeUTF8Array ||
- op == StringEncodeLossyUTF8Array || op == StringEncodeWTF16Array) {
- start = parseExpression(s[3]);
- }
+
return Builder(wasm).makeStringEncode(
- op, parseExpression(s[1]), parseExpression(s[2]), start);
+ op, parseExpression(s[1]), parseExpression(s[2]), parseExpression(s[3]));
}
Expression* SExpressionWasmBuilder::makeStringConcat(Element& s) {
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index a817e5294..1d7fe5255 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -2298,7 +2298,7 @@ void BinaryInstWriter::visitRefAs(RefAs* curr) {
}
void BinaryInstWriter::visitStringNew(StringNew* curr) {
- if (curr->ptr->type.isNull()) {
+ if (curr->ref->type.isNull()) {
// This is a bottom type, so this is an array-receiving operation that does
// not receive an array. The spec allows this, but V8 does not, see
// https://github.com/WebAssembly/stringref/issues/66
@@ -2308,36 +2308,6 @@ void BinaryInstWriter::visitStringNew(StringNew* curr) {
}
o << int8_t(BinaryConsts::GCPrefix);
switch (curr->op) {
- case StringNewUTF8:
- if (!curr->try_) {
- o << U32LEB(BinaryConsts::StringNewUTF8);
- } else {
- o << U32LEB(BinaryConsts::StringNewUTF8Try);
- }
- o << int8_t(0); // Memory index.
- break;
- case StringNewWTF8:
- o << U32LEB(BinaryConsts::StringNewWTF8);
- o << int8_t(0); // Memory index.
- break;
- case StringNewLossyUTF8:
- o << U32LEB(BinaryConsts::StringNewLossyUTF8);
- o << int8_t(0); // Memory index.
- break;
- case StringNewWTF16:
- o << U32LEB(BinaryConsts::StringNewWTF16);
- o << int8_t(0); // Memory index.
- break;
- case StringNewUTF8Array:
- if (!curr->try_) {
- o << U32LEB(BinaryConsts::StringNewUTF8Array);
- } else {
- o << U32LEB(BinaryConsts::StringNewUTF8ArrayTry);
- }
- break;
- case StringNewWTF8Array:
- o << U32LEB(BinaryConsts::StringNewWTF8Array);
- break;
case StringNewLossyUTF8Array:
o << U32LEB(BinaryConsts::StringNewLossyUTF8Array);
break;
@@ -2363,56 +2333,25 @@ void BinaryInstWriter::visitStringMeasure(StringMeasure* curr) {
case StringMeasureUTF8:
o << U32LEB(BinaryConsts::StringMeasureUTF8);
break;
- case StringMeasureWTF8:
- o << U32LEB(BinaryConsts::StringMeasureWTF8);
- break;
case StringMeasureWTF16:
o << U32LEB(BinaryConsts::StringMeasureWTF16);
break;
- case StringMeasureIsUSV:
- o << U32LEB(BinaryConsts::StringIsUSV);
- break;
- case StringMeasureHash:
- o << U32LEB(BinaryConsts::StringHash);
- break;
default:
WASM_UNREACHABLE("invalid string.new*");
}
}
void BinaryInstWriter::visitStringEncode(StringEncode* curr) {
- if (curr->ptr->type.isNull()) {
+ if (curr->str->type.isNull()) {
// See visitStringNew.
emitUnreachable();
return;
}
o << int8_t(BinaryConsts::GCPrefix);
switch (curr->op) {
- case StringEncodeUTF8:
- o << U32LEB(BinaryConsts::StringEncodeUTF8);
- o << int8_t(0); // Memory index.
- break;
- case StringEncodeLossyUTF8:
- o << U32LEB(BinaryConsts::StringEncodeLossyUTF8);
- o << int8_t(0); // Memory index.
- break;
- case StringEncodeWTF8:
- o << U32LEB(BinaryConsts::StringEncodeWTF8);
- o << int8_t(0); // Memory index.
- break;
- case StringEncodeWTF16:
- o << U32LEB(BinaryConsts::StringEncodeWTF16);
- o << int8_t(0); // Memory index.
- break;
- case StringEncodeUTF8Array:
- o << U32LEB(BinaryConsts::StringEncodeUTF8Array);
- break;
case StringEncodeLossyUTF8Array:
o << U32LEB(BinaryConsts::StringEncodeLossyUTF8Array);
break;
- case StringEncodeWTF8Array:
- o << U32LEB(BinaryConsts::StringEncodeWTF8Array);
- break;
case StringEncodeWTF16Array:
o << U32LEB(BinaryConsts::StringEncodeWTF16Array);
break;
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index e9bee8e08..bf7ebc620 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -3248,37 +3248,43 @@ void FunctionValidator::visitStringNew(StringNew* curr) {
"string operations require reference-types [--enable-strings]");
switch (curr->op) {
+ case StringNewLossyUTF8Array:
case StringNewWTF16Array: {
- auto ptrType = curr->ptr->type;
- if (ptrType == Type::unreachable) {
+ auto refType = curr->ref->type;
+ if (refType == Type::unreachable) {
return;
}
- if (!shouldBeTrue(ptrType.isRef(),
- curr,
- "string.new_wtf16_array input must have string type")) {
+ if (!shouldBeTrue(
+ refType.isRef(), curr, "string.new input must have array type")) {
return;
}
- auto ptrHeapType = ptrType.getHeapType();
- if (!shouldBeTrue(ptrHeapType.isBottom() || ptrHeapType.isArray(),
+ auto heapType = refType.getHeapType();
+ if (!shouldBeTrue(heapType.isBottom() || heapType.isArray(),
curr,
- "string.new_wtf16_array input must be array")) {
+ "string.new input must have array type")) {
return;
}
+ shouldBeEqualOrFirstIsUnreachable(curr->start->type,
+ Type(Type::i32),
+ curr,
+ "string.new start must be i32");
shouldBeEqualOrFirstIsUnreachable(
- curr->start->type,
- Type(Type::i32),
- curr,
- "string.new_wtf16_array start must be i32");
+ curr->end->type, Type(Type::i32), curr, "string.new end must be i32");
+ return;
+ }
+ case StringNewFromCodePoint:
shouldBeEqualOrFirstIsUnreachable(
- curr->end->type,
+ curr->ref->type,
Type(Type::i32),
curr,
- "string.new_wtf16_array end must be i32");
- break;
- }
- default: {
- }
+ "string.from_code_point code point must be i32");
+ shouldBeTrue(
+ !curr->start, curr, "string.from_code_point should not have start");
+ shouldBeTrue(
+ !curr->end, curr, "string.from_code_point should not have end");
+ return;
}
+ WASM_UNREACHABLE("unexpected op");
}
void FunctionValidator::visitStringConst(StringConst* curr) {
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 22ea4d86f..a4b9da21b 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -1244,13 +1244,12 @@ void RefAs::finalize() {
}
void StringNew::finalize() {
- if (ptr->type == Type::unreachable ||
- (length && length->type == Type::unreachable) ||
+ if (ref->type == Type::unreachable ||
(start && start->type == Type::unreachable) ||
(end && end->type == Type::unreachable)) {
type = Type::unreachable;
} else {
- type = Type(HeapType::string, try_ ? Nullable : NonNullable);
+ type = Type(HeapType::string, NonNullable);
}
}
@@ -1265,8 +1264,8 @@ void StringMeasure::finalize() {
}
void StringEncode::finalize() {
- if (ref->type == Type::unreachable || ptr->type == Type::unreachable ||
- (start && start->type == Type::unreachable)) {
+ if (str->type == Type::unreachable || array->type == Type::unreachable ||
+ start->type == Type::unreachable) {
type = Type::unreachable;
} else {
type = Type::i32;
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index 1b78ea1e7..5fb71b4d6 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -1170,82 +1170,17 @@ void test_core() {
makeInt32(module, 2)),
// Strings
BinaryenStringNew(module,
- BinaryenStringNewUTF8(),
- makeInt32(module, 0),
- makeInt32(module, 0),
- 0,
- 0,
- false),
- BinaryenStringNew(module,
- BinaryenStringNewUTF8(),
- makeInt32(module, 0),
- makeInt32(module, 0),
- 0,
- 0,
- true),
- BinaryenStringNew(module,
- BinaryenStringNewWTF8(),
- makeInt32(module, 0),
- makeInt32(module, 0),
- 0,
- 0,
- false),
- BinaryenStringNew(module,
- BinaryenStringNewLossyUTF8(),
- makeInt32(module, 0),
- makeInt32(module, 0),
- 0,
- 0,
- false),
- BinaryenStringNew(module,
- BinaryenStringNewWTF16(),
- makeInt32(module, 0),
- makeInt32(module, 0),
- 0,
- 0,
- false),
- BinaryenStringNew(module,
- BinaryenStringNewUTF8Array(),
- BinaryenGlobalGet(module, "i8Array-global", i8Array),
- 0,
- makeInt32(module, 0),
- makeInt32(module, 0),
- false),
- BinaryenStringNew(module,
- BinaryenStringNewUTF8Array(),
- BinaryenGlobalGet(module, "i8Array-global", i8Array),
- 0,
- makeInt32(module, 0),
- makeInt32(module, 0),
- true),
- BinaryenStringNew(module,
- BinaryenStringNewWTF8Array(),
- BinaryenGlobalGet(module, "i8Array-global", i8Array),
- 0,
- makeInt32(module, 0),
- makeInt32(module, 0),
- false),
- BinaryenStringNew(module,
BinaryenStringNewLossyUTF8Array(),
BinaryenGlobalGet(module, "i8Array-global", i8Array),
- 0,
- makeInt32(module, 0),
makeInt32(module, 0),
- false),
+ makeInt32(module, 0)),
BinaryenStringNew(module,
BinaryenStringNewWTF16Array(),
BinaryenGlobalGet(module, "i16Array-global", i8Array),
- 0,
- makeInt32(module, 0),
makeInt32(module, 0),
- false),
- BinaryenStringNew(module,
- BinaryenStringNewFromCodePoint(),
- makeInt32(module, 1),
- 0,
- 0,
- 0,
- false),
+ makeInt32(module, 0)),
+ BinaryenStringNew(
+ module, BinaryenStringNewFromCodePoint(), makeInt32(module, 1), 0, 0),
BinaryenStringConst(module, "hello world"),
BinaryenStringMeasure(
module,
@@ -1253,46 +1188,8 @@ void test_core() {
BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())),
BinaryenStringMeasure(
module,
- BinaryenStringMeasureWTF8(),
- BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())),
- BinaryenStringMeasure(
- module,
BinaryenStringMeasureWTF16(),
BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())),
- BinaryenStringMeasure(
- module,
- BinaryenStringMeasureIsUSV(),
- BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref())),
- BinaryenStringEncode(
- module,
- BinaryenStringEncodeUTF8(),
- BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()),
- makeInt32(module, 0),
- 0),
- BinaryenStringEncode(
- module,
- BinaryenStringEncodeLossyUTF8(),
- BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()),
- makeInt32(module, 0),
- 0),
- BinaryenStringEncode(
- module,
- BinaryenStringEncodeWTF8(),
- BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()),
- makeInt32(module, 0),
- 0),
- BinaryenStringEncode(
- module,
- BinaryenStringEncodeWTF16(),
- BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()),
- makeInt32(module, 0),
- 0),
- BinaryenStringEncode(
- module,
- BinaryenStringEncodeUTF8Array(),
- BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()),
- BinaryenGlobalGet(module, "i8Array-global", i8Array),
- makeInt32(module, 0)),
BinaryenStringEncode(
module,
BinaryenStringEncodeLossyUTF8Array(),
@@ -1301,12 +1198,6 @@ void test_core() {
makeInt32(module, 0)),
BinaryenStringEncode(
module,
- BinaryenStringEncodeWTF8Array(),
- BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()),
- BinaryenGlobalGet(module, "i8Array-global", i8Array),
- makeInt32(module, 0)),
- BinaryenStringEncode(
- module,
BinaryenStringEncodeWTF16Array(),
BinaryenGlobalGet(module, "string-global", BinaryenTypeStringref()),
BinaryenGlobalGet(module, "i16Array-global", i16Array),
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index e10c3b47b..7231ded9a 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -2337,57 +2337,6 @@ BinaryenFeatureAll: 131071
(i32.const 2)
)
(drop
- (string.new_utf8
- (i32.const 0)
- (i32.const 0)
- )
- )
- (drop
- (string.new_utf8_try
- (i32.const 0)
- (i32.const 0)
- )
- )
- (drop
- (string.new_wtf8
- (i32.const 0)
- (i32.const 0)
- )
- )
- (drop
- (string.new_lossy_utf8
- (i32.const 0)
- (i32.const 0)
- )
- )
- (drop
- (string.new_wtf16
- (i32.const 0)
- (i32.const 0)
- )
- )
- (drop
- (string.new_utf8_array
- (global.get $i8Array-global)
- (i32.const 0)
- (i32.const 0)
- )
- )
- (drop
- (string.new_utf8_array_try
- (global.get $i8Array-global)
- (i32.const 0)
- (i32.const 0)
- )
- )
- (drop
- (string.new_wtf8_array
- (global.get $i8Array-global)
- (i32.const 0)
- (i32.const 0)
- )
- )
- (drop
(string.new_lossy_utf8_array
(global.get $i8Array-global)
(i32.const 0)
@@ -2415,52 +2364,11 @@ BinaryenFeatureAll: 131071
)
)
(drop
- (string.measure_wtf8
- (global.get $string-global)
- )
- )
- (drop
(string.measure_wtf16
(global.get $string-global)
)
)
(drop
- (string.is_usv_sequence
- (global.get $string-global)
- )
- )
- (drop
- (string.encode_utf8
- (global.get $string-global)
- (i32.const 0)
- )
- )
- (drop
- (string.encode_lossy_utf8
- (global.get $string-global)
- (i32.const 0)
- )
- )
- (drop
- (string.encode_wtf8
- (global.get $string-global)
- (i32.const 0)
- )
- )
- (drop
- (string.encode_wtf16
- (global.get $string-global)
- (i32.const 0)
- )
- )
- (drop
- (string.encode_utf8_array
- (global.get $string-global)
- (global.get $i8Array-global)
- (i32.const 0)
- )
- )
- (drop
(string.encode_lossy_utf8_array
(global.get $string-global)
(global.get $i8Array-global)
@@ -2468,13 +2376,6 @@ BinaryenFeatureAll: 131071
)
)
(drop
- (string.encode_wtf8_array
- (global.get $string-global)
- (global.get $i8Array-global)
- (i32.const 0)
- )
- )
- (drop
(string.encode_wtf16_array
(global.get $string-global)
(global.get $i16Array-global)
diff --git a/test/lit/passes/simplify-locals-strings.wast b/test/lit/passes/simplify-locals-strings.wast
index d03875652..b4b2adc88 100644
--- a/test/lit/passes/simplify-locals-strings.wast
+++ b/test/lit/passes/simplify-locals-strings.wast
@@ -10,185 +10,9 @@
;; CHECK: (type $array16 (sub (array (mut i16))))
(type $array16 (sub (array (mut i16))))
- ;; CHECK: (func $no-new-past-store (type $1)
+ ;; CHECK: (func $no-new-past-store (type $2) (param $array (ref $array)) (param $array16 (ref $array16))
;; CHECK-NEXT: (local $temp stringref)
;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (string.new_utf8
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: (i32.const 2)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (i32.store
- ;; CHECK-NEXT: (i32.const 3)
- ;; CHECK-NEXT: (i32.const 4)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (string.new_wtf8
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: (i32.const 2)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (i32.store
- ;; CHECK-NEXT: (i32.const 3)
- ;; CHECK-NEXT: (i32.const 4)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (string.new_lossy_utf8
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: (i32.const 2)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (i32.store
- ;; CHECK-NEXT: (i32.const 3)
- ;; CHECK-NEXT: (i32.const 4)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (string.new_wtf16
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: (i32.const 2)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (i32.store
- ;; CHECK-NEXT: (i32.const 3)
- ;; CHECK-NEXT: (i32.const 4)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- (func $no-new-past-store
- (local $temp stringref)
- ;; A string.new cannot be moved past a memory store.
- (local.set $temp
- (string.new_utf8
- (i32.const 1)
- (i32.const 2)
- )
- )
- (i32.store
- (i32.const 3)
- (i32.const 4)
- )
- (drop
- (local.get $temp)
- )
- (local.set $temp
- (string.new_wtf8
- (i32.const 1)
- (i32.const 2)
- )
- )
- (i32.store
- (i32.const 3)
- (i32.const 4)
- )
- (drop
- (local.get $temp)
- )
- (local.set $temp
- (string.new_lossy_utf8
- (i32.const 1)
- (i32.const 2)
- )
- )
- (i32.store
- (i32.const 3)
- (i32.const 4)
- )
- (drop
- (local.get $temp)
- )
- (local.set $temp
- (string.new_wtf16
- (i32.const 1)
- (i32.const 2)
- )
- )
- (i32.store
- (i32.const 3)
- (i32.const 4)
- )
- (drop
- (local.get $temp)
- )
- )
-
- ;; CHECK: (func $yes-new-past-store (type $1)
- ;; CHECK-NEXT: (local $temp stringref)
- ;; CHECK-NEXT: (nop)
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (i32.load
- ;; CHECK-NEXT: (i32.const 3)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_utf8
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: (i32.const 2)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- (func $yes-new-past-store
- (local $temp stringref)
- ;; A string.new can be moved past a memory load.
- (local.set $temp
- (string.new_utf8
- (i32.const 1)
- (i32.const 2)
- )
- )
- (drop
- (i32.load
- (i32.const 3)
- )
- )
- (drop
- (local.get $temp)
- )
- )
-
- ;; CHECK: (func $no-new-past-store-gc (type $3) (param $array (ref $array)) (param $array16 (ref $array16))
- ;; CHECK-NEXT: (local $temp stringref)
- ;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (string.new_utf8_array
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: (i32.const 2)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (array.set $array
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 3)
- ;; CHECK-NEXT: (i32.const 4)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (string.new_wtf8_array
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: (i32.const 2)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (array.set $array
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 3)
- ;; CHECK-NEXT: (i32.const 4)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.set $temp
;; CHECK-NEXT: (string.new_lossy_utf8_array
;; CHECK-NEXT: (local.get $array)
;; CHECK-NEXT: (i32.const 1)
@@ -219,40 +43,10 @@
;; CHECK-NEXT: (local.get $temp)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
- (func $no-new-past-store-gc (param $array (ref $array)) (param $array16 (ref $array16))
+ (func $no-new-past-store (param $array (ref $array)) (param $array16 (ref $array16))
(local $temp stringref)
;; A string.new_***_array cannot be moved past a GC store.
(local.set $temp
- (string.new_utf8_array
- (local.get $array)
- (i32.const 1)
- (i32.const 2)
- )
- )
- (array.set $array
- (local.get $array)
- (i32.const 3)
- (i32.const 4)
- )
- (drop
- (local.get $temp)
- )
- (local.set $temp
- (string.new_wtf8_array
- (local.get $array)
- (i32.const 1)
- (i32.const 2)
- )
- )
- (array.set $array
- (local.get $array)
- (i32.const 3)
- (i32.const 4)
- )
- (drop
- (local.get $temp)
- )
- (local.set $temp
(string.new_lossy_utf8_array
(local.get $array)
(i32.const 1)
@@ -284,119 +78,37 @@
)
)
- ;; CHECK: (func $no-load-past-encode (type $4) (param $ref stringref)
- ;; CHECK-NEXT: (local $temp i32)
- ;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (i32.load
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_wtf8
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (i32.const 10)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (i32.load
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_utf8
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (i32.const 20)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (i32.load
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
+ ;; CHECK: (func $yes-new-past-load (type $3) (param $array16 (ref $array16))
+ ;; CHECK-NEXT: (local $temp stringref)
+ ;; CHECK-NEXT: (nop)
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_lossy_utf8
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (i32.const 30)
+ ;; CHECK-NEXT: (array.get_u $array16
+ ;; CHECK-NEXT: (local.get $array16)
+ ;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (i32.load
+ ;; CHECK-NEXT: (string.new_wtf16_array
+ ;; CHECK-NEXT: (local.get $array16)
;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: (i32.const 2)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_wtf16
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (i32.const 40)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
;; CHECK-NEXT: )
- (func $no-load-past-encode (param $ref stringref)
- (local $temp i32)
- ;; string.encode writes to memory, so a load can't be moved past it.
- (local.set $temp
- (i32.load
- (i32.const 1)
- )
- )
- (drop
- (string.encode_wtf8
- (local.get $ref)
- (i32.const 10)
- )
- )
- (drop
- (local.get $temp)
- )
- (local.set $temp
- (i32.load
- (i32.const 1)
- )
- )
- (drop
- (string.encode_utf8
- (local.get $ref)
- (i32.const 20)
- )
- )
- (drop
- (local.get $temp)
- )
- (local.set $temp
- (i32.load
- (i32.const 1)
- )
- )
- (drop
- (string.encode_lossy_utf8
- (local.get $ref)
- (i32.const 30)
- )
- )
- (drop
- (local.get $temp)
- )
+ (func $yes-new-past-load (param $array16 (ref $array16))
+ (local $temp stringref)
+ ;; A string.new can be moved past an array load.
(local.set $temp
- (i32.load
+ (string.new_wtf16_array
+ (local.get $array16)
(i32.const 1)
+ (i32.const 2)
)
)
(drop
- (string.encode_wtf16
- (local.get $ref)
- (i32.const 40)
+ (array.get $array16
+ (local.get $array16)
+ (i32.const 0)
)
)
(drop
@@ -404,7 +116,7 @@
)
)
- ;; CHECK: (func $no-load-past-encode-gc (type $5) (param $ref stringref) (param $array (ref $array)) (param $array16 (ref $array16))
+ ;; CHECK: (func $no-load-past-encode (type $4) (param $ref stringref) (param $array (ref $array)) (param $array16 (ref $array16))
;; CHECK-NEXT: (local $temp i32)
;; CHECK-NEXT: (local.set $temp
;; CHECK-NEXT: (array.get_u $array
@@ -413,42 +125,10 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_wtf8_array
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 10)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (array.get_u $array
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 0)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_utf8_array
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 20)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $temp)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.set $temp
- ;; CHECK-NEXT: (array.get_u $array
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 0)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
;; CHECK-NEXT: (string.encode_lossy_utf8_array
;; CHECK-NEXT: (local.get $ref)
;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 30)
+ ;; CHECK-NEXT: (i32.const 10)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
@@ -464,14 +144,14 @@
;; CHECK-NEXT: (string.encode_wtf16_array
;; CHECK-NEXT: (local.get $ref)
;; CHECK-NEXT: (local.get $array16)
- ;; CHECK-NEXT: (i32.const 40)
+ ;; CHECK-NEXT: (i32.const 20)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (local.get $temp)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
- (func $no-load-past-encode-gc (param $ref stringref) (param $array (ref $array)) (param $array16 (ref $array16))
+ (func $no-load-past-encode (param $ref stringref) (param $array (ref $array)) (param $array16 (ref $array16))
(local $temp i32)
;; string.encode_*_array writes to an array, so an array get can't be moved
;; past it.
@@ -482,42 +162,10 @@
)
)
(drop
- (string.encode_wtf8_array
- (local.get $ref)
- (local.get $array)
- (i32.const 10)
- )
- )
- (drop
- (local.get $temp)
- )
- (local.set $temp
- (array.get $array
- (local.get $array)
- (i32.const 0)
- )
- )
- (drop
- (string.encode_utf8_array
- (local.get $ref)
- (local.get $array)
- (i32.const 20)
- )
- )
- (drop
- (local.get $temp)
- )
- (local.set $temp
- (array.get $array
- (local.get $array)
- (i32.const 0)
- )
- )
- (drop
(string.encode_lossy_utf8_array
(local.get $ref)
(local.get $array)
- (i32.const 30)
+ (i32.const 10)
)
)
(drop
@@ -533,7 +181,7 @@
(string.encode_wtf16_array
(local.get $ref)
(local.get $array16)
- (i32.const 40)
+ (i32.const 20)
)
)
(drop
diff --git a/test/lit/strings.wast b/test/lit/strings.wast
index c06a3ead4..8c72ea7cc 100644
--- a/test/lit/strings.wast
+++ b/test/lit/strings.wast
@@ -14,91 +14,29 @@
(module
(memory 10 10)
- ;; CHECK: (type $0 (func (param stringref)))
-
- ;; CHECK: (type $1 (func (param stringref stringref)))
+ ;; CHECK: (type $0 (func (param stringref stringref)))
;; CHECK: (type $array (sub (array (mut i8))))
(type $array (sub (array (mut i8))))
;; CHECK: (type $array16 (sub (array (mut i16))))
(type $array16 (sub (array (mut i16))))
- ;; CHECK: (type $4 (func (param stringref stringref (ref string))))
-
- ;; CHECK: (type $5 (func (param (ref string))))
-
- ;; CHECK: (type $6 (func (param (ref $array) (ref $array16))))
+ ;; CHECK: (type $3 (func (param (ref string))))
- ;; CHECK: (type $7 (func (param stringref (ref $array) (ref $array16))))
+ ;; CHECK: (type $4 (func (param stringref)))
- ;; CHECK: (type $8 (func))
+ ;; CHECK: (type $5 (func (param (ref $array) (ref $array16))))
- ;; CHECK: (type $9 (func (param (ref $array))))
+ ;; CHECK: (type $6 (func (param stringref (ref $array) (ref $array16))))
- ;; CHECK: (type $10 (func (param stringref) (result i32)))
+ ;; CHECK: (type $7 (func))
;; CHECK: (global $string-const stringref (string.const "string in a global \c2\a3_\e2\82\ac_\f0\90\8d\88 \01\00\t\t\n\n\r\r\"\"\'\'\\\\ "))
(global $string-const stringref (string.const "string in a global \C2\A3_\E2\82\AC_\F0\90\8D\88 \01\00\t\t\n\n\r\r\"\"\'\'\\\\ "))
;; CHECK: (memory $0 10 10)
- ;; CHECK: (func $string.new (type $4) (param $a stringref) (param $b stringref) (param $c (ref string))
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_wtf16
- ;; CHECK-NEXT: (i32.const 7)
- ;; CHECK-NEXT: (i32.const 8)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_utf8
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: (i32.const 2)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_wtf8
- ;; CHECK-NEXT: (i32.const 3)
- ;; CHECK-NEXT: (i32.const 4)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_lossy_utf8
- ;; CHECK-NEXT: (i32.const 5)
- ;; CHECK-NEXT: (i32.const 6)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- (func $string.new
- (param $a stringref)
- (param $b (ref null string))
- (param $c (ref string))
- (drop
- (string.new_wtf16
- (i32.const 7)
- (i32.const 8)
- )
- )
- (drop
- (string.new_utf8
- (i32.const 1)
- (i32.const 2)
- )
- )
- (drop
- (string.new_wtf8
- (i32.const 3)
- (i32.const 4)
- )
- )
- (drop
- (string.new_lossy_utf8
- (i32.const 5)
- (i32.const 6)
- )
- )
- )
-
- ;; CHECK: (func $string.const (type $5) (param $param (ref string))
+ ;; CHECK: (func $string.const (type $3) (param $param (ref string))
;; CHECK-NEXT: (call $string.const
;; CHECK-NEXT: (string.const "foo")
;; CHECK-NEXT: )
@@ -122,20 +60,15 @@
)
)
- ;; CHECK: (func $string.measure (type $0) (param $ref stringref)
+ ;; CHECK: (func $string.measure (type $4) (param $ref stringref)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.eqz
- ;; CHECK-NEXT: (string.measure_wtf8
+ ;; CHECK-NEXT: (string.measure_wtf16
;; CHECK-NEXT: (local.get $ref)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.measure_wtf16
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
;; CHECK-NEXT: (string.measure_utf8
;; CHECK-NEXT: (local.get $ref)
;; CHECK-NEXT: )
@@ -144,85 +77,19 @@
(func $string.measure (param $ref stringref)
(drop
(i32.eqz ;; validate the output is i32
- (string.measure_wtf8
+ (string.measure_wtf16
(local.get $ref)
)
)
)
(drop
- (string.measure_wtf16
- (local.get $ref)
- )
- )
- (drop
(string.measure_utf8
(local.get $ref)
)
)
)
- ;; CHECK: (func $string.encode (type $0) (param $ref stringref)
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (i32.eqz
- ;; CHECK-NEXT: (string.encode_wtf8
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (i32.const 10)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (i32.eqz
- ;; CHECK-NEXT: (string.encode_lossy_utf8
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (i32.const 10)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_wtf16
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (i32.const 30)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_utf8
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (i32.const 20)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- (func $string.encode (param $ref stringref)
- (drop
- (i32.eqz ;; validate the output is i32
- (string.encode_wtf8
- (local.get $ref)
- (i32.const 10)
- )
- )
- )
- (drop
- (i32.eqz ;; validate the output is i32
- (string.encode_lossy_utf8
- (local.get $ref)
- (i32.const 10)
- )
- )
- )
- (drop
- (string.encode_wtf16
- (local.get $ref)
- (i32.const 30)
- )
- )
- (drop
- (string.encode_utf8
- (local.get $ref)
- (i32.const 20)
- )
- )
- )
-
- ;; CHECK: (func $string.concat (type $1) (param $a stringref) (param $b stringref)
+ ;; CHECK: (func $string.concat (type $0) (param $a stringref) (param $b stringref)
;; CHECK-NEXT: (local.set $a
;; CHECK-NEXT: (string.concat
;; CHECK-NEXT: (local.get $a)
@@ -239,7 +106,7 @@
)
)
- ;; CHECK: (func $string.eq (type $1) (param $a stringref) (param $b stringref)
+ ;; CHECK: (func $string.eq (type $0) (param $a stringref) (param $b stringref)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.eqz
;; CHECK-NEXT: (string.eq
@@ -260,7 +127,7 @@
)
)
- ;; CHECK: (func $string.compare (type $1) (param $a stringref) (param $b stringref)
+ ;; CHECK: (func $string.compare (type $0) (param $a stringref) (param $b stringref)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.eqz
;; CHECK-NEXT: (string.compare
@@ -281,26 +148,7 @@
)
)
- ;; CHECK: (func $string.is_usv_sequence (type $0) (param $ref stringref)
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (i32.eqz
- ;; CHECK-NEXT: (string.is_usv_sequence
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- (func $string.is_usv_sequence (param $ref stringref)
- (drop
- (i32.eqz ;; validate the output is i32
- (string.is_usv_sequence
- (local.get $ref)
- )
- )
- )
- )
-
- ;; CHECK: (func $string.new.gc (type $6) (param $array (ref $array)) (param $array16 (ref $array16))
+ ;; CHECK: (func $string.new.gc (type $5) (param $array (ref $array)) (param $array16 (ref $array16))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (string.new_wtf16_array
;; CHECK-NEXT: (local.get $array16)
@@ -309,20 +157,6 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_utf8_array
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: (i32.const 2)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_wtf8_array
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 3)
- ;; CHECK-NEXT: (i32.const 4)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
;; CHECK-NEXT: (string.new_lossy_utf8_array
;; CHECK-NEXT: (local.get $array)
;; CHECK-NEXT: (i32.const 5)
@@ -339,20 +173,6 @@
)
)
(drop
- (string.new_utf8_array
- (local.get $array)
- (i32.const 1)
- (i32.const 2)
- )
- )
- (drop
- (string.new_wtf8_array
- (local.get $array)
- (i32.const 3)
- (i32.const 4)
- )
- )
- (drop
(string.new_lossy_utf8_array
(local.get $array)
(i32.const 5)
@@ -361,7 +181,7 @@
)
)
- ;; CHECK: (func $string.encode.gc (type $7) (param $ref stringref) (param $array (ref $array)) (param $array16 (ref $array16))
+ ;; CHECK: (func $string.encode.gc (type $6) (param $ref stringref) (param $array (ref $array)) (param $array16 (ref $array16))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.eqz
;; CHECK-NEXT: (string.encode_wtf16_array
@@ -372,26 +192,12 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_wtf8_array
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 10)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
;; CHECK-NEXT: (string.encode_lossy_utf8_array
;; CHECK-NEXT: (local.get $ref)
;; CHECK-NEXT: (local.get $array)
;; CHECK-NEXT: (i32.const 10)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_utf8_array
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 20)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $string.encode.gc (param $ref stringref) (param $array (ref $array)) (param $array16 (ref $array16))
(drop
@@ -404,29 +210,15 @@
)
)
(drop
- (string.encode_wtf8_array
- (local.get $ref)
- (local.get $array)
- (i32.const 10)
- )
- )
- (drop
(string.encode_lossy_utf8_array
(local.get $ref)
(local.get $array)
(i32.const 10)
)
)
- (drop
- (string.encode_utf8_array
- (local.get $ref)
- (local.get $array)
- (i32.const 20)
- )
- )
)
- ;; CHECK: (func $string.from_code_point (type $8)
+ ;; CHECK: (func $string.from_code_point (type $7)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (string.from_code_point
;; CHECK-NEXT: (i32.const 1)
@@ -440,46 +232,4 @@
)
)
)
-
- ;; CHECK: (func $string.new_try (type $9) (param $array (ref $array))
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_utf8_try
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: (i32.const 2)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_utf8_array_try
- ;; CHECK-NEXT: (local.get $array)
- ;; CHECK-NEXT: (i32.const 3)
- ;; CHECK-NEXT: (i32.const 4)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- (func $string.new_try (param $array (ref $array))
- (drop
- (string.new_utf8_try
- (i32.const 1)
- (i32.const 2)
- )
- )
- (drop
- (string.new_utf8_array_try
- (local.get $array)
- (i32.const 3)
- (i32.const 4)
- )
- )
- )
-
- ;; CHECK: (func $string.hash (type $10) (param $ref stringref) (result i32)
- ;; CHECK-NEXT: (string.hash
- ;; CHECK-NEXT: (local.get $ref)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- (func $string.hash (param $ref stringref) (result i32)
- (string.hash
- (local.get $ref)
- )
- )
)
diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast
index 68c881a62..f4b5dc16c 100644
--- a/test/lit/wat-kitchen-sink.wast
+++ b/test/lit/wat-kitchen-sink.wast
@@ -70,121 +70,117 @@
;; CHECK: (type $any-array (array (mut anyref)))
- ;; CHECK: (type $29 (func (param stringref)))
+ ;; CHECK: (type $29 (func (param stringref stringref) (result i32)))
- ;; CHECK: (type $30 (func (param stringref stringref) (result i32)))
+ ;; CHECK: (type $30 (func (param i64 v128) (result v128)))
- ;; CHECK: (type $31 (func (param i64 v128) (result v128)))
-
- ;; CHECK: (type $32 (func (param i64 v128)))
+ ;; CHECK: (type $31 (func (param i64 v128)))
;; CHECK: (type $cont-bind-before-func (func (param i32 i64 i32 i64) (result f32)))
;; CHECK: (type $cont-bind-before (cont $cont-bind-before-func))
- ;; CHECK: (type $35 (func (result structref arrayref)))
-
- ;; CHECK: (type $36 (func (result arrayref structref)))
+ ;; CHECK: (type $34 (func (result structref arrayref)))
- ;; CHECK: (type $37 (func (result i32 i64 (ref null $simple-cont))))
+ ;; CHECK: (type $35 (func (result arrayref structref)))
- ;; CHECK: (type $38 (func (param i32 i32)))
+ ;; CHECK: (type $36 (func (result i32 i64 (ref null $simple-cont))))
- ;; CHECK: (type $39 (func (param exnref)))
+ ;; CHECK: (type $37 (func (param i32 i32)))
- ;; CHECK: (type $40 (func (result anyref anyref)))
+ ;; CHECK: (type $38 (func (param exnref)))
- ;; CHECK: (type $41 (func (param i32 i32 f64 f64)))
+ ;; CHECK: (type $39 (func (result anyref anyref)))
- ;; CHECK: (type $42 (func (param i64)))
+ ;; CHECK: (type $40 (func (param i32 i32 f64 f64)))
- ;; CHECK: (type $43 (func (param v128) (result i32)))
+ ;; CHECK: (type $41 (func (param i64)))
- ;; CHECK: (type $44 (func (param v128 v128) (result v128)))
+ ;; CHECK: (type $42 (func (param v128) (result i32)))
- ;; CHECK: (type $45 (func (param v128 v128 v128) (result v128)))
+ ;; CHECK: (type $43 (func (param v128 v128) (result v128)))
- ;; CHECK: (type $46 (func (param i32 i32 i64 i64)))
+ ;; CHECK: (type $44 (func (param v128 v128 v128) (result v128)))
- ;; CHECK: (type $47 (func (param i64) (result i32 i64)))
+ ;; CHECK: (type $45 (func (param i32 i32 i64 i64)))
- ;; CHECK: (type $48 (func (param anyref) (result i32)))
+ ;; CHECK: (type $46 (func (param i64) (result i32 i64)))
- ;; CHECK: (type $49 (func (param eqref eqref) (result i32)))
+ ;; CHECK: (type $47 (func (param anyref) (result i32)))
- ;; CHECK: (type $50 (func (param i32) (result i31ref)))
+ ;; CHECK: (type $48 (func (param eqref eqref) (result i32)))
- ;; CHECK: (type $51 (func (param i31ref)))
+ ;; CHECK: (type $49 (func (param i32) (result i31ref)))
- ;; CHECK: (type $52 (func (param i32 i64) (result (ref $pair))))
+ ;; CHECK: (type $50 (func (param i31ref)))
- ;; CHECK: (type $53 (func (result (ref $pair))))
+ ;; CHECK: (type $51 (func (param i32 i64) (result (ref $pair))))
- ;; CHECK: (type $54 (func (param (ref $pair)) (result i32)))
+ ;; CHECK: (type $52 (func (result (ref $pair))))
- ;; CHECK: (type $55 (func (param (ref $pair)) (result i64)))
+ ;; CHECK: (type $53 (func (param (ref $pair)) (result i32)))
- ;; CHECK: (type $56 (func (param (ref null $pair)) (result i32)))
+ ;; CHECK: (type $54 (func (param (ref $pair)) (result i64)))
- ;; CHECK: (type $57 (func (param (ref $pair) i32)))
+ ;; CHECK: (type $55 (func (param (ref null $pair)) (result i32)))
- ;; CHECK: (type $58 (func (param (ref $pair) i64)))
+ ;; CHECK: (type $56 (func (param (ref $pair) i32)))
- ;; CHECK: (type $59 (func (param (ref null $pair) i64)))
+ ;; CHECK: (type $57 (func (param (ref $pair) i64)))
- ;; CHECK: (type $60 (func (param i64 i32) (result (ref $a1))))
+ ;; CHECK: (type $58 (func (param (ref null $pair) i64)))
- ;; CHECK: (type $61 (func (param i32) (result (ref $a1))))
+ ;; CHECK: (type $59 (func (param i64 i32) (result (ref $a1))))
- ;; CHECK: (type $62 (func (param i32 i32) (result (ref $a1))))
+ ;; CHECK: (type $60 (func (param i32) (result (ref $a1))))
- ;; CHECK: (type $63 (func (param (ref $a1) i32) (result i64)))
+ ;; CHECK: (type $61 (func (param i32 i32) (result (ref $a1))))
- ;; CHECK: (type $64 (func (param (ref $packed-i8) i32) (result i32)))
+ ;; CHECK: (type $62 (func (param (ref $a1) i32) (result i64)))
- ;; CHECK: (type $65 (func (param (ref $packed-i16) i32) (result i32)))
+ ;; CHECK: (type $63 (func (param (ref $packed-i8) i32) (result i32)))
- ;; CHECK: (type $66 (func (param (ref $a2) i32 f32)))
+ ;; CHECK: (type $64 (func (param (ref $packed-i16) i32) (result i32)))
- ;; CHECK: (type $67 (func (param arrayref) (result i32)))
+ ;; CHECK: (type $65 (func (param (ref $a2) i32 f32)))
- ;; CHECK: (type $68 (func (param (ref $a2) i32 (ref $a2) i32 i32)))
+ ;; CHECK: (type $66 (func (param arrayref) (result i32)))
- ;; CHECK: (type $69 (func (param (ref $a2) i32 f32 i32)))
+ ;; CHECK: (type $67 (func (param (ref $a2) i32 (ref $a2) i32 i32)))
- ;; CHECK: (type $70 (func (param (ref $a2) i32 i32 i32)))
+ ;; CHECK: (type $68 (func (param (ref $a2) i32 f32 i32)))
- ;; CHECK: (type $71 (func (param (ref $any-array) i32 i32 i32)))
+ ;; CHECK: (type $69 (func (param (ref $a2) i32 i32 i32)))
- ;; CHECK: (type $72 (func (param externref)))
+ ;; CHECK: (type $70 (func (param (ref $any-array) i32 i32 i32)))
- ;; CHECK: (type $73 (func (param i32 i32) (result stringref)))
+ ;; CHECK: (type $71 (func (param externref)))
- ;; CHECK: (type $74 (func (param (ref $packed-i8) i32 i32) (result stringref)))
+ ;; CHECK: (type $72 (func (param (ref $packed-i8) i32 i32) (result stringref)))
- ;; CHECK: (type $75 (func (param i32) (result stringref)))
+ ;; CHECK: (type $73 (func (param i32) (result stringref)))
- ;; CHECK: (type $76 (func (result (ref string))))
+ ;; CHECK: (type $74 (func (result (ref string))))
- ;; CHECK: (type $77 (func (param stringref) (result i32)))
+ ;; CHECK: (type $75 (func (param stringref)))
- ;; CHECK: (type $78 (func (param stringref (ref $packed-i8) i32) (result i32)))
+ ;; CHECK: (type $76 (func (param stringref (ref $packed-i8) i32) (result i32)))
- ;; CHECK: (type $79 (func (param stringref stringref) (result (ref string))))
+ ;; CHECK: (type $77 (func (param stringref stringref) (result (ref string))))
- ;; CHECK: (type $80 (func (param stringref i32) (result i32)))
+ ;; CHECK: (type $78 (func (param stringref i32) (result i32)))
- ;; CHECK: (type $81 (func (param stringref i32 i32) (result (ref string))))
+ ;; CHECK: (type $79 (func (param stringref i32 i32) (result (ref string))))
- ;; CHECK: (type $82 (func (param (ref $simple-cont))))
+ ;; CHECK: (type $80 (func (param (ref $simple-cont))))
;; CHECK: (type $to-f32 (func (result f32)))
;; CHECK: (type $to-f32-cont (cont $to-f32))
- ;; CHECK: (type $85 (func (param (ref $simple)) (result (ref $simple-cont))))
+ ;; CHECK: (type $83 (func (param (ref $simple)) (result (ref $simple-cont))))
- ;; CHECK: (type $86 (func (param (ref $cont-bind-before)) (result (ref $simple-cont))))
+ ;; CHECK: (type $84 (func (param (ref $cont-bind-before)) (result (ref $simple-cont))))
;; CHECK: (type $s2 (struct (field i32)))
(type $s2 (struct i32))
@@ -257,7 +253,7 @@
;; imported memories
(memory (export "mem") (export "mem2") (import "" "mem") 0)
- ;; CHECK: (type $98 (func (param (ref $s0) (ref $s1) (ref $s2) (ref $s3) (ref $s4) (ref $s5) (ref $s6) (ref $s7) (ref $s8) (ref $a0) (ref $a1) (ref $a2) (ref $a3) (ref $subvoid) (ref $submany) (ref $all-types))))
+ ;; CHECK: (type $96 (func (param (ref $s0) (ref $s1) (ref $s2) (ref $s3) (ref $s4) (ref $s5) (ref $s6) (ref $s7) (ref $s8) (ref $a0) (ref $a1) (ref $a2) (ref $a3) (ref $subvoid) (ref $submany) (ref $all-types))))
;; CHECK: (import "" "mem" (memory $mimport$0 0))
@@ -409,7 +405,7 @@
;; CHECK: (elem $passive-2 anyref (struct.new_default $s0) (struct.new_default $s0))
(elem $passive-2 anyref (item struct.new $s0) (struct.new $s0))
- ;; CHECK: (elem declare func $ref-func $ref-is-null $table-fill $table-grow $table-set)
+ ;; CHECK: (elem declare func $ref-func $table-fill $table-grow $table-set)
(elem declare func 0 1 2 3)
(elem $declare-2 declare funcref (item ref.func 0) (ref.func 1) (item (ref.func 2)))
@@ -929,7 +925,7 @@
drop
)
- ;; CHECK: (func $locals (type $38) (param $0 i32) (param $x i32)
+ ;; CHECK: (func $locals (type $37) (param $0 i32) (param $x i32)
;; CHECK-NEXT: (local $2 i32)
;; CHECK-NEXT: (local $y i32)
;; CHECK-NEXT: (drop
@@ -2546,7 +2542,7 @@
)
)
- ;; CHECK: (func $try-table-throw-ref (type $39) (param $0 exnref)
+ ;; CHECK: (func $try-table-throw-ref (type $38) (param $0 exnref)
;; CHECK-NEXT: (throw_ref
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
@@ -2936,10 +2932,10 @@
end
)
- ;; CHECK: (func $br-table-multivalue-glb (type $40) (result anyref anyref)
- ;; CHECK-NEXT: (block $a (type $36) (result arrayref structref)
+ ;; CHECK: (func $br-table-multivalue-glb (type $39) (result anyref anyref)
+ ;; CHECK-NEXT: (block $a (type $35) (result arrayref structref)
;; CHECK-NEXT: (return
- ;; CHECK-NEXT: (block $b (type $35) (result structref arrayref)
+ ;; CHECK-NEXT: (block $b (type $34) (result structref arrayref)
;; CHECK-NEXT: (br_table $a $b
;; CHECK-NEXT: (tuple.make 2
;; CHECK-NEXT: (ref.null none)
@@ -2986,7 +2982,7 @@
end
)
- ;; CHECK: (func $binary (type $41) (param $0 i32) (param $1 i32) (param $2 f64) (param $3 f64)
+ ;; CHECK: (func $binary (type $40) (param $0 i32) (param $1 i32) (param $2 f64) (param $3 f64)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.add
;; CHECK-NEXT: (local.get $0)
@@ -3011,7 +3007,7 @@
drop
)
- ;; CHECK: (func $unary (type $42) (param $0 i64)
+ ;; CHECK: (func $unary (type $41) (param $0 i64)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i64.eqz
;; CHECK-NEXT: (local.get $0)
@@ -3360,7 +3356,7 @@
drop
)
- ;; CHECK: (func $simd-extract (type $43) (param $0 v128) (result i32)
+ ;; CHECK: (func $simd-extract (type $42) (param $0 v128) (result i32)
;; CHECK-NEXT: (i32x4.extract_lane 3
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
@@ -3382,7 +3378,7 @@
i32x4.replace_lane 2
)
- ;; CHECK: (func $simd-shuffle (type $44) (param $0 v128) (param $1 v128) (result v128)
+ ;; CHECK: (func $simd-shuffle (type $43) (param $0 v128) (param $1 v128) (result v128)
;; CHECK-NEXT: (i8x16.shuffle 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -3394,7 +3390,7 @@
i8x16.shuffle 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23
)
- ;; CHECK: (func $simd-ternary (type $45) (param $0 v128) (param $1 v128) (param $2 v128) (result v128)
+ ;; CHECK: (func $simd-ternary (type $44) (param $0 v128) (param $1 v128) (param $2 v128) (result v128)
;; CHECK-NEXT: (v128.bitselect
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -3504,7 +3500,7 @@
data.drop $passive
)
- ;; CHECK: (func $memory-copy (type $46) (param $0 i32) (param $1 i32) (param $2 i64) (param $3 i64)
+ ;; CHECK: (func $memory-copy (type $45) (param $0 i32) (param $1 i32) (param $2 i64) (param $3 i64)
;; CHECK-NEXT: (memory.copy $mimport$0 $mimport$0
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -3599,7 +3595,7 @@
return
)
- ;; CHECK: (func $return-two-first-unreachable (type $47) (param $0 i64) (result i32 i64)
+ ;; CHECK: (func $return-two-first-unreachable (type $46) (param $0 i64) (result i32 i64)
;; CHECK-NEXT: (return
;; CHECK-NEXT: (tuple.make 2
;; CHECK-NEXT: (unreachable)
@@ -3652,7 +3648,7 @@
return
)
- ;; CHECK: (func $ref-is-null (type $48) (param $0 anyref) (result i32)
+ ;; CHECK: (func $ref-is-null (type $47) (param $0 anyref) (result i32)
;; CHECK-NEXT: (ref.is_null
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
@@ -3667,13 +3663,13 @@
;; CHECK-NEXT: (ref.func $ref-func)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (ref.func $ref-is-null)
+ ;; CHECK-NEXT: (ref.func $ref-func)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $ref-func
ref.func $ref-func
drop
- ref.func 158
+ ref.func 159
drop
)
@@ -3696,7 +3692,7 @@
throw $tag-pair
)
- ;; CHECK: (func $ref-eq (type $49) (param $0 eqref) (param $1 eqref) (result i32)
+ ;; CHECK: (func $ref-eq (type $48) (param $0 eqref) (param $1 eqref) (result i32)
;; CHECK-NEXT: (ref.eq
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -3873,7 +3869,7 @@
table.copy 2 $funcs
)
- ;; CHECK: (func $i31-new (type $50) (param $0 i32) (result i31ref)
+ ;; CHECK: (func $i31-new (type $49) (param $0 i32) (result i31ref)
;; CHECK-NEXT: (ref.i31
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
@@ -3883,7 +3879,7 @@
ref.i31
)
- ;; CHECK: (func $i31-get (type $51) (param $0 i31ref)
+ ;; CHECK: (func $i31-get (type $50) (param $0 i31ref)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i31.get_s
;; CHECK-NEXT: (local.get $0)
@@ -4102,7 +4098,7 @@
drop
)
- ;; CHECK: (func $struct-new (type $52) (param $0 i32) (param $1 i64) (result (ref $pair))
+ ;; CHECK: (func $struct-new (type $51) (param $0 i32) (param $1 i64) (result (ref $pair))
;; CHECK-NEXT: (struct.new $pair
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4114,14 +4110,14 @@
struct.new $pair
)
- ;; CHECK: (func $struct-new-default (type $53) (result (ref $pair))
+ ;; CHECK: (func $struct-new-default (type $52) (result (ref $pair))
;; CHECK-NEXT: (struct.new_default $pair)
;; CHECK-NEXT: )
(func $struct-new-default (result (ref $pair))
struct.new_default 14
)
- ;; CHECK: (func $struct-get-0 (type $54) (param $0 (ref $pair)) (result i32)
+ ;; CHECK: (func $struct-get-0 (type $53) (param $0 (ref $pair)) (result i32)
;; CHECK-NEXT: (struct.get $pair $first
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
@@ -4131,7 +4127,7 @@
struct.get 14 0
)
- ;; CHECK: (func $struct-get-1 (type $55) (param $0 (ref $pair)) (result i64)
+ ;; CHECK: (func $struct-get-1 (type $54) (param $0 (ref $pair)) (result i64)
;; CHECK-NEXT: (struct.get $pair $second
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
@@ -4141,7 +4137,7 @@
struct.get $pair 1
)
- ;; CHECK: (func $struct-get-named (type $56) (param $0 (ref null $pair)) (result i32)
+ ;; CHECK: (func $struct-get-named (type $55) (param $0 (ref null $pair)) (result i32)
;; CHECK-NEXT: (struct.get $pair $first
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
@@ -4151,7 +4147,7 @@
struct.get $pair $first
)
- ;; CHECK: (func $struct-set-0 (type $57) (param $0 (ref $pair)) (param $1 i32)
+ ;; CHECK: (func $struct-set-0 (type $56) (param $0 (ref $pair)) (param $1 i32)
;; CHECK-NEXT: (struct.set $pair $first
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4163,7 +4159,7 @@
struct.set $pair 0
)
- ;; CHECK: (func $struct-set-1 (type $58) (param $0 (ref $pair)) (param $1 i64)
+ ;; CHECK: (func $struct-set-1 (type $57) (param $0 (ref $pair)) (param $1 i64)
;; CHECK-NEXT: (struct.set $pair $second
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4175,7 +4171,7 @@
struct.set 14 1
)
- ;; CHECK: (func $struct-set-named (type $59) (param $0 (ref null $pair)) (param $1 i64)
+ ;; CHECK: (func $struct-set-named (type $58) (param $0 (ref null $pair)) (param $1 i64)
;; CHECK-NEXT: (struct.set $pair $second
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4187,7 +4183,7 @@
struct.set 14 $second
)
- ;; CHECK: (func $array-new (type $60) (param $0 i64) (param $1 i32) (result (ref $a1))
+ ;; CHECK: (func $array-new (type $59) (param $0 i64) (param $1 i32) (result (ref $a1))
;; CHECK-NEXT: (array.new $a1
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4199,7 +4195,7 @@
array.new $a1
)
- ;; CHECK: (func $array-new-default (type $61) (param $0 i32) (result (ref $a1))
+ ;; CHECK: (func $array-new-default (type $60) (param $0 i32) (result (ref $a1))
;; CHECK-NEXT: (array.new_default $a1
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
@@ -4209,7 +4205,7 @@
array.new_default 11
)
- ;; CHECK: (func $array-new-data (type $62) (param $0 i32) (param $1 i32) (result (ref $a1))
+ ;; CHECK: (func $array-new-data (type $61) (param $0 i32) (param $1 i32) (result (ref $a1))
;; CHECK-NEXT: (array.new_data $a1 $implicit-data
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4243,7 +4239,7 @@
drop
)
- ;; CHECK: (func $array-get (type $63) (param $0 (ref $a1)) (param $1 i32) (result i64)
+ ;; CHECK: (func $array-get (type $62) (param $0 (ref $a1)) (param $1 i32) (result i64)
;; CHECK-NEXT: (array.get $a1
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4255,7 +4251,7 @@
array.get $a1
)
- ;; CHECK: (func $array-get-s (type $64) (param $0 (ref $packed-i8)) (param $1 i32) (result i32)
+ ;; CHECK: (func $array-get-s (type $63) (param $0 (ref $packed-i8)) (param $1 i32) (result i32)
;; CHECK-NEXT: (array.get_s $packed-i8
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4267,7 +4263,7 @@
array.get_s 15
)
- ;; CHECK: (func $array-get-u (type $65) (param $0 (ref $packed-i16)) (param $1 i32) (result i32)
+ ;; CHECK: (func $array-get-u (type $64) (param $0 (ref $packed-i16)) (param $1 i32) (result i32)
;; CHECK-NEXT: (array.get_u $packed-i16
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4279,7 +4275,7 @@
array.get_u $packed-i16
)
- ;; CHECK: (func $array-set (type $66) (param $0 (ref $a2)) (param $1 i32) (param $2 f32)
+ ;; CHECK: (func $array-set (type $65) (param $0 (ref $a2)) (param $1 i32) (param $2 f32)
;; CHECK-NEXT: (array.set $a2
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4293,7 +4289,7 @@
array.set $a2
)
- ;; CHECK: (func $array-len (type $67) (param $0 arrayref) (result i32)
+ ;; CHECK: (func $array-len (type $66) (param $0 arrayref) (result i32)
;; CHECK-NEXT: (array.len
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
@@ -4303,7 +4299,7 @@
array.len
)
- ;; CHECK: (func $array-copy (type $68) (param $0 (ref $a2)) (param $1 i32) (param $2 (ref $a2)) (param $3 i32) (param $4 i32)
+ ;; CHECK: (func $array-copy (type $67) (param $0 (ref $a2)) (param $1 i32) (param $2 (ref $a2)) (param $3 i32) (param $4 i32)
;; CHECK-NEXT: (array.copy $a2 $a2
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4321,7 +4317,7 @@
array.copy $a2 $a2
)
- ;; CHECK: (func $array-fill (type $69) (param $0 (ref $a2)) (param $1 i32) (param $2 f32) (param $3 i32)
+ ;; CHECK: (func $array-fill (type $68) (param $0 (ref $a2)) (param $1 i32) (param $2 f32) (param $3 i32)
;; CHECK-NEXT: (array.fill $a2
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4337,7 +4333,7 @@
array.fill $a2
)
- ;; CHECK: (func $array-init-data (type $70) (param $0 (ref $a2)) (param $1 i32) (param $2 i32) (param $3 i32)
+ ;; CHECK: (func $array-init-data (type $69) (param $0 (ref $a2)) (param $1 i32) (param $2 i32) (param $3 i32)
;; CHECK-NEXT: (array.init_data $a2 $implicit-data
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4353,7 +4349,7 @@
array.init_data $a2 0
)
- ;; CHECK: (func $array-init-elem (type $71) (param $0 (ref $any-array)) (param $1 i32) (param $2 i32) (param $3 i32)
+ ;; CHECK: (func $array-init-elem (type $70) (param $0 (ref $any-array)) (param $1 i32) (param $2 i32) (param $3 i32)
;; CHECK-NEXT: (array.init_elem $any-array $passive-2
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4382,7 +4378,7 @@
drop
)
- ;; CHECK: (func $any-convert-extern (type $72) (param $0 externref)
+ ;; CHECK: (func $any-convert-extern (type $71) (param $0 externref)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (extern.internalize
;; CHECK-NEXT: (local.get $0)
@@ -4408,50 +4404,8 @@
drop
)
- ;; CHECK: (func $string-new (type $73) (param $0 i32) (param $1 i32) (result stringref)
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_utf8_try
- ;; CHECK-NEXT: (local.get $0)
- ;; CHECK-NEXT: (local.get $1)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_wtf8
- ;; CHECK-NEXT: (local.get $0)
- ;; CHECK-NEXT: (local.get $1)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.new_lossy_utf8
- ;; CHECK-NEXT: (local.get $0)
- ;; CHECK-NEXT: (local.get $1)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (string.new_wtf16
- ;; CHECK-NEXT: (local.get $0)
- ;; CHECK-NEXT: (local.get $1)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- (func $string-new (param i32 i32) (result stringref)
- local.get 0
- local.get 1
- string.new_utf8_try
- drop
- local.get 0
- local.get 1
- string.new_wtf8 0
- drop
- local.get 0
- local.get 1
- string.new_lossy_utf8 $mem
- drop
- local.get 0
- local.get 1
- string.new_wtf16
- )
-
- ;; CHECK: (func $string-new-gc (type $74) (param $0 (ref $packed-i8)) (param $1 i32) (param $2 i32) (result stringref)
- ;; CHECK-NEXT: (string.new_utf8_array
+ ;; CHECK: (func $string-new-gc (type $72) (param $0 (ref $packed-i8)) (param $1 i32) (param $2 i32) (result stringref)
+ ;; CHECK-NEXT: (string.new_lossy_utf8_array
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
;; CHECK-NEXT: (local.get $2)
@@ -4461,10 +4415,10 @@
local.get 0
local.get 1
local.get 2
- string.new_utf8_array
+ string.new_lossy_utf8_array
)
- ;; CHECK: (func $string-new-code-point (type $75) (param $0 i32) (result stringref)
+ ;; CHECK: (func $string-new-code-point (type $73) (param $0 i32) (result stringref)
;; CHECK-NEXT: (string.from_code_point
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
@@ -4474,7 +4428,7 @@
string.from_code_point
)
- ;; CHECK: (func $string-const (type $76) (result (ref string))
+ ;; CHECK: (func $string-const (type $74) (result (ref string))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (string.const "foobar")
;; CHECK-NEXT: )
@@ -4486,12 +4440,7 @@
string.const "\00\00\00"
)
- ;; CHECK: (func $string-measure (type $29) (param $0 stringref)
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.measure_wtf8
- ;; CHECK-NEXT: (local.get $0)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
+ ;; CHECK: (func $string-measure (type $75) (param $0 stringref)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (string.measure_utf8
;; CHECK-NEXT: (local.get $0)
@@ -4502,84 +4451,18 @@
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.is_usv_sequence
- ;; CHECK-NEXT: (local.get $0)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $string-measure (param stringref)
local.get 0
- string.measure_wtf8
- drop
- local.get 0
string.measure_utf8
drop
local.get 0
string.measure_wtf16
drop
- local.get 0
- string.is_usv_sequence
- drop
- )
-
- ;; CHECK: (func $string-hash (type $77) (param $0 stringref) (result i32)
- ;; CHECK-NEXT: (string.hash
- ;; CHECK-NEXT: (local.get $0)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- (func $string-hash (param stringref) (result i32)
- local.get 0
- string.hash
- )
-
- ;; CHECK: (func $string-encode (type $29) (param $0 stringref)
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_wtf8
- ;; CHECK-NEXT: (local.get $0)
- ;; CHECK-NEXT: (i32.const 0)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_lossy_utf8
- ;; CHECK-NEXT: (local.get $0)
- ;; CHECK-NEXT: (i32.const 1)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_utf8
- ;; CHECK-NEXT: (local.get $0)
- ;; CHECK-NEXT: (i32.const 2)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (string.encode_wtf16
- ;; CHECK-NEXT: (local.get $0)
- ;; CHECK-NEXT: (i32.const 3)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- (func $string-encode (param stringref)
- local.get 0
- i32.const 0
- string.encode_wtf8
- drop
- local.get 0
- i32.const 1
- string.encode_lossy_utf8 0
- drop
- local.get 0
- i32.const 2
- string.encode_utf8 $mem
- drop
- local.get 0
- i32.const 3
- string.encode_wtf16
- drop
)
- ;; CHECK: (func $string-encode-gc (type $78) (param $0 stringref) (param $1 (ref $packed-i8)) (param $2 i32) (result i32)
- ;; CHECK-NEXT: (string.encode_wtf8_array
+ ;; CHECK: (func $string-encode-gc (type $76) (param $0 stringref) (param $1 (ref $packed-i8)) (param $2 i32) (result i32)
+ ;; CHECK-NEXT: (string.encode_wtf16_array
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
;; CHECK-NEXT: (local.get $2)
@@ -4589,10 +4472,10 @@
local.get 0
local.get 1
local.get 2
- string.encode_wtf8_array
+ string.encode_wtf16_array
)
- ;; CHECK: (func $string-concat (type $79) (param $0 stringref) (param $1 stringref) (result (ref string))
+ ;; CHECK: (func $string-concat (type $77) (param $0 stringref) (param $1 stringref) (result (ref string))
;; CHECK-NEXT: (string.concat
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4604,7 +4487,7 @@
string.concat
)
- ;; CHECK: (func $string-eq (type $30) (param $0 stringref) (param $1 stringref) (result i32)
+ ;; CHECK: (func $string-eq (type $29) (param $0 stringref) (param $1 stringref) (result i32)
;; CHECK-NEXT: (string.eq
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4616,7 +4499,7 @@
string.eq
)
- ;; CHECK: (func $string-compare (type $30) (param $0 stringref) (param $1 stringref) (result i32)
+ ;; CHECK: (func $string-compare (type $29) (param $0 stringref) (param $1 stringref) (result i32)
;; CHECK-NEXT: (string.compare
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4628,7 +4511,7 @@
string.compare
)
- ;; CHECK: (func $string-get (type $80) (param $0 stringref) (param $1 i32) (result i32)
+ ;; CHECK: (func $string-get (type $78) (param $0 stringref) (param $1 i32) (result i32)
;; CHECK-NEXT: (stringview_wtf16.get_codeunit
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4640,7 +4523,7 @@
stringview_wtf16.get_codeunit
)
- ;; CHECK: (func $string-slice (type $81) (param $0 stringref) (param $1 i32) (param $2 i32) (result (ref string))
+ ;; CHECK: (func $string-slice (type $79) (param $0 stringref) (param $1 i32) (param $2 i32) (result (ref string))
;; CHECK-NEXT: (stringview_wtf16.slice
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $1)
@@ -4707,7 +4590,7 @@
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (call_indirect $timport$0 (type $31)
+ ;; CHECK-NEXT: (call_indirect $timport$0 (type $30)
;; CHECK-NEXT: (local.get $1)
;; CHECK-NEXT: (local.get $2)
;; CHECK-NEXT: (local.get $0)
@@ -4769,7 +4652,7 @@
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (call_indirect $timport$0 (type $31)
+ ;; CHECK-NEXT: (call_indirect $timport$0 (type $30)
;; CHECK-NEXT: (local.get $1)
;; CHECK-NEXT: (local.get $2)
;; CHECK-NEXT: (local.get $0)
@@ -4841,7 +4724,7 @@
;; CHECK-NEXT: (return_call_indirect $funcs (type $void)
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (return_call_indirect $timport$0 (type $32)
+ ;; CHECK-NEXT: (return_call_indirect $timport$0 (type $31)
;; CHECK-NEXT: (local.get $1)
;; CHECK-NEXT: (local.get $2)
;; CHECK-NEXT: (local.get $0)
@@ -4900,7 +4783,7 @@
;; CHECK-NEXT: (return_call_indirect $funcs (type $void)
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (return_call_indirect $timport$0 (type $32)
+ ;; CHECK-NEXT: (return_call_indirect $timport$0 (type $31)
;; CHECK-NEXT: (local.get $1)
;; CHECK-NEXT: (local.get $2)
;; CHECK-NEXT: (local.get $0)
@@ -4941,13 +4824,13 @@
)
)
- ;; CHECK: (func $resume (type $82) (param $ct (ref $simple-cont))
+ ;; CHECK: (func $resume (type $80) (param $ct (ref $simple-cont))
;; CHECK-NEXT: (local $f f32)
;; CHECK-NEXT: (block $label
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (block $block (result (ref $to-f32-cont))
;; CHECK-NEXT: (tuple.drop 3
- ;; CHECK-NEXT: (block $block0 (type $37) (result i32 i64 (ref null $simple-cont))
+ ;; CHECK-NEXT: (block $block0 (type $36) (result i32 i64 (ref null $simple-cont))
;; CHECK-NEXT: (local.set $f
;; CHECK-NEXT: (resume $simple-cont (tag $empty $block) (tag $tag-pair-to-pair $block0)
;; CHECK-NEXT: (i32.const 0)
@@ -4980,7 +4863,7 @@
br 0
)
- ;; CHECK: (func $contnew (type $85) (param $f (ref $simple)) (result (ref $simple-cont))
+ ;; CHECK: (func $contnew (type $83) (param $f (ref $simple)) (result (ref $simple-cont))
;; CHECK-NEXT: (cont.new $simple-cont
;; CHECK-NEXT: (local.get $f)
;; CHECK-NEXT: )
@@ -4990,7 +4873,7 @@
cont.new $simple-cont
)
- ;; CHECK: (func $contbind (type $86) (param $c (ref $cont-bind-before)) (result (ref $simple-cont))
+ ;; CHECK: (func $contbind (type $84) (param $c (ref $cont-bind-before)) (result (ref $simple-cont))
;; CHECK-NEXT: (cont.bind $cont-bind-before $simple-cont
;; CHECK-NEXT: (i32.const 123)
;; CHECK-NEXT: (i64.const 123)
@@ -5115,7 +4998,7 @@
drop
)
- ;; CHECK: (func $use-types (type $98) (param $0 (ref $s0)) (param $1 (ref $s1)) (param $2 (ref $s2)) (param $3 (ref $s3)) (param $4 (ref $s4)) (param $5 (ref $s5)) (param $6 (ref $s6)) (param $7 (ref $s7)) (param $8 (ref $s8)) (param $9 (ref $a0)) (param $10 (ref $a1)) (param $11 (ref $a2)) (param $12 (ref $a3)) (param $13 (ref $subvoid)) (param $14 (ref $submany)) (param $15 (ref $all-types))
+ ;; CHECK: (func $use-types (type $96) (param $0 (ref $s0)) (param $1 (ref $s1)) (param $2 (ref $s2)) (param $3 (ref $s3)) (param $4 (ref $s4)) (param $5 (ref $s5)) (param $6 (ref $s6)) (param $7 (ref $s7)) (param $8 (ref $s8)) (param $9 (ref $a0)) (param $10 (ref $a1)) (param $11 (ref $a2)) (param $12 (ref $a3)) (param $13 (ref $subvoid)) (param $14 (ref $submany)) (param $15 (ref $all-types))
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )
(func $use-types