]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Merge branch 'master' into v2.1
authorMike Pall <mike>
Sun, 12 Nov 2023 14:25:14 +0000 (15:25 +0100)
committerMike Pall <mike>
Sun, 12 Nov 2023 14:25:14 +0000 (15:25 +0100)
1  2 
src/lj_asm_x86.h

index 0e0b28a40d9f11b13e07324ad028a1c80c943491,6b1148028d91aa7379659b26dd2612863996c1a1..d98fb827688676fa838d8de5a69ee4cc22f569c0
@@@ -814,7 -672,9 +814,8 @@@ static void asm_tointg(ASMState *as, IR
    asm_guardcc(as, CC_NE);
    emit_rr(as, XO_UCOMISD, left, tmp);
    emit_rr(as, XO_CVTSI2SD, tmp, dest);
 -  if (!(as->flags & JIT_F_SPLIT_XMM))
 -    emit_rr(as, XO_XORPS, tmp, tmp);  /* Avoid partial register stall. */
 +  emit_rr(as, XO_XORPS, tmp, tmp);  /* Avoid partial register stall. */
+   checkmclim(as);
    emit_rr(as, XO_CVTTSD2SI, dest, left);
    /* Can't fuse since left is needed twice. */
  }
@@@ -856,7 -713,8 +857,8 @@@ static void asm_conv(ASMState *as, IRIn
        emit_rr(as, XO_CVTSD2SS, dest, dest);
        emit_rr(as, XO_SUBSD, dest, bias);  /* Subtract 2^52+2^51 bias. */
        emit_rr(as, XO_XORPS, dest, bias);  /* Merge bias and integer. */
 -      emit_loadn(as, bias, k);
 +      emit_rma(as, XO_MOVSD, bias, k);
+       checkmclim(as);
        emit_mrm(as, XO_MOVD, dest, asm_fuseload(as, lref, RSET_GPR));
        return;
      } else {  /* Integer to FP conversion. */
@@@ -1169,10 -1023,11 +1171,11 @@@ static void asm_href(ASMState *as, IRIn
    l_next = emit_label(as);
  
    /* Type and value comparison. */
 -  if (nilexit)
 -    emit_jcc(as, CC_E, nilexit);
 +  if (merge == IR_EQ)
 +    asm_guardcc(as, CC_E);
    else
      emit_sjcc(as, CC_E, l_end);
+   checkmclim(as);
    if (irt_isnum(kt)) {
      if (isk) {
        /* Assumes -0.0 is already canonicalized to +0.0. */
        emit_rmro(as, XO_CMP, key, dest, offsetof(Node, key.gcr));
        emit_sjcc(as, CC_NE, l_next);
      }
 -    lua_assert(!irt_isnil(kt));
 +    lj_assertA(!irt_isnil(kt), "bad HREF key type");
      emit_i8(as, irt_toitype(kt));
      emit_rmro(as, XO_ARITHi8, XOg_CMP, dest, offsetof(Node, key.it));
 +#endif
    }
    emit_sfixup(as, l_loop);
-   checkmclim(as);
 +#if LJ_GC64
 +  if (!isk && irt_isaddr(kt)) {
 +    emit_rr(as, XO_OR, tmp|REX_64, key);
 +    emit_loadu64(as, tmp, (uint64_t)irt_toitype(kt) << 47);
 +  }
 +#endif
  
    /* Load main position relative to tab->node into dest. */
 -  khash = isk ? ir_khash(irkey) : 1;
 +  khash = isk ? ir_khash(as, irkey) : 1;
    if (khash == 0) {
 -    emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, node));
 +    emit_rmro(as, XO_MOV, dest|REX_GC64, tab, offsetof(GCtab, node));
    } else {
 -    emit_rmro(as, XO_ARITH(XOg_ADD), dest, tab, offsetof(GCtab, node));
 -    if ((as->flags & JIT_F_PREFER_IMUL)) {
 -      emit_i8(as, sizeof(Node));
 -      emit_rr(as, XO_IMULi8, dest, dest);
 -    } else {
 -      emit_shifti(as, XOg_SHL, dest, 3);
 -      emit_rmrxo(as, XO_LEA, dest, dest, dest, XM_SCALE2, 0);
 -    }
 +    emit_rmro(as, XO_ARITH(XOg_ADD), dest|REX_GC64, tab, offsetof(GCtab,node));
 +    emit_shifti(as, XOg_SHL, dest, 3);
 +    emit_rmrxo(as, XO_LEA, dest, dest, dest, XM_SCALE2, 0);
      if (isk) {
        emit_gri(as, XG_ARITHi(XOg_AND), dest, (int32_t)khash);
        emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, hmask));
  #endif
        } else {
        emit_rr(as, XO_MOV, tmp, key);
-       checkmclim(as);
 +#if LJ_GC64
 +      emit_gri(as, XG_ARITHi(XOg_XOR), dest, irt_toitype(kt) << 15);
 +      if ((as->flags & JIT_F_BMI2)) {
 +        emit_i8(as, 32);
 +        emit_mrm(as, XV_RORX|VEX_64, dest, key);
 +      } else {
 +        emit_shifti(as, XOg_SHR|REX_64, dest, 32);
 +        emit_rr(as, XO_MOV, dest|REX_64, key|REX_64);
 +      }
 +#else
        emit_rmro(as, XO_LEA, dest, key, HASH_BIAS);
 +#endif
        }
      }
    }
