diff --git a/src/racket/src/jit.c b/src/racket/src/jit.c index b520f7b5f7..91cfb9fac3 100644 --- a/src/racket/src/jit.c +++ b/src/racket/src/jit.c @@ -1432,8 +1432,7 @@ static int generate_non_tail_with_branch(Scheme_Object *obj, mz_jit_state *jitte using_local1 = 2; } else { /* mark stack is an integer... turn it into a pointer */ - jit_lshi_l(JIT_R2, JIT_R2, 0x1); - jit_ori_l(JIT_R2, JIT_R2, 0x1); + jit_fixnum_l(JIT_R2, JIT_R2); mz_pushr_p(JIT_R2); /* no sync */ # ifdef MZ_USE_LWC /* For lighweight continuations, we need to be able to recognize @@ -2047,8 +2046,7 @@ int scheme_generate(Scheme_Object *obj, mz_jit_state *jitter, int is_tail, int w mz_tl_ldi_p(JIT_R0, tl_scheme_current_thread); CHECK_LIMIT(); jit_ldxi_l(JIT_V1, JIT_R0, &((Scheme_Thread *)0x0)->ku.multiple.count); - jit_lshi_l(JIT_V1, JIT_V1, 0x1); - jit_ori_l(JIT_V1, JIT_V1, 0x1); + jit_fixnum_l(JIT_V1, JIT_V1); mz_pushr_p(JIT_V1); /* sync'd below */ jit_ldxi_p(JIT_V1, JIT_R0, &((Scheme_Thread *)0x0)->ku.multiple.array); mz_pushr_p(JIT_V1); /* sync'd below */ diff --git a/src/racket/src/jit.h b/src/racket/src/jit.h index cfa2525261..79437890db 100644 --- a/src/racket/src/jit.h +++ b/src/racket/src/jit.h @@ -914,6 +914,13 @@ static jit_insn *fp_tmpr; # define mz_bnei_p(a, v, i) jit_bnei_p(a, v, i) #endif +#ifdef jit_leai_l +# define jit_fixnum_l(JIT_Rdest, JIT_Rsrc) jit_leai_l(JIT_Rdest, JIT_Rsrc, 1, 1) +#else +# define jit_fixnum_l(JIT_Rdest, JIT_Rsrc) (jit_lshi_l(JIT_Rdest, JIT_Rsrc, 1), \ + jit_ori_l(JIT_Rdest, JIT_Rdest, 0x1)) +#endif + /* About short-jump mode: diff --git a/src/racket/src/jitarith.c b/src/racket/src/jitarith.c index 02ee34655b..584f0bce1b 100644 --- a/src/racket/src/jitarith.c +++ b/src/racket/src/jitarith.c @@ -590,8 +590,7 @@ static int generate_double_arith(mz_jit_state *jitter, Scheme_Object *rator, jit_roundr_d_l_fppop(JIT_R1, fpr2); /* slow path won't be needed */ #endif } - jit_lshi_l(JIT_R0, JIT_R1, 1); - jit_ori_l(JIT_R0, JIT_R0, 0x1); + jit_fixnum_l(JIT_R0, JIT_R1); no_alloc = 1; break; case ARITH_SQRT: @@ -1363,11 +1362,11 @@ int scheme_generate_arith(mz_jit_state *jitter, Scheme_Object *rator, Scheme_Obj refx = jit_beqr_l(jit_forward(), JIT_R2, JIT_V1); __END_INNER_TINY__(branch_short); /* restore R0 argument: */ - if (reversed) - jit_lshi_l(JIT_R0, JIT_V1, 1); - else - jit_lshi_l(JIT_R0, JIT_R2, 1); - jit_ori_l(JIT_R0, JIT_R0, 0x1); + if (reversed) { + jit_fixnum_l(JIT_R0, JIT_V1); + } else { + jit_fixnum_l(JIT_R0, JIT_R2); + } (void)jit_jmpi(refslow); __START_INNER_TINY__(branch_short); mz_patch_branch(refx); @@ -1404,8 +1403,7 @@ int scheme_generate_arith(mz_jit_state *jitter, Scheme_Object *rator, Scheme_Obj __END_INNER_TINY__(branch_short); } } - jit_lshi_l(JIT_R0, JIT_R0, 1); - jit_ori_l(JIT_R0, JIT_R0, 0x1); + jit_fixnum_l(JIT_R0, JIT_R0); } else if (arith == ARITH_AND) { /* and */ jit_andr_ul(JIT_R0, JIT_R1, JIT_R0); diff --git a/src/racket/src/jitcommon.c b/src/racket/src/jitcommon.c index 5d7f9e0e00..d83fe2412b 100644 --- a/src/racket/src/jitcommon.c +++ b/src/racket/src/jitcommon.c @@ -720,8 +720,7 @@ static int common2(mz_jit_state *jitter, void *_data) jit_subi_p(JIT_RUNSTACK, JIT_RUNSTACK, WORDS_TO_BYTES(2)); CHECK_RUNSTACK_OVERFLOW(); jit_str_p(JIT_RUNSTACK, JIT_R0); - jit_lshi_ul(JIT_R1, JIT_R1, 0x1); - jit_ori_ul(JIT_R1, JIT_R1, 0x1); + jit_fixnum_l(JIT_R1, JIT_R1); CHECK_LIMIT(); jit_stxi_p(WORDS_TO_BYTES(1), JIT_RUNSTACK, JIT_R1); JIT_UPDATE_THREAD_RSPTR(); @@ -1150,8 +1149,7 @@ static int common3(mz_jit_state *jitter, void *_data) if (i) jit_stxi_p(WORDS_TO_BYTES(1), JIT_RUNSTACK, JIT_R1); else { - jit_lshi_ul(JIT_R2, JIT_R1, 0x1); - jit_ori_ul(JIT_R2, JIT_R2, 0x1); + jit_fixnum_l(JIT_R2, JIT_R1); jit_stxi_p(WORDS_TO_BYTES(1), JIT_RUNSTACK, JIT_R2); } } @@ -1164,8 +1162,7 @@ static int common3(mz_jit_state *jitter, void *_data) if (ii != -1) { /* in chaperone mode, we already saved original and index on runstack */ if (!i) { - jit_lshi_ul(JIT_R1, JIT_R1, 1); - jit_ori_ul(JIT_R1, JIT_R1, 0x1); + jit_fixnum_l(JIT_R1, JIT_R1); } jit_subi_p(JIT_RUNSTACK, JIT_RUNSTACK, WORDS_TO_BYTES(2)); CHECK_RUNSTACK_OVERFLOW(); @@ -1296,8 +1293,7 @@ static int common3(mz_jit_state *jitter, void *_data) jit_ldxi_p(JIT_R0, JIT_R0, offset); jit_ldxr_c(JIT_R0, JIT_R0, JIT_V1); jit_extr_uc_ul(JIT_R0, JIT_R0); - jit_lshi_l(JIT_R0, JIT_R0, 0x1); - jit_ori_l(JIT_R0, JIT_R0, 0x1); + jit_fixnum_l(JIT_R0, JIT_R0); break; } @@ -2642,8 +2638,7 @@ static int common8(mz_jit_state *jitter, void *_data) /* Return result: */ mz_patch_branch(ref2); __END_SHORT_JUMPS__(1); - jit_lshi_l(JIT_R0, JIT_R1, 1); - jit_ori_l(JIT_R0, JIT_R0, 1); + jit_fixnum_l(JIT_R0, JIT_R1); ref1 = _jit.x.pc; mz_epilog(JIT_R2); diff --git a/src/racket/src/jitinline.c b/src/racket/src/jitinline.c index 8f9cbab4cc..8ec6a1f591 100644 --- a/src/racket/src/jitinline.c +++ b/src/racket/src/jitinline.c @@ -1393,8 +1393,7 @@ int scheme_generate_inlined_unary(mz_jit_state *jitter, Scheme_App2_Rec *app, in (void)jit_ldxi_l(JIT_R0, JIT_R0, &SCHEME_VEC_SIZE(0x0)); else (void)jit_ldxi_l(JIT_R0, JIT_R0, &SCHEME_FLVEC_SIZE(0x0)); - jit_lshi_l(JIT_R0, JIT_R0, 1); - jit_ori_l(JIT_R0, JIT_R0, 0x1); + jit_fixnum_l(JIT_R0, JIT_R0); return 1; } else if (IS_NAMED_PRIM(rator, "unsafe-string-length") @@ -1412,8 +1411,7 @@ int scheme_generate_inlined_unary(mz_jit_state *jitter, Scheme_App2_Rec *app, in (void)jit_ldxi_l(JIT_R0, JIT_R0, &SCHEME_CHAR_STRLEN_VAL(0x0)); else (void)jit_ldxi_l(JIT_R0, JIT_R0, &SCHEME_BYTE_STRLEN_VAL(0x0)); - jit_lshi_l(JIT_R0, JIT_R0, 1); - jit_ori_l(JIT_R0, JIT_R0, 0x1); + jit_fixnum_l(JIT_R0, JIT_R0); return 1; } else if (IS_NAMED_PRIM(rator, "unbox")) { @@ -1995,8 +1993,7 @@ static int generate_vector_op(mz_jit_state *jitter, int set, int int_ready, int reffail = _jit.x.pc; if (int_ready) { - jit_lshi_ul(JIT_R1, JIT_R1, 1); - jit_ori_l(JIT_R1, JIT_R1, 0x1); + jit_fixnum_l(JIT_R1, JIT_R1); } if (set) { if (for_struct) @@ -2721,8 +2718,7 @@ int scheme_generate_inlined_binary(mz_jit_state *jitter, Scheme_App3_Rec *app, i jit_ldxi_p(JIT_R0, JIT_R0, &SCHEME_CHAR_STR_VAL((Scheme_Object *)0x0)); jit_ldxr_c(JIT_R0, JIT_R0, JIT_R1); jit_extr_uc_ul(JIT_R0, JIT_R0); - jit_lshi_l(JIT_R0, JIT_R0, 0x1); - jit_ori_l(JIT_R0, JIT_R0, 0x1); + jit_fixnum_l(JIT_R0, JIT_R0); CHECK_LIMIT(); } else { (void)jit_calli(sjc.bytes_ref_check_index_code); @@ -2776,8 +2772,7 @@ int scheme_generate_inlined_binary(mz_jit_state *jitter, Scheme_App3_Rec *app, i jit_ldxi_p(JIT_R0, JIT_R0, &SCHEME_CHAR_STR_VAL((Scheme_Object *)0x0)); jit_ldxr_c(JIT_R0, JIT_R0, JIT_V1); jit_extr_uc_ul(JIT_R0, JIT_R0); - jit_lshi_l(JIT_R0, JIT_R0, 0x1); - jit_ori_l(JIT_R0, JIT_R0, 0x1); + jit_fixnum_l(JIT_R0, JIT_R0); } else { (void)jit_calli(sjc.bytes_ref_code); } @@ -2844,8 +2839,7 @@ int scheme_generate_inlined_binary(mz_jit_state *jitter, Scheme_App3_Rec *app, i else jit_ldxr_s(JIT_R0, JIT_R0, JIT_R1); - jit_lshi_l(JIT_R0, JIT_R0, 0x1); - jit_ori_l(JIT_R0, JIT_R0, 0x1); + jit_fixnum_l(JIT_R0, JIT_R0); return 1; } else if (IS_NAMED_PRIM(rator, "list-ref") diff --git a/src/racket/src/lightning/i386/core.h b/src/racket/src/lightning/i386/core.h index 791584b183..37748a918b 100644 --- a/src/racket/src/lightning/i386/core.h +++ b/src/racket/src/lightning/i386/core.h @@ -353,6 +353,8 @@ struct jit_local_state { #define jit_rshr_l(d, r1, r2) jit_replace((r1), (r2), _ECX, jit_qop_ ((d), (r1), SARQrr(_CL, (d)) )) #define jit_rshr_ul(d, r1, r2) jit_replace((r1), (r2), _ECX, jit_qop_ ((d), (r1), SHRQrr(_CL, (d)) )) +#define jit_leai_l(d, rs, is, js) LEAQmr((is), 0, (rs), 1 << (js), (d)) + /* Stack */ #define jit_pushi_i(is) PUSHLi(is) #define jit_pushr_i(rs) PUSHLr(rs)