diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-06-27 16:49:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-27 16:49:09 -0700 |
commit | e26a90b337fbf31b62276afb8eb3a561544cf840 (patch) | |
tree | 4bc5004f3adb5521ace7e78d7ec0bbf33db72b90 /src/passes/Precompute.cpp | |
parent | 6f0609ae19a3124010eaceba17de02c026cbb9df (diff) | |
download | binaryen-e26a90b337fbf31b62276afb8eb3a561544cf840.tar.gz binaryen-e26a90b337fbf31b62276afb8eb3a561544cf840.tar.bz2 binaryen-e26a90b337fbf31b62276afb8eb3a561544cf840.zip |
avoid exceptions in Precompute pass (#606)
Diffstat (limited to 'src/passes/Precompute.cpp')
-rw-r--r-- | src/passes/Precompute.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp index 36f33d514..4f0a0e22d 100644 --- a/src/passes/Precompute.cpp +++ b/src/passes/Precompute.cpp @@ -35,6 +35,8 @@ namespace wasm { +Name NONSTANDALONE("Binaryen|nonstandalone"); + // Execute an expression by itself. Errors if we hit anything we need anything not in the expression itself standalone. class StandaloneExpressionRunner : public ExpressionRunner<StandaloneExpressionRunner> { public: @@ -43,32 +45,32 @@ public: Flow visitLoop(Loop* curr) { // loops might be infinite, so must be careful // but we can't tell if non-infinite, since we don't have state, so loops are just impossible to optimize for now - throw NonstandaloneException(); + return Flow(NONSTANDALONE); } Flow visitCall(Call* curr) { - throw NonstandaloneException(); + return Flow(NONSTANDALONE); } Flow visitCallImport(CallImport* curr) { - throw NonstandaloneException(); + return Flow(NONSTANDALONE); } Flow visitCallIndirect(CallIndirect* curr) { - throw NonstandaloneException(); + return Flow(NONSTANDALONE); } Flow visitGetLocal(GetLocal *curr) { - throw NonstandaloneException(); + return Flow(NONSTANDALONE); } Flow visitSetLocal(SetLocal *curr) { - throw NonstandaloneException(); + return Flow(NONSTANDALONE); } Flow visitLoad(Load *curr) { - throw NonstandaloneException(); + return Flow(NONSTANDALONE); } Flow visitStore(Store *curr) { - throw NonstandaloneException(); + return Flow(NONSTANDALONE); } Flow visitHost(Host *curr) { - throw NonstandaloneException(); + return Flow(NONSTANDALONE); } void trap(const char* why) override { @@ -90,7 +92,7 @@ struct Precompute : public WalkerPass<PostWalker<Precompute, UnifiedExpressionVi } catch (StandaloneExpressionRunner::NonstandaloneException& e) { return; } - if (flow.breaking()) return; // TODO: can create a break as a replacement + if (flow.breaking()) return; // TODO: can create a break as a replacement in some cases (not NONSTANDALONE) if (isConcreteWasmType(flow.value.type)) { replaceCurrent(Builder(*getModule()).makeConst(flow.value)); } |