diff options
author | Thomas Lively <tlively@google.com> | 2024-05-15 12:07:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-15 12:07:34 -0700 |
commit | 6b43a5ef76149c92e216fddb0a1ee17f736b4b6e (patch) | |
tree | 7b2deb1e6924ba8f74e0b25c26cf2d9a63ad610a /src/wasm/wasm-validator.cpp | |
parent | ef4b57c2a491a2193435dccdc9305f6a79965715 (diff) | |
download | binaryen-6b43a5ef76149c92e216fddb0a1ee17f736b4b6e.tar.gz binaryen-6b43a5ef76149c92e216fddb0a1ee17f736b4b6e.tar.bz2 binaryen-6b43a5ef76149c92e216fddb0a1ee17f736b4b6e.zip |
[Strings] Remove operations not included in imported strings (#6589)
The stringref proposal has been superseded by the imported JS strings proposal,
but the former has many more operations than the latter. To reduce complexity,
remove all operations that are part of stringref but not part of imported
strings.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
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) { |