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-ir-builder.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-ir-builder.cpp')
-rw-r--r-- | src/wasm/wasm-ir-builder.cpp | 73 |
1 files changed, 21 insertions, 52 deletions
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() { |