diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2014-10-22 14:11:41 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2014-10-22 14:11:41 +0000 |
| commit | c8b3865338d3399dd983b36e1e0ad17f326bdd86 (patch) | |
| tree | f482e77513e5bcb4b2cdcaaa6471c3f1f87286e8 /src/runtime/c | |
| parent | 71d5cae4e3b1c2cdd155d472f84ac1e0aad1dae7 (diff) | |
an explicit PUSH_FRAME instruction
Diffstat (limited to 'src/runtime/c')
| -rw-r--r-- | src/runtime/c/pgf/data.h | 13 | ||||
| -rw-r--r-- | src/runtime/c/pgf/jit.c | 34 |
2 files changed, 20 insertions, 27 deletions
diff --git a/src/runtime/c/pgf/data.h b/src/runtime/c/pgf/data.h index 2b11f24da..154679ac8 100644 --- a/src/runtime/c/pgf/data.h +++ b/src/runtime/c/pgf/data.h @@ -133,12 +133,13 @@ typedef enum { PGF_INSTR_PUT_LIT = 6, PGF_INSTR_SET = 7, PGF_INSTR_SET_PAD = 8, - PGF_INSTR_PUSH = 9, - PGF_INSTR_EVAL = 10, - PGF_INSTR_DROP = 13, - PGF_INSTR_JUMP = 14, - PGF_INSTR_FAIL = 15, - PGF_INSTR_ADD = 16 + PGF_INSTR_PUSH_FRAME = 9, + PGF_INSTR_PUSH = 10, + PGF_INSTR_EVAL = 11, + PGF_INSTR_DROP = 14, + PGF_INSTR_JUMP = 15, + PGF_INSTR_FAIL = 16, + PGF_INSTR_ADD = 17, } PgfInstruction; typedef GuSeq PgfConcrs; diff --git a/src/runtime/c/pgf/jit.c b/src/runtime/c/pgf/jit.c index 0b42cc91f..dbb441454 100644 --- a/src/runtime/c/pgf/jit.c +++ b/src/runtime/c/pgf/jit.c @@ -937,6 +937,15 @@ pgf_jit_function(PgfReader* rdr, PgfAbstr* abstr, curr_offset++; break; } + case PGF_INSTR_PUSH_FRAME: { +#ifdef PGF_JIT_DEBUG + gu_printf(out, err, "PUSH_FRAME\n"); +#endif + jit_pushr_p(JIT_VCLOS); + jit_pushr_p(JIT_FP); + jit_movr_p(JIT_FP, JIT_SP); + break; + } case PGF_INSTR_PUSH: { switch (mod) { case 0: { @@ -990,7 +999,6 @@ pgf_jit_function(PgfReader* rdr, PgfAbstr* abstr, } case PGF_INSTR_EVAL+0: case PGF_INSTR_EVAL+2: - jit_movr_p(JIT_R2, JIT_VCLOS); case PGF_INSTR_EVAL+1: { switch (mod) { case 0: { @@ -1039,9 +1047,6 @@ pgf_jit_function(PgfReader* rdr, PgfAbstr* abstr, #ifdef PGF_JIT_DEBUG gu_printf(out, err, "\n"); #endif - jit_pushr_p(JIT_R2); - jit_pushr_p(JIT_FP); - jit_movr_p(JIT_FP, JIT_SP); jit_callr(JIT_R0); jit_popr_p(JIT_FP); jit_popr_p(JIT_VCLOS); @@ -1072,28 +1077,15 @@ pgf_jit_function(PgfReader* rdr, PgfAbstr* abstr, gu_printf(out, err, " update(%d,%d)\n", b, c); #endif - if (b >= 3) { - jit_stxi_p(sizeof(PgfClosure*)*(c-3), JIT_SP, JIT_FP); - jit_stxi_p(sizeof(PgfClosure*)*(c-2), JIT_SP, JIT_R2); + if (b > 1) { for (size_t i = 0; i < c-b; i++) { - jit_ldxi_p(JIT_R1, JIT_SP, sizeof(PgfClosure*)*((c-b-1)-i)); - jit_stxi_p(sizeof(PgfClosure*)*((c-4)-i), JIT_SP, JIT_R1); + jit_ldxi_p(JIT_R1, JIT_SP, sizeof(PgfClosure*)*(c-b-1-i)); + jit_stxi_p(sizeof(PgfClosure*)*(c-2-i), JIT_SP, JIT_R1); } - jit_addi_p(JIT_SP, JIT_SP, (b-3)*sizeof(PgfClosure*)); - } else { - jit_subi_p(JIT_SP, JIT_SP, (3-b)*sizeof(PgfClosure*)); - for (size_t i = 0; i < c-b; i++) { - jit_ldxi_p(JIT_R1, JIT_SP, sizeof(PgfClosure*)*(i+(3-b))); - jit_stxi_p(sizeof(PgfClosure*)*i, JIT_SP, JIT_R1); - } - jit_stxi_p(sizeof(PgfClosure*)*(c-b), JIT_SP, JIT_FP); - jit_stxi_p(sizeof(PgfClosure*)*(c-b+1), JIT_SP, JIT_R2); + jit_addi_p(JIT_SP, JIT_SP, (b-1)*sizeof(PgfClosure*)); } - - jit_addi_p(JIT_FP, JIT_SP, sizeof(PgfClosure*)*(c-b)); jit_movi_p(JIT_R1, abstr->eval_gates->update_closure); jit_pushr_p(JIT_R1); - jit_jmpr(JIT_R0); break; } |
