diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-02-21 10:29:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 10:29:59 -0800 |
commit | a32c0eff473d39b816679a5f7c65b522886726b0 (patch) | |
tree | bb45de27ff61d2b793e5168f17af8ab0f5d820a1 | |
parent | d946d68963d4731020d7dc0e41f331e0ab89591c (diff) | |
download | binaryen-a32c0eff473d39b816679a5f7c65b522886726b0.tar.gz binaryen-a32c0eff473d39b816679a5f7c65b522886726b0.tar.bz2 binaryen-a32c0eff473d39b816679a5f7c65b522886726b0.zip |
allow traversing the inits of globals (#917)
-rw-r--r-- | src/wasm-traversal.h | 7 | ||||
-rw-r--r-- | test/passes/metrics.txt | 5 | ||||
-rw-r--r-- | test/passes/metrics.wast | 1 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h index 47f6984dd..4eb5eb0ad 100644 --- a/src/wasm-traversal.h +++ b/src/wasm-traversal.h @@ -172,6 +172,11 @@ struct Walker : public VisitorType { // Walk starting + void walkGlobal(Global* global) { + walk(global->init); + static_cast<SubType*>(this)->visitGlobal(global); + } + void walkFunction(Function* func) { setFunction(func); static_cast<SubType*>(this)->doWalkFunction(func); @@ -219,7 +224,7 @@ struct Walker : public VisitorType { self->visitExport(curr.get()); } for (auto& curr : module->globals) { - self->visitGlobal(curr.get()); + self->walkGlobal(curr.get()); } for (auto& curr : module->functions) { self->walkFunction(curr.get()); diff --git a/test/passes/metrics.txt b/test/passes/metrics.txt index 2ab45b440..d381dbc46 100644 --- a/test/passes/metrics.txt +++ b/test/passes/metrics.txt @@ -2,15 +2,16 @@ Counts [funcs] : 1 [memory-data] : 9 [table-data] : 3 - [total] : 26 + [total] : 27 [vars] : 1 binary : 1 block : 1 - const : 14 + const : 15 drop : 6 if : 4 (module (type $0 (func (param i32))) + (global $glob i32 (i32.const 1337)) (table 256 256 anyfunc) (elem (i32.const 0) $ifs $ifs $ifs) (memory $0 256 256) diff --git a/test/passes/metrics.wast b/test/passes/metrics.wast index 242b254da..be31ea23a 100644 --- a/test/passes/metrics.wast +++ b/test/passes/metrics.wast @@ -4,6 +4,7 @@ (elem (i32.const 0) $ifs $ifs $ifs) (data (i32.const 0) "\ff\ef\0f\1f\20\30\40\50\99") (type $0 (func (param i32))) + (global $glob i32 (i32.const 1337)) (func $ifs (type $0) (param $x i32) (local $y f32) (block $block0 |