VirtualBox

Ignore:
Timestamp:
Oct 16, 2024 10:52:26 PM (4 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/include/IEMN8veRecompiler.h

    r106407 r106408  
    23432343                                                           IEMNATIVEGSTREGREF enmRegClass, uint8_t idxReg);
    23442344DECL_HIDDEN_THROW(uint8_t)  iemNativeVarGetStackSlot(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar);
    2345 DECL_HIDDEN_THROW(uint8_t)  iemNativeVarRegisterAcquire(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff);
    2346 DECL_HIDDEN_THROW(uint8_t)  iemNativeVarRegisterAcquireWithPref(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref);
    2347 DECL_HIDDEN_THROW(uint8_t)  iemNativeVarRegisterAcquireInited(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff);
    2348 DECL_HIDDEN_THROW(uint8_t)  iemNativeVarRegisterAcquireInitedWithPref(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref);
     2345DECL_HIDDEN_THROW(uint8_t)  iemNativeVarRegisterAcquireSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff);
     2346DECL_HIDDEN_THROW(uint8_t)  iemNativeVarRegisterAcquireWithPrefSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar,
     2347                                                                    uint32_t *poff, uint8_t idxRegPref);
     2348DECL_HIDDEN_THROW(uint8_t)  iemNativeVarRegisterAcquireInitedSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff);
     2349DECL_HIDDEN_THROW(uint8_t)  iemNativeVarRegisterAcquireInitedWithPrefSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar,
     2350                                                                          uint32_t *poff, uint8_t idxRegPref);
    23492351#ifdef IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
    23502352DECL_HIDDEN_THROW(uint8_t)  iemNativeVarSimdRegisterAcquire(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff,
     
    26732675}
    26742676#endif
     2677
     2678
     2679/**
     2680 * Makes sure variable @a idxVar has a register assigned to it and that it stays
     2681 * fixed till we call iemNativeVarRegisterRelease.
     2682 *
     2683 * @returns The host register number.
     2684 * @param   pReNative       The recompiler state.
     2685 * @param   idxVar          The variable.
     2686 * @param   poff            Pointer to the instruction buffer offset.
     2687 *                          In case a register needs to be freed up or the value
     2688 *                          loaded off the stack.
     2689 * @note    Must not modify the host status flags!
     2690 */
     2691DECL_INLINE_THROW(uint8_t) iemNativeVarRegisterAcquire(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff)
     2692{
     2693    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
     2694    PIEMNATIVEVAR const pVar = &pReNative->Core.aVars[IEMNATIVE_VAR_IDX_UNPACK(idxVar)];
     2695    Assert(pVar->cbVar <= 8);
     2696    Assert(!pVar->fRegAcquired);
     2697    uint8_t const idxReg = pVar->idxReg;
     2698    if (idxReg < RT_ELEMENTS(pReNative->Core.aHstRegs))
     2699    {
     2700        Assert(   pVar->enmKind > kIemNativeVarKind_Invalid
     2701               && pVar->enmKind < kIemNativeVarKind_End);
     2702        pVar->fRegAcquired = true;
     2703        return idxReg;
     2704    }
     2705    return iemNativeVarRegisterAcquireSlow(pReNative, idxVar, poff);
     2706}
     2707
     2708
     2709/**
     2710 * Makes sure variable @a idxVar has a register assigned to it and that it stays
     2711 * fixed till we call iemNativeVarRegisterRelease.
     2712 *
     2713 * @returns The host register number.
     2714 * @param   pReNative       The recompiler state.
     2715 * @param   idxVar          The variable.
     2716 * @param   poff            Pointer to the instruction buffer offset.
     2717 *                          In case a register needs to be freed up or the value
     2718 *                          loaded off the stack.
     2719 * @param   idxRegPref      Preferred register number.
     2720 * @note    Must not modify the host status flags!
     2721 */
     2722DECL_INLINE_THROW(uint8_t)
     2723iemNativeVarRegisterAcquireWithPref(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref)
     2724{
     2725    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
     2726    PIEMNATIVEVAR const pVar = &pReNative->Core.aVars[IEMNATIVE_VAR_IDX_UNPACK(idxVar)];
     2727    Assert(pVar->cbVar <= 8);
     2728    Assert(!pVar->fRegAcquired);
     2729    Assert(idxRegPref < RT_ELEMENTS(pReNative->Core.aHstRegs));
     2730    uint8_t const idxReg = pVar->idxReg;
     2731    if (idxReg < RT_ELEMENTS(pReNative->Core.aHstRegs))
     2732    {
     2733        Assert(   pVar->enmKind > kIemNativeVarKind_Invalid
     2734               && pVar->enmKind < kIemNativeVarKind_End);
     2735        pVar->fRegAcquired = true;
     2736        return idxReg;
     2737    }
     2738    return iemNativeVarRegisterAcquireWithPrefSlow(pReNative, idxVar, poff, idxRegPref);
     2739}
     2740
     2741
     2742/**
     2743 * Makes sure variable @a idxVar has a register assigned to it and that it stays
     2744 * fixed till we call iemNativeVarRegisterRelease.
     2745 *
     2746 * The variable must be initialized or VERR_IEM_VAR_NOT_INITIALIZED will be
     2747 * thrown.
     2748 *
     2749 * @returns The host register number.
     2750 * @param   pReNative       The recompiler state.
     2751 * @param   idxVar          The variable.
     2752 * @param   poff            Pointer to the instruction buffer offset.
     2753 *                          In case a register needs to be freed up or the value
     2754 *                          loaded off the stack.
     2755 * @note    Must not modify the host status flags!
     2756 */
     2757DECL_INLINE_THROW(uint8_t) iemNativeVarRegisterAcquireInited(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff)
     2758{
     2759    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
     2760    PIEMNATIVEVAR const pVar = &pReNative->Core.aVars[IEMNATIVE_VAR_IDX_UNPACK(idxVar)];
     2761    Assert(pVar->cbVar <= 8);
     2762    Assert(!pVar->fRegAcquired);
     2763    uint8_t const idxReg = pVar->idxReg;
     2764    if (idxReg < RT_ELEMENTS(pReNative->Core.aHstRegs))
     2765    {
     2766        Assert(   pVar->enmKind > kIemNativeVarKind_Invalid
     2767               && pVar->enmKind < kIemNativeVarKind_End);
     2768        pVar->fRegAcquired = true;
     2769        return idxReg;
     2770    }
     2771    return iemNativeVarRegisterAcquireInitedSlow(pReNative, idxVar, poff);
     2772}
     2773
     2774
     2775/**
     2776 * Makes sure variable @a idxVar has a register assigned to it and that it stays
     2777 * fixed till we call iemNativeVarRegisterRelease.
     2778 *
     2779 * The variable must be initialized or VERR_IEM_VAR_NOT_INITIALIZED will be
     2780 * thrown.
     2781 *
     2782 * @returns The host register number.
     2783 * @param   pReNative       The recompiler state.
     2784 * @param   idxVar          The variable.
     2785 * @param   poff            Pointer to the instruction buffer offset.
     2786 *                          In case a register needs to be freed up or the value
     2787 *                          loaded off the stack.
     2788 * @param   idxRegPref      Preferred register number.
     2789 * @note    Must not modify the host status flags!
     2790 */
     2791DECL_INLINE_THROW(uint8_t)
     2792iemNativeVarRegisterAcquireInitedWithPref(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref)
     2793{
     2794    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
     2795    PIEMNATIVEVAR const pVar = &pReNative->Core.aVars[IEMNATIVE_VAR_IDX_UNPACK(idxVar)];
     2796    Assert(pVar->cbVar <= 8);
     2797    Assert(!pVar->fRegAcquired);
     2798    Assert(idxRegPref < RT_ELEMENTS(pReNative->Core.aHstRegs));
     2799    uint8_t const idxReg = pVar->idxReg;
     2800    if (idxReg < RT_ELEMENTS(pReNative->Core.aHstRegs))
     2801    {
     2802        Assert(   pVar->enmKind > kIemNativeVarKind_Invalid
     2803               && pVar->enmKind < kIemNativeVarKind_End);
     2804        pVar->fRegAcquired = true;
     2805        return idxReg;
     2806    }
     2807    return iemNativeVarRegisterAcquireInitedWithPrefSlow(pReNative, idxVar, poff, idxRegPref);
     2808}
    26752809
    26762810
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