summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-01-10 11:34:53 -0800
committerGitHub <noreply@github.com>2018-01-10 11:34:53 -0800
commit623e42aa7be8aa030093b204491d94f3c297d312 (patch)
tree05158ff7c3ef2856345c1650192283ed737f91fd /src/passes/Print.cpp
parent8f90b655201e4cd77196a0b90ea4f398ecfe2c56 (diff)
downloadbinaryen-623e42aa7be8aa030093b204491d94f3c297d312.tar.gz
binaryen-623e42aa7be8aa030093b204491d94f3c297d312.tar.bz2
binaryen-623e42aa7be8aa030093b204491d94f3c297d312.zip
Optimize out memory and table when possible (#1352)
We can remove the memory/table (itself, or an import if imported) if they are not used. This is pretty minor on a large wasm file, but when reading small wasts it's very noticeable to have an unused memory and table all the time.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index cfdfc09dd..7651414e0 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -735,6 +735,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
o << " anyfunc)";
}
void visitTable(Table *curr) {
+ if (!curr->exists) return;
// if table wasn't imported, declare it
if (!curr->imported) {
doIndent(o, indent);
@@ -764,6 +765,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
o << ")";
}
void visitMemory(Memory* curr) {
+ if (!curr->exists) return;
// if memory wasn't imported, declare it
if (!curr->imported) {
doIndent(o, indent);