summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2014-10-14 09:27:24 +0000
committerkr.angelov <kr.angelov@gmail.com>2014-10-14 09:27:24 +0000
commitf4dc2c0b6e63807d4c7e18383b348534d597aef5 (patch)
tree8e10773d6df4ccae32dca3c7ab877e5582323710 /src
parent1c2e02ad5026e92ac9b82c6c876bde4281754f21 (diff)
bugfix in the bytecode generator
Diffstat (limited to 'src')
-rw-r--r--src/compiler/GF/Compile/GenerateBC.hs4
-rw-r--r--src/runtime/c/pgf/jit.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/compiler/GF/Compile/GenerateBC.hs b/src/compiler/GF/Compile/GenerateBC.hs
index b749a40e1..3d8a7ef3a 100644
--- a/src/compiler/GF/Compile/GenerateBC.hs
+++ b/src/compiler/GF/Compile/GenerateBC.hs
@@ -68,11 +68,11 @@ compileEquations gr arity st (i:is) eqs fl bs = whilePP eqs Map.empty
(EFloat d) -> CASE_LIT (LFlt d)
compileBranch0 fl bs ((t,n),eqs) =
- let (bs1,instrs) = compileEquations gr arity (st+n) (push_is st n is) eqs fl bs
+ let (bs1,instrs) = compileEquations gr arity (st+n) (push_is (st+n-1) n is) eqs fl bs
in (bs1, case_instr t n (length bs1) : instrs)
compileBranch l bs ((t,n),eqs) =
- let (bs1,instrs) = compileEquations gr arity (st+n) (push_is st n is) eqs fl ((case_instr t n (length bs1) : instrs) : bs)
+ let (bs1,instrs) = compileEquations gr arity (st+n) (push_is (st+n-1) n is) eqs fl ((case_instr t n (length bs1) : instrs) : bs)
in bs1
mkFail st1 Nothing = FAIL
diff --git a/src/runtime/c/pgf/jit.c b/src/runtime/c/pgf/jit.c
index ab8eae1c6..c97113b5a 100644
--- a/src/runtime/c/pgf/jit.c
+++ b/src/runtime/c/pgf/jit.c
@@ -738,8 +738,8 @@ pgf_jit_function(PgfReader* rdr, PgfAbstr* abstr,
call_patch.ref = jump-6;
gu_buf_push(rdr->jit_state->call_patches, PgfCallPatch, call_patch);
- for (int i = 0; i < n; i++) {
- jit_ldxi_p(JIT_R0, JIT_VHEAP, sizeof(PgfValue)+sizeof(PgfClosure*)*i);
+ for (int i = n; i > 0; i--) {
+ jit_ldxi_p(JIT_R0, JIT_VHEAP, sizeof(PgfValue)+sizeof(PgfClosure*)*(i-1));
jit_pushr_p(JIT_R0);
}
break;