From fac48d43e822aab54d3b4af3b8a9a263b46c4e07 Mon Sep 17 00:00:00 2001 From: krasimir Date: Thu, 16 Jul 2015 15:21:09 +0000 Subject: [PATCH] bugfixes in the JIT compiler for x86_64. One of the fixes is actually in GNU lightning --- src/runtime/c/pgf/jit.c | 21 +++++++++++---------- src/runtime/c/pgf/lightning/i386/core-64.h | 3 +-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/runtime/c/pgf/jit.c b/src/runtime/c/pgf/jit.c index 27a3752b4..17ce2fa57 100644 --- a/src/runtime/c/pgf/jit.c +++ b/src/runtime/c/pgf/jit.c @@ -707,19 +707,20 @@ pgf_jit_function(PgfReader* rdr, PgfAbstr* abstr, #ifdef PGF_JIT_DEBUG gu_printf(out, err, "CASE %s %03d\n", id, target); #endif - jit_insn *jump = - jit_bnei_p(jit_forward(), JIT_RET, jit_forward()); - - PgfSegmentPatch label_patch; - label_patch.segment = target; - label_patch.ref = jump; - label_patch.is_abs = false; - gu_buf_push(rdr->jit_state->segment_patches, PgfSegmentPatch, label_patch); - + jit_insn *ref1 = + jit_movi_p(JIT_R1, jit_forward()); PgfCallPatch call_patch; call_patch.cid = id; - call_patch.ref = jump-6; + call_patch.ref = ref1; gu_buf_push(rdr->jit_state->call_patches, PgfCallPatch, call_patch); + + jit_insn *ref2 = + jit_bner_p(jit_forward(), JIT_RET, JIT_R1); + PgfSegmentPatch label_patch; + label_patch.segment = target; + label_patch.ref = ref2; + label_patch.is_abs = false; + gu_buf_push(rdr->jit_state->segment_patches, PgfSegmentPatch, label_patch); break; } case PGF_INSTR_CASE_LIT: { diff --git a/src/runtime/c/pgf/lightning/i386/core-64.h b/src/runtime/c/pgf/lightning/i386/core-64.h index 848fb283b..151f5b0ff 100644 --- a/src/runtime/c/pgf/lightning/i386/core-64.h +++ b/src/runtime/c/pgf/lightning/i386/core-64.h @@ -123,8 +123,7 @@ struct jit_local_state { /* No. Need value in a register */ \ : (jit_movi_l(JIT_REXTMP, is), \ jit_addr_l(d, rs, JIT_REXTMP))) \ - /* No. Do nothing. */ \ - : 0) + : jit_movr_l(d, rs)) #define jit_addr_l(d, s1, s2) jit_opo_((d), (s1), (s2), ADDQrr((s2), (d)), ADDQrr((s1), (d)), LEAQmr(0, (s1), (s2), 1, (d)) ) #define jit_addci_l(d, rs, is) jit_qop_ ((d), (rs), (is), ADCQir((is), (d)), ADCQrr(JIT_REXTMP, (d))) #define jit_addcr_l(d, s1, s2) jit_qopr_((d), (s1), (s2), ADCQrr((s1), (d)), ADCQrr((s2), (d)) )