diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2021-07-01 01:56:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-30 18:56:23 -0700 |
commit | ca27f40a2f1070a16ee7c0efc18ff35d342d8027 (patch) | |
tree | ab0f2b1b731737bc409db21f677b97be16f67c0f /src/tools/wasm2c-wrapper.h | |
parent | 10ef52d62468aec5762742930630e882dc5e5c0b (diff) | |
download | binaryen-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/tools/wasm2c-wrapper.h')
-rw-r--r-- | src/tools/wasm2c-wrapper.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/tools/wasm2c-wrapper.h b/src/tools/wasm2c-wrapper.h index de235c35e..ae32ec744 100644 --- a/src/tools/wasm2c-wrapper.h +++ b/src/tools/wasm2c-wrapper.h @@ -27,7 +27,7 @@ namespace wasm { // Mangle a name in (hopefully) exactly the same way wasm2c does. -static std::string wasm2cMangle(Name name, Signature sig) { +inline std::string wasm2cMangle(Name name, Signature sig) { const char escapePrefix = 'Z'; std::string mangled = "Z_"; const char* original = name.str; @@ -78,7 +78,7 @@ static std::string wasm2cMangle(Name name, Signature sig) { return mangled; } -static std::string generateWasm2CWrapper(Module& wasm) { +inline std::string generateWasm2CWrapper(Module& wasm) { // First, emit implementations of the wasm's imports so that the wasm2c code // can call them. The names use wasm2c's name mangling. std::string ret = R"( @@ -169,7 +169,7 @@ int main(int argc, char** argv) { ret += std::string(" puts(\"[fuzz-exec] calling ") + exp->name.str + "\");\n"; - auto result = func->sig.results; + auto result = func->getResults(); // Emit the call itself. ret += " "; @@ -199,13 +199,13 @@ int main(int argc, char** argv) { ret += "(*"; // Emit the callee's name with wasm2c name mangling. - ret += wasm2cMangle(exp->name, func->sig); + ret += wasm2cMangle(exp->name, func->getSig()); ret += ")("; // Emit the parameters (all 0s, like the other wrappers). bool first = true; - for (const auto& param : func->sig.params) { + for (const auto& param : func->getParams()) { WASM_UNUSED(param); if (!first) { ret += ", "; |