summaryrefslogtreecommitdiff
path: root/src/asm2wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-07-19 16:01:15 -0700
committerGitHub <noreply@github.com>2019-07-19 16:01:15 -0700
commit88ef839433ac0cf58c2a29f369d0268a22b5ae0e (patch)
tree13488bb2eda5657d7cb440cacacab4369b7fda1e /src/asm2wasm.h
parent7bc5f1891f77e53f5a4e6905e02e80c680c728c3 (diff)
downloadbinaryen-88ef839433ac0cf58c2a29f369d0268a22b5ae0e.tar.gz
binaryen-88ef839433ac0cf58c2a29f369d0268a22b5ae0e.tar.bz2
binaryen-88ef839433ac0cf58c2a29f369d0268a22b5ae0e.zip
Simpify PassRunner.add() and automatically parallelize parallel functions (#2242)
Main change here is in pass.h, everything else is changes to work with the new API. The add("name") remains as before, while the weird variadic add(..) which constructed the pass now just gets a std::unique_ptr of a pass. This also makes the memory management internally fully automatic. And it makes it trivial to parallelize WalkerPass::run on parallel passes. As a benefit, this allows removing a lot of code since in many cases there is no need to create a new pass runner, and running a pass can be just a single line.
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r--src/asm2wasm.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index d4b4f8674..3f7206f4d 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -1068,10 +1068,10 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
passRunner.setValidateGlobally(false);
}
// run autodrop first, before optimizations
- passRunner.add<AutoDrop>();
+ passRunner.add(make_unique<AutoDrop>());
if (preprocessor.debugInfo) {
// fix up debug info to better survive optimization
- passRunner.add<AdjustDebugInfo>();
+ passRunner.add(make_unique<AdjustDebugInfo>());
}
// optimize relooper label variable usage at the wasm level, where it is
// easy
@@ -1680,7 +1680,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
}
// finalizeCalls also does autoDrop, which is crucial for the non-optimizing
// case, so that the output of the first pass is valid
- passRunner.add<FinalizeCalls>(this);
+ passRunner.add(make_unique<FinalizeCalls>(this));
passRunner.add(ABI::getLegalizationPass(legalizeJavaScriptFFI
? ABI::LegalizationLevel::Full
: ABI::LegalizationLevel::Minimal));
@@ -1697,11 +1697,11 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
if (preprocessor.debugInfo) {
// we would have run this before if optimizing, do it now otherwise. must
// precede ApplyDebugInfo
- passRunner.add<AdjustDebugInfo>();
+ passRunner.add(make_unique<AdjustDebugInfo>());
}
}
if (preprocessor.debugInfo) {
- passRunner.add<ApplyDebugInfo>();
+ passRunner.add(make_unique<ApplyDebugInfo>());
// FIXME maybe just remove the nops that were debuginfo nodes, if not
// optimizing?
passRunner.add("vacuum");