summaryrefslogtreecommitdiff
path: root/src/wasm/wasm.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-07-01 01:56:23 +0000
committerGitHub <noreply@github.com>2021-06-30 18:56:23 -0700
commitca27f40a2f1070a16ee7c0efc18ff35d342d8027 (patch)
treeab0f2b1b731737bc409db21f677b97be16f67c0f /src/wasm/wasm.cpp
parent10ef52d62468aec5762742930630e882dc5e5c0b (diff)
downloadbinaryen-ca27f40a2f1070a16ee7c0efc18ff35d342d8027.tar.gz
binaryen-ca27f40a2f1070a16ee7c0efc18ff35d342d8027.tar.bz2
binaryen-ca27f40a2f1070a16ee7c0efc18ff35d342d8027.zip
Preserve Function HeapTypes (#3952)
When using nominal types, func.ref of two functions with identical signatures but different HeapTypes will yield different types. To preserve these semantics, Functions need to track their HeapTypes, not just their Signatures. This PR replaces the Signature field in Function with a HeapType field and adds new utility methods to make it almost as simple to update and query the function HeapType as it was to update and query the Function Signature.
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r--src/wasm/wasm.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 54c82159f..5b1163ae0 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -1087,14 +1087,14 @@ void RefAs::finalize() {
}
}
-size_t Function::getNumParams() { return sig.params.size(); }
+size_t Function::getNumParams() { return getParams().size(); }
size_t Function::getNumVars() { return vars.size(); }
-size_t Function::getNumLocals() { return sig.params.size() + vars.size(); }
+size_t Function::getNumLocals() { return getParams().size() + vars.size(); }
bool Function::isParam(Index index) {
- size_t size = sig.params.size();
+ size_t size = getParams().size();
assert(index < size + vars.size());
return index < size;
}
@@ -1141,12 +1141,12 @@ Index Function::getLocalIndex(Name name) {
return iter->second;
}
-Index Function::getVarIndexBase() { return sig.params.size(); }
+Index Function::getVarIndexBase() { return getParams().size(); }
Type Function::getLocalType(Index index) {
- auto numParams = sig.params.size();
+ auto numParams = getParams().size();
if (index < numParams) {
- return sig.params[index];
+ return getParams()[index];
} else if (isVar(index)) {
return vars[index - numParams];
} else {