@@@ -1554,8 -1378,8 +1556,9 @@@ static void asm_ahuvload(ASMState *as, 
    if (irt_islightud(ir->t)) {
      Reg dest = asm_load_lightud64(as, ir, 1);
      if (ra_hasreg(dest)) {
+       checkmclim(as);
        asm_fuseahuref(as, ir->op1, RSET_GPR);
 +      if (ir->o == IR_VLOAD) as->mrm.ofs += 8 * ir->op2;
        emit_mrm(as, XO_MOV, dest|REX_64, RID_MRM);
      }
      return;
    as->mrm.ofs += 4;
    asm_guardcc(as, irt_isnum(ir->t) ? CC_AE : CC_NE);
    if (LJ_64 && irt_type(ir->t) >= IRT_NUM) {
 -    lua_assert(irt_isinteger(ir->t) || irt_isnum(ir->t));
 +    lj_assertA(irt_isinteger(ir->t) || irt_isnum(ir->t),
 +             "bad load type %d", irt_type(ir->t));
+     checkmclim(as);
 +#if LJ_GC64
 +    emit_u32(as, LJ_TISNUM << 15);
 +#else
      emit_u32(as, LJ_TISNUM);
 +#endif
      emit_mrm(as, XO_ARITHi, XOg_CMP, RID_MRM);
 +#if LJ_GC64
 +  } else if (irt_isaddr(ir->t)) {
 +    as->mrm.ofs -= 4;
 +    emit_i8(as, irt_toitype(ir->t));
 +    emit_mrm(as, XO_ARITHi8, XOg_CMP, tmp);
 +    emit_shifti(as, XOg_SAR|REX_64, tmp, 47);
 +    emit_mrm(as, XO_MOV, tmp|REX_64, RID_MRM);
 +  } else if (irt_isnil(ir->t)) {
 +    as->mrm.ofs -= 4;
 +    emit_i8(as, -1);
 +    emit_mrm(as, XO_ARITHi8, XOg_CMP|REX_64, RID_MRM);
 +  } else {
 +    emit_u32(as, (irt_toitype(ir->t) << 15) | 0x7fff);
 +    emit_mrm(as, XO_ARITHi, XOg_CMP, RID_MRM);
 +#else
    } else {
      emit_i8(as, irt_toitype(ir->t));
      emit_mrm(as, XO_ARITHi8, XOg_CMP, RID_MRM);