Changeset 106408 in vbox
- Timestamp:
- Oct 16, 2024 10:52:26 PM (3 months ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp
r106407 r106408 7494 7494 template<bool const a_fInitialized, bool const a_fWithRegPref> 7495 7495 DECL_FORCE_INLINE_THROW(uint8_t) 7496 iemNativeVarRegisterAcquire Int(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref)7496 iemNativeVarRegisterAcquireSlowInt(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref) 7497 7497 { 7498 7498 IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar); … … 7502 7502 Assert(!a_fWithRegPref || idxRegPref < RT_ELEMENTS(pReNative->Core.aHstRegs)); 7503 7503 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); 7513 7507 7514 7508 /* … … 7538 7532 * calls causing less optimal code to be generated in the python script. */ 7539 7533 7534 uint8_t idxReg; 7540 7535 uint8_t const uArgNo = pVar->uArgNo; 7541 7536 if ( uArgNo < RT_ELEMENTS(g_aidxIemNativeCallRegs) … … 7634 7629 7635 7630 7636 /** See iemNativeVarRegisterAcquire Int for details. */7637 DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquire (PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff)7631 /** See iemNativeVarRegisterAcquireSlowInt for details. */ 7632 DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquireSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff) 7638 7633 { 7639 7634 /* very likely */ 7640 7635 //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 iemNativeVarRegisterAcquire Int<false, false>(pReNative, idxVar, poff, UINT8_MAX);7642 } 7643 7644 7645 /** See iemNativeVarRegisterAcquire Int 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. */ 7641 DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquireInitedSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff) 7647 7642 { 7648 7643 /* even more likely */ 7649 7644 //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 iemNativeVarRegisterAcquire Int<true, false>(pReNative, idxVar, poff, UINT8_MAX);7651 } 7652 7653 7654 /** See iemNativeVarRegisterAcquire Int for details. */7645 return iemNativeVarRegisterAcquireSlowInt<true, false>(pReNative, idxVar, poff, UINT8_MAX); 7646 } 7647 7648 7649 /** See iemNativeVarRegisterAcquireSlowInt for details. */ 7655 7650 DECL_HIDDEN_THROW(uint8_t) 7656 iemNativeVarRegisterAcquireWithPref (PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref)7651 iemNativeVarRegisterAcquireWithPrefSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref) 7657 7652 { 7658 7653 /* unused */ 7659 7654 //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 iemNativeVarRegisterAcquire Int<false, true>(pReNative, idxVar, poff, idxRegPref);7661 } 7662 7663 7664 /** See iemNativeVarRegisterAcquire Int for details. */7655 return iemNativeVarRegisterAcquireSlowInt<false, true>(pReNative, idxVar, poff, idxRegPref); 7656 } 7657 7658 7659 /** See iemNativeVarRegisterAcquireSlowInt for details. */ 7665 7660 DECL_HIDDEN_THROW(uint8_t) 7666 iemNativeVarRegisterAcquireInitedWithPref (PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref)7661 iemNativeVarRegisterAcquireInitedWithPrefSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, uint8_t idxRegPref) 7667 7662 { 7668 7663 /* very very likely */ 7669 7664 //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 iemNativeVarRegisterAcquire Int<true, true>(pReNative, idxVar, poff, idxRegPref);7665 return iemNativeVarRegisterAcquireSlowInt<true, true>(pReNative, idxVar, poff, idxRegPref); 7671 7666 } 7672 7667 -
trunk/src/VBox/VMM/include/IEMN8veRecompiler.h
r106407 r106408 2343 2343 IEMNATIVEGSTREGREF enmRegClass, uint8_t idxReg); 2344 2344 DECL_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); 2345 DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquireSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff); 2346 DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquireWithPrefSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, 2347 uint32_t *poff, uint8_t idxRegPref); 2348 DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquireInitedSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff); 2349 DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquireInitedWithPrefSlow(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, 2350 uint32_t *poff, uint8_t idxRegPref); 2349 2351 #ifdef IEMNATIVE_WITH_SIMD_REG_ALLOCATOR 2350 2352 DECL_HIDDEN_THROW(uint8_t) iemNativeVarSimdRegisterAcquire(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint32_t *poff, … … 2673 2675 } 2674 2676 #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 */ 2691 DECL_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 */ 2722 DECL_INLINE_THROW(uint8_t) 2723 iemNativeVarRegisterAcquireWithPref(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 */ 2757 DECL_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 */ 2791 DECL_INLINE_THROW(uint8_t) 2792 iemNativeVarRegisterAcquireInitedWithPref(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 } 2675 2809 2676 2810
Note:
See TracChangeset
for help on using the changeset viewer.