summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-07-02 10:04:48 -0700
committerGitHub <noreply@github.com>2021-07-02 10:04:48 -0700
commit98d654257cd22b4912121d022d484e4750932329 (patch)
tree9e58db97d7447258c78df71a72fe95fe66949842 /src/wasm/wasm-binary.cpp
parentd2347ff02d807fc38559d5f436eabae694562dae (diff)
downloadbinaryen-98d654257cd22b4912121d022d484e4750932329.tar.gz
binaryen-98d654257cd22b4912121d022d484e4750932329.tar.bz2
binaryen-98d654257cd22b4912121d022d484e4750932329.zip
[Wasm GC] Add support for non-nullable locals in binary reading (#3955)
We only tested that feature on the text format. For binary support, the reader needs to know that the feature is enabled, so that it allows non-nullable locals in that case (i.e., does not apply the workarounds to remove them). Fixes #3953
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 581dbd6a2..0b3ed0b53 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -2228,7 +2228,9 @@ void WasmBinaryBuilder::readFunctions() {
}
}
- TypeUpdating::handleNonDefaultableLocals(func, wasm);
+ if (!wasm.features.hasGCNNLocals()) {
+ TypeUpdating::handleNonDefaultableLocals(func, wasm);
+ }
std::swap(func->epilogLocation, debugLocation);
currFunction = nullptr;
@@ -2560,14 +2562,16 @@ void WasmBinaryBuilder::pushExpression(Expression* curr) {
Builder builder(wasm);
// Non-nullable types require special handling as they cannot be stored to
// a local.
- std::vector<Type> nullableTypes;
- for (auto t : type) {
- if (t.isRef() && !t.isNullable()) {
- t = Type(t.getHeapType(), Nullable);
+ std::vector<Type> finalTypes;
+ if (!wasm.features.hasGCNNLocals()) {
+ for (auto t : type) {
+ if (t.isRef() && !t.isNullable()) {
+ t = Type(t.getHeapType(), Nullable);
+ }
+ finalTypes.push_back(t);
}
- nullableTypes.push_back(t);
}
- auto nullableType = Type(Tuple(nullableTypes));
+ auto nullableType = Type(Tuple(finalTypes));
Index tuple = builder.addVar(currFunction, nullableType);
expressionStack.push_back(builder.makeLocalSet(tuple, curr));
for (Index i = 0; i < nullableType.size(); ++i) {