VirtualBox

Ignore:
Timestamp:
Oct 16, 2024 10:52:26 PM (3 months ago)
Author:
vboxsync
Message:

VMM/IEM: Inline the iemNativeVarRegisterAcquire* case that pVar->idxReg is valid as it looks like it is very common. bugref:10720

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp

    r106407 r106408  
    74947494template<bool const a_fInitialized, bool const a_fWithRegPref>
    74957495DECL_FORCE_INLINE_THROW(uint8_t)
    7496 iemNativeVarRegisterAcquireInt(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref)
     7496iemNativeVarRegisterAcquireSlowInt(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref)
    74977497{
    74987498    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
     
    75027502    Assert(!a_fWithRegPref || idxRegPref < RT_ELEMENTS(pReNative->Core.aHstRegs));
    75037503
    7504     /** @todo inline this bit? */
    7505     uint8_t idxReg = pVar->idxReg;
    7506     if (idxReg < RT_ELEMENTS(pReNative->Core.aHstRegs))
    7507     {
    7508         Assert(   pVar->enmKind > kIemNativeVarKind_Invalid
    7509                && pVar->enmKind < kIemNativeVarKind_End);
    7510         pVar->fRegAcquired = true;
    7511         return idxReg;
    7512     }
     7504    /* This slow code path only handles the case where no register have been
     7505       allocated for the variable yet. */
     7506    Assert(pVar->idxReg == UINT8_MAX);
    75137507
    75147508    /*
     
    75387532     * calls causing less optimal code to be generated in the python script. */
    75397533
     7534    uint8_t       idxReg;
    75407535    uint8_t const uArgNo = pVar->uArgNo;
    75417536    if (   uArgNo < RT_ELEMENTS(g_aidxIemNativeCallRegs)
     
    76347629
    76357630
    7636 /** See iemNativeVarRegisterAcquireInt for details. */
    7637 DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquire(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff)
     7631/** See iemNativeVarRegisterAcquireSlowInt for details. */
     7632DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquireSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff)
    76387633{
    76397634    /* very likely */
    76407635    //STAM_REL_COUNTER_INC(&pReNative->pVCpu->iem.s.aStatAdHoc[(pReNative->Core.aVars[IEMNATIVE_VAR_IDX_UNPACK(idxVar)].idxReg < RT_ELEMENTS(pReNative->Core.aHstRegs)) + 0]);
    7641     return iemNativeVarRegisterAcquireInt<false, false>(pReNative, idxVar, poff, UINT8_MAX);
    7642 }
    7643 
    7644 
    7645 /** See iemNativeVarRegisterAcquireInt for details. */
    7646 DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquireInited(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff)
     7636    return iemNativeVarRegisterAcquireSlowInt<false, false>(pReNative, idxVar, poff, UINT8_MAX);
     7637}
     7638
     7639
     7640/** See iemNativeVarRegisterAcquireSlowInt for details. */
     7641DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquireInitedSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff)
    76477642{
    76487643    /* even more likely */
    76497644    //STAM_REL_COUNTER_INC(&pReNative->pVCpu->iem.s.aStatAdHoc[(pReNative->Core.aVars[IEMNATIVE_VAR_IDX_UNPACK(idxVar)].idxReg < RT_ELEMENTS(pReNative->Core.aHstRegs)) + 2]);
    7650     return iemNativeVarRegisterAcquireInt<true, false>(pReNative, idxVar, poff, UINT8_MAX);
    7651 }
    7652 
    7653 
    7654 /** See iemNativeVarRegisterAcquireInt for details. */
     7645    return iemNativeVarRegisterAcquireSlowInt<true, false>(pReNative, idxVar, poff, UINT8_MAX);
     7646}
     7647
     7648
     7649/** See iemNativeVarRegisterAcquireSlowInt for details. */
    76557650DECL_HIDDEN_THROW(uint8_t)
    7656 iemNativeVarRegisterAcquireWithPref(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref)
     7651iemNativeVarRegisterAcquireWithPrefSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref)
    76577652{
    76587653    /* unused */
    76597654    //STAM_REL_COUNTER_INC(&pReNative->pVCpu->iem.s.aStatAdHoc[(pReNative->Core.aVars[IEMNATIVE_VAR_IDX_UNPACK(idxVar)].idxReg < RT_ELEMENTS(pReNative->Core.aHstRegs)) + 4]);
    7660     return iemNativeVarRegisterAcquireInt<false, true>(pReNative, idxVar, poff, idxRegPref);
    7661 }
    7662 
    7663 
    7664 /** See iemNativeVarRegisterAcquireInt for details. */
     7655    return iemNativeVarRegisterAcquireSlowInt<false, true>(pReNative, idxVar, poff, idxRegPref);
     7656}
     7657
     7658
     7659/** See iemNativeVarRegisterAcquireSlowInt for details. */
    76657660DECL_HIDDEN_THROW(uint8_t)
    7666 iemNativeVarRegisterAcquireInitedWithPref(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref)
     7661iemNativeVarRegisterAcquireInitedWithPrefSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref)
    76677662{
    76687663    /* very very likely */
    76697664    //STAM_REL_COUNTER_INC(&pReNative->pVCpu->iem.s.aStatAdHoc[(pReNative->Core.aVars[IEMNATIVE_VAR_IDX_UNPACK(idxVar)].idxReg < RT_ELEMENTS(pReNative->Core.aHstRegs)) + 6]);
    7670     return iemNativeVarRegisterAcquireInt<true, true>(pReNative, idxVar, poff, idxRegPref);
     7665    return iemNativeVarRegisterAcquireSlowInt<true, true>(pReNative, idxVar, poff, idxRegPref);
    76717666}
    76727667
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette