mirror of
https://github.com/fluencelabs/asmble
synced 2025-04-24 22:32:19 +00:00
Stopped the extra pop on get/set global. Fixes #2.
This commit is contained in:
parent
e2996212e9
commit
febb07b8b2
@ -196,8 +196,8 @@ open class InsnReworker {
|
||||
is Node.Instr.GetLocal -> PUSH_RESULT
|
||||
is Node.Instr.SetLocal -> POP_PARAM
|
||||
is Node.Instr.TeeLocal -> POP_PARAM + PUSH_RESULT
|
||||
is Node.Instr.GetGlobal -> POP_THIS + PUSH_RESULT
|
||||
is Node.Instr.SetGlobal -> POP_THIS + POP_PARAM
|
||||
is Node.Instr.GetGlobal -> PUSH_RESULT
|
||||
is Node.Instr.SetGlobal -> POP_PARAM
|
||||
is Node.Instr.I32Load, is Node.Instr.I64Load, is Node.Instr.F32Load, is Node.Instr.F64Load,
|
||||
is Node.Instr.I32Load8S, is Node.Instr.I32Load8U, is Node.Instr.I32Load16U, is Node.Instr.I32Load16S,
|
||||
is Node.Instr.I64Load8S, is Node.Instr.I64Load8U, is Node.Instr.I64Load16U, is Node.Instr.I64Load16S,
|
||||
@ -266,7 +266,6 @@ open class InsnReworker {
|
||||
}.let { (count, _) -> count }
|
||||
|
||||
companion object : InsnReworker() {
|
||||
const val POP_THIS = -1
|
||||
const val POP_PARAM = -1
|
||||
const val PUSH_RESULT = 1
|
||||
const val NOP = 0
|
||||
|
23
src/test/resources/local-spec/multi-global.wast
Normal file
23
src/test/resources/local-spec/multi-global.wast
Normal file
@ -0,0 +1,23 @@
|
||||
;; This was breaking because stack diff was wrong for get_global and set_global
|
||||
|
||||
(module
|
||||
(global $foo (mut i32) (i32.const 20))
|
||||
(func (export "test") (param $p i32) (result i32)
|
||||
(local i32)
|
||||
(get_global $foo)
|
||||
(set_local 1)
|
||||
(get_global $foo)
|
||||
(get_local $p)
|
||||
(i32.add)
|
||||
(set_global $foo)
|
||||
(get_global $foo)
|
||||
(i32.const 15)
|
||||
(i32.add)
|
||||
(i32.const -16)
|
||||
(i32.and)
|
||||
(set_global $foo)
|
||||
(get_global $foo)
|
||||
)
|
||||
)
|
||||
|
||||
(assert_return (invoke "test" (i32.const 7)) (i32.const 32))
|
Loading…
x
Reference in New Issue
Block a user