summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-08-30 18:24:55 -0500
committerGitHub <noreply@github.com>2023-08-30 16:24:55 -0700
commit5bfb19239a15fec2d2ce44606d7c6e2b821302e1 (patch)
treea37715c090bd3ede3e1733b5c24f4ed692b47fae /src
parente8adbdda08a138c697187cad13528e9082bf3ca4 (diff)
downloadbinaryen-5bfb19239a15fec2d2ce44606d7c6e2b821302e1.tar.gz
binaryen-5bfb19239a15fec2d2ce44606d7c6e2b821302e1.tar.bz2
binaryen-5bfb19239a15fec2d2ce44606d7c6e2b821302e1.zip
Parse non-nullable tuple elements without special handling (#5910)
In the binary parser, when creating a scratch local to hold multivalue results as tuples, we previously ensured that the scratch local did not contain any non-nullable by modifying its type and inserting ref.as_non_null as necessary. Now that we properly support non-nullable elements in tuple locals, however, this parser behavior is no longer necessary. Remove it.
Diffstat (limited to 'src')
-rw-r--r--src/wasm/wasm-binary.cpp28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index d6eb3b235..011957cd3 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -3006,32 +3006,14 @@ void WasmBinaryReader::skipUnreachableCode() {
void WasmBinaryReader::pushExpression(Expression* curr) {
auto type = curr->type;
if (type.isTuple()) {
- // Store tuple to local and push individual extracted values
+ // Store tuple to local and push individual extracted values.
Builder builder(wasm);
- // Non-nullable types require special handling as they cannot be stored to
- // a local, so we may need to use a different local type than the original.
- auto localType = type;
- if (!wasm.features.hasGCNNLocals()) {
- std::vector<Type> finalTypes;
- for (auto t : type) {
- if (t.isNonNullable()) {
- t = Type(t.getHeapType(), Nullable);
- }
- finalTypes.push_back(t);
- }
- localType = Type(Tuple(finalTypes));
- }
requireFunctionContext("pushExpression-tuple");
- Index tuple = builder.addVar(currFunction, localType);
+ Index tuple = builder.addVar(currFunction, type);
expressionStack.push_back(builder.makeLocalSet(tuple, curr));
- for (Index i = 0; i < localType.size(); ++i) {
- Expression* value =
- builder.makeTupleExtract(builder.makeLocalGet(tuple, localType), i);
- if (localType[i] != type[i]) {
- // We modified this to be nullable; undo that.
- value = builder.makeRefAs(RefAsNonNull, value);
- }
- expressionStack.push_back(value);
+ for (Index i = 0; i < type.size(); ++i) {
+ expressionStack.push_back(
+ builder.makeTupleExtract(builder.makeLocalGet(tuple, type), i));
}
} else {
expressionStack.push_back(curr);