Precompute and inline constant globals

This is necessary so that other constant globals referencing constant globals can be precomputed as well (NON_STANDALONE_FLOW in binaryen)
This commit is contained in:
dcodeIO
2017-12-06 23:38:17 +01:00
parent d63ed925a9
commit 9ae3328e58
13 changed files with 323 additions and 198 deletions

View File

@ -0,0 +1,24 @@
(module
(type $i (func (result i32)))
(type $v (func))
(global $enum/NonConstant.ZERO (mut i32) (i32.const 0))
(global $enum/NonConstant.ONE (mut i32) (i32.const 0))
(memory $0 1)
(data (i32.const 4) "\08")
(export "memory" (memory $0))
(start $start)
(func $enum/getZero (; 0 ;) (type $i) (result i32)
(i32.const 0)
)
(func $start (; 1 ;) (type $v)
(set_global $enum/NonConstant.ZERO
(call $enum/getZero)
)
(set_global $enum/NonConstant.ONE
(i32.add
(get_global $enum/NonConstant.ZERO)
(i32.const 1)
)
)
)
)