summaryrefslogtreecommitdiff
path: root/src/passes/SignatureRefining.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-03-25 16:33:53 -0700
committerGitHub <noreply@github.com>2022-03-25 16:33:53 -0700
commit11932cc31e88d3d368714fcca43df979f7694bd1 (patch)
tree889faa7d6c6e2e261970ea776e3183202e9d6cba /src/passes/SignatureRefining.cpp
parent3a1953a1f417eb2f588eeb35bf26a3df6ea8f8e1 (diff)
downloadbinaryen-11932cc31e88d3d368714fcca43df979f7694bd1.tar.gz
binaryen-11932cc31e88d3d368714fcca43df979f7694bd1.tar.bz2
binaryen-11932cc31e88d3d368714fcca43df979f7694bd1.zip
[Wasm GC] Signature Pruning (#4545)
This adds a new signature-pruning pass that prunes parameters from signature types where those parameters are never used in any function that has that type. This is similar to DeadArgumentElimination but works on a set of functions, and it can handle indirect calls. Also move a little code from SignatureRefining into a shared place to avoid duplication of logic to update signature types. This pattern happens in j2wasm code, for example if all method functions for some virtual method just return a constant and do not use the this pointer.
Diffstat (limited to 'src/passes/SignatureRefining.cpp')
-rw-r--r--src/passes/SignatureRefining.cpp20
1 files changed, 1 insertions, 19 deletions
diff --git a/src/passes/SignatureRefining.cpp b/src/passes/SignatureRefining.cpp
index 623a393c1..37ca091df 100644
--- a/src/passes/SignatureRefining.cpp
+++ b/src/passes/SignatureRefining.cpp
@@ -35,8 +35,6 @@
#include "wasm-type.h"
#include "wasm.h"
-using namespace std;
-
namespace wasm {
namespace {
@@ -227,23 +225,7 @@ struct SignatureRefining : public Pass {
CodeUpdater(*this, *module).run(runner, module);
// Rewrite the types.
- class TypeRewriter : public GlobalTypeRewriter {
- SignatureRefining& parent;
-
- public:
- TypeRewriter(Module& wasm, SignatureRefining& parent)
- : GlobalTypeRewriter(wasm), parent(parent) {}
-
- void modifySignature(HeapType oldSignatureType, Signature& sig) override {
- auto iter = parent.newSignatures.find(oldSignatureType);
- if (iter != parent.newSignatures.end()) {
- sig.params = getTempType(iter->second.params);
- sig.results = getTempType(iter->second.results);
- }
- }
- };
-
- TypeRewriter(*module, *this).update();
+ GlobalTypeRewriter::updateSignatures(newSignatures, *module);
if (refinedResults) {
// After return types change we need to propagate.