an explicit SAVE instruction

This commit is contained in:
kr.angelov
2014-10-26 11:40:12 +00:00
parent 97db991979
commit 77d3775385
5 changed files with 68 additions and 59 deletions

View File

@@ -127,19 +127,20 @@ typedef enum {
PGF_INSTR_CHECK_ARGS = 0,
PGF_INSTR_CASE = 1,
PGF_INSTR_CASE_LIT = 2,
PGF_INSTR_ALLOC = 3,
PGF_INSTR_PUT_CONSTR = 4,
PGF_INSTR_PUT_CLOSURE = 5,
PGF_INSTR_PUT_LIT = 6,
PGF_INSTR_SET = 7,
PGF_INSTR_SET_PAD = 8,
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,
PGF_INSTR_SAVE = 3,
PGF_INSTR_ALLOC = 4,
PGF_INSTR_PUT_CONSTR = 5,
PGF_INSTR_PUT_CLOSURE = 6,
PGF_INSTR_PUT_LIT = 7,
PGF_INSTR_SET = 8,
PGF_INSTR_SET_PAD = 9,
PGF_INSTR_PUSH_FRAME = 10,
PGF_INSTR_PUSH = 11,
PGF_INSTR_EVAL = 12,
PGF_INSTR_DROP = 15,
PGF_INSTR_JUMP = 16,
PGF_INSTR_FAIL = 17,
PGF_INSTR_ADD = 18,
} PgfInstruction;
typedef GuSeq PgfConcrs;

View File

@@ -689,10 +689,9 @@ pgf_jit_function(PgfReader* rdr, PgfAbstr* abstr,
}
case PGF_INSTR_CASE: {
PgfCId id = pgf_read_cid(rdr, rdr->tmp_pool);
int n = pgf_read_int(rdr);
int target = pgf_read_int(rdr);
#ifdef PGF_JIT_DEBUG
gu_printf(out, err, "CASE %s %d %03d\n", id, n, target);
gu_printf(out, err, "CASE %s %03d\n", id, target);
#endif
jit_insn *jump =
jit_bnei_i(jit_forward(), JIT_RET, (int) jit_forward());
@@ -707,11 +706,6 @@ pgf_jit_function(PgfReader* rdr, PgfAbstr* abstr,
call_patch.cid = id;
call_patch.ref = jump-6;
gu_buf_push(rdr->jit_state->call_patches, PgfCallPatch, call_patch);
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;
}
case PGF_INSTR_CASE_LIT: {
@@ -772,6 +766,15 @@ pgf_jit_function(PgfReader* rdr, PgfAbstr* abstr,
break;
}
case PGF_INSTR_SAVE: {
int i = pgf_read_int(rdr);
#ifdef PGF_JIT_DEBUG
gu_printf(out, err, "SAVE %d\n", i);
#endif
jit_ldxi_p(JIT_R0, JIT_VHEAP, sizeof(PgfValue)+sizeof(PgfClosure*)*i);
jit_pushr_p(JIT_R0);
break;
}
case PGF_INSTR_ALLOC: {
size_t size = pgf_read_int(rdr);
#ifdef PGF_JIT_DEBUG