- Timestamp:
- Dec 5, 2023 12:46:45 PM (14 months ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/Makefile.kmk
r101906 r102471 265 265 VBoxVMM_LIBS.darwin += /opt/local/lib/libcapstone.dylib 266 266 endif 267 VMMAll/IEMAllN8veRecompiler.cpp_CXXFLAGS.win = /bigobj 267 268 endif 268 269 VMMAll/IEMAllThrdFuncs.cpp_CXXFLAGS.win = /bigobj -
trunk/src/VBox/VMM/VMMAll/IEMAllInstPython.py
r102452 r102471 2817 2817 'IEM_MC_ARG_LOCAL_EFLAGS': (McBlock.parseMcArgLocalEFlags, False, True, ), 2818 2818 'IEM_MC_ARG_LOCAL_REF': (McBlock.parseMcArgLocalRef, False, True, ), 2819 'IEM_MC_ASSIGN_TO_SMALLER': (McBlock.parseMcGeneric, False, False,),2819 'IEM_MC_ASSIGN_TO_SMALLER': (McBlock.parseMcGeneric, False, True, ), 2820 2820 'IEM_MC_BEGIN': (McBlock.parseMcBegin, False, True, ), 2821 2821 'IEM_MC_BROADCAST_XREG_U16_ZX_VLMAX': (McBlock.parseMcGeneric, True, False, ), -
trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp
r102452 r102471 2949 2949 Assert(pReNative->Core.bmHstRegsWithGstShadow & RT_BIT_32(idxReg)); 2950 2950 2951 pReNative->Core.bmHstRegsWithGstShadow &= ~RT_BIT_32(idxReg); 2951 2952 pReNative->Core.bmGstRegShadows &= ~pReNative->Core.aHstRegs[idxReg].fGstRegShadows; 2952 pReNative->Core.bmHstRegsWithGstShadow &= ~RT_BIT_32(idxReg);2953 2953 pReNative->Core.aHstRegs[idxReg].fGstRegShadows = 0; 2954 2954 return idxReg; … … 2989 2989 2990 2990 pReNative->Core.aVars[idxVar].idxReg = UINT8_MAX; 2991 pReNative->Core.bmHstRegs &= ~RT_BIT_32(idxReg); 2992 2993 pReNative->Core.bmHstRegsWithGstShadow &= ~RT_BIT_32(idxReg); 2991 2994 pReNative->Core.bmGstRegShadows &= ~pReNative->Core.aHstRegs[idxReg].fGstRegShadows; 2992 pReNative->Core.bmHstRegsWithGstShadow &= ~RT_BIT_32(idxReg); 2993 pReNative->Core.bmHstRegs &= ~RT_BIT_32(idxReg); 2995 pReNative->Core.aHstRegs[idxReg].fGstRegShadows = 0; 2994 2996 return idxReg; 2995 2997 } … … 3031 3033 if (fGstRegShadows) 3032 3034 { 3033 pReNative->Core.bmHstRegsWithGstShadow |= RT_BIT_32(idxRegNew); 3035 pReNative->Core.bmHstRegsWithGstShadow = (pReNative->Core.bmHstRegsWithGstShadow & ~RT_BIT_32(idxRegOld)) 3036 | RT_BIT_32(idxRegNew); 3034 3037 while (fGstRegShadows) 3035 3038 { … … 3109 3112 pReNative->Core.aVars[idxVar].idxReg = UINT8_MAX; 3110 3113 pReNative->Core.bmHstRegsWithGstShadow &= ~RT_BIT_32(idxRegOld); 3114 pReNative->Core.bmHstRegs &= ~RT_BIT_32(idxRegOld); 3111 3115 pReNative->Core.bmGstRegShadows &= ~pReNative->Core.aHstRegs[idxRegOld].fGstRegShadows; 3112 pReNative->Core.bmHstRegs &= ~RT_BIT_32(idxRegOld);3113 3116 pReNative->Core.aHstRegs[idxRegOld].fGstRegShadows = 0; 3114 3117 return off; … … 3202 3205 { 3203 3206 Assert(!(pReNative->Core.bmGstRegShadows & RT_BIT_64(enmGstReg))); 3207 Assert(!pReNative->Core.aHstRegs[idxHstReg].fGstRegShadows); 3204 3208 Assert((unsigned)enmGstReg < (unsigned)kIemNativeGstReg_End); 3205 3209 3206 3210 pReNative->Core.aidxGstRegShadows[enmGstReg] = idxHstReg; 3207 pReNative->Core.aHstRegs[idxHstReg].fGstRegShadows = RT_BIT_64(enmGstReg); 3211 pReNative->Core.aHstRegs[idxHstReg].fGstRegShadows = RT_BIT_64(enmGstReg); /** @todo why? not OR? */ 3208 3212 pReNative->Core.bmGstRegShadows |= RT_BIT_64(enmGstReg); 3209 3213 pReNative->Core.bmHstRegsWithGstShadow |= RT_BIT_32(idxHstReg); … … 3328 3332 { 3329 3333 Assert(pReNative->Core.aHstRegs[idxRegFrom].fGstRegShadows & RT_BIT_64(enmGstReg)); 3334 Assert(pReNative->Core.aidxGstRegShadows[enmGstReg] == idxRegFrom); 3330 3335 Assert( (pReNative->Core.bmGstRegShadows & pReNative->Core.aHstRegs[idxRegFrom].fGstRegShadows) 3331 3336 == pReNative->Core.aHstRegs[idxRegFrom].fGstRegShadows … … 3625 3630 Assert( (pReNative->Core.aHstRegs[idxReg].fGstRegShadows & pReNative->Core.bmGstRegShadows) 3626 3631 == pReNative->Core.aHstRegs[idxReg].fGstRegShadows); 3627 pReNative->Core.bmGstRegShadows &= ~pReNative->Core.aHstRegs[idxReg].fGstRegShadows; 3632 pReNative->Core.bmHstRegsWithGstShadow &= ~RT_BIT_32(idxReg); 3633 pReNative->Core.bmGstRegShadows &= ~pReNative->Core.aHstRegs[idxReg].fGstRegShadows; 3628 3634 pReNative->Core.aHstRegs[idxReg].fGstRegShadows = 0; 3629 3635 } … … 3726 3732 { 3727 3733 pReNative->Core.bmHstRegsWithGstShadow &= ~RT_BIT_32(idxHstReg); 3728 uint64_t const fGstRegShadowsOld = pReNative->Core.aHstRegs[idxHstReg].fGstRegShadows; 3734 uint64_t const fGstRegShadowsOld = pReNative->Core.aHstRegs[idxHstReg].fGstRegShadows; 3735 pReNative->Core.aHstRegs[idxHstReg].fGstRegShadows = 0; 3729 3736 pReNative->Core.bmGstRegShadows &= ~fGstRegShadowsOld; 3730 uint64_t fGstRegShadows = fGstRegShadowsOld;3737 uint64_t fGstRegShadows = fGstRegShadowsOld; 3731 3738 while (fGstRegShadows) 3732 3739 { … … 3865 3872 * Reduce the mask by what's currently shadowed 3866 3873 */ 3867 fGstRegs &= pReNative->Core.bmGstRegShadows; 3874 uint64_t const bmGstRegShadowsOld = pReNative->Core.bmGstRegShadows; 3875 fGstRegs &= bmGstRegShadowsOld; 3868 3876 if (fGstRegs) 3869 3877 { 3870 Log12(("iemNativeRegFlushGuestShadows: flushing %#RX64 (%#RX64 -> %#RX64)\n",3871 fGstRegs, pReNative->Core.bmGstRegShadows, pReNative->Core.bmGstRegShadows & ~fGstRegs));3872 pReNative->Core.bmGstRegShadows &= ~fGstRegs;3873 if ( pReNative->Core.bmGstRegShadows)3878 uint64_t const bmGstRegShadowsNew = bmGstRegShadowsOld & ~fGstRegs; 3879 Log12(("iemNativeRegFlushGuestShadows: flushing %#RX64 (%#RX64 -> %#RX64)\n", fGstRegs, bmGstRegShadowsOld, bmGstRegShadowsNew)); 3880 pReNative->Core.bmGstRegShadows = bmGstRegShadowsNew; 3881 if (bmGstRegShadowsNew) 3874 3882 { 3875 3883 /* … … 3886 3894 uint64_t const fInThisHstReg = (pReNative->Core.aHstRegs[idxHstReg].fGstRegShadows & fGstRegs) | RT_BIT_64(idxGstReg); 3887 3895 fGstRegs &= ~fInThisHstReg; 3888 pReNative->Core.aHstRegs[idxHstReg].fGstRegShadows &= ~fInThisHstReg; 3889 if (!pReNative->Core.aHstRegs[idxHstReg].fGstRegShadows) 3896 uint64_t const fGstRegShadowsNew = pReNative->Core.aHstRegs[idxHstReg].fGstRegShadows & ~fInThisHstReg; 3897 pReNative->Core.aHstRegs[idxHstReg].fGstRegShadows = fGstRegShadowsNew; 3898 if (!fGstRegShadowsNew) 3890 3899 pReNative->Core.bmHstRegsWithGstShadow &= ~RT_BIT_32(idxHstReg); 3891 3900 } while (fGstRegs != 0); … … 6270 6279 { 6271 6280 idxReg = g_aidxIemNativeCallRegs[uArgNo]; 6281 iemNativeRegClearGstRegShadowing(pReNative, idxReg, *poff); 6272 6282 Log11(("iemNativeVarAllocRegister: idxVar=%u idxReg=%u (matching arg %u)\n", idxVar, idxReg, uArgNo)); 6273 6283 } … … 6598 6608 6599 6609 6610 #define IEM_MC_ASSIGN_TO_SMALLER(a_VarDst, a_VarSrcEol) off = iemNativeVarAssignToSmaller(pReNative, off, a_VarDst, a_VarSrcEol) 6611 6612 /** 6613 * This is called by IEM_MC_ASSIGN_TO_SMALLER. 6614 */ 6615 DECL_INLINE_THROW(uint32_t) 6616 iemNativeVarAssignToSmaller(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t idxVarDst, uint8_t idxVarSrc) 6617 { 6618 IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVarDst); 6619 AssertStmt(pReNative->Core.aVars[idxVarDst].enmKind == kIemNativeVarKind_Invalid, 6620 IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND)); 6621 Assert( pReNative->Core.aVars[idxVarDst].cbVar == sizeof(uint16_t) 6622 || pReNative->Core.aVars[idxVarDst].cbVar == sizeof(uint32_t)); 6623 6624 IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVarSrc); 6625 AssertStmt( pReNative->Core.aVars[idxVarSrc].enmKind == kIemNativeVarKind_Stack 6626 || pReNative->Core.aVars[idxVarSrc].enmKind == kIemNativeVarKind_Immediate, 6627 IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND)); 6628 6629 Assert(pReNative->Core.aVars[idxVarDst].cbVar < pReNative->Core.aVars[idxVarSrc].cbVar); 6630 6631 /* 6632 * Special case for immediates. 6633 */ 6634 if (pReNative->Core.aVars[idxVarSrc].enmKind == kIemNativeVarKind_Immediate) 6635 { 6636 switch (pReNative->Core.aVars[idxVarDst].cbVar) 6637 { 6638 case sizeof(uint16_t): 6639 iemNativeVarSetKindToConst(pReNative, idxVarDst, (uint16_t)pReNative->Core.aVars[idxVarSrc].u.uValue); 6640 break; 6641 case sizeof(uint32_t): 6642 iemNativeVarSetKindToConst(pReNative, idxVarDst, (uint32_t)pReNative->Core.aVars[idxVarSrc].u.uValue); 6643 break; 6644 default: AssertFailed(); break; 6645 } 6646 } 6647 else 6648 { 6649 /* 6650 * The generic solution for now. 6651 */ 6652 /** @todo optimize this by having the python script make sure the source 6653 * variable passed to IEM_MC_ASSIGN_TO_SMALLER is not used after the 6654 * statement. Then we could just transfer the register assignments. */ 6655 uint8_t const idxRegDst = iemNativeVarAllocRegister(pReNative, idxVarDst, &off); 6656 uint8_t const idxRegSrc = iemNativeVarAllocRegister(pReNative, idxVarSrc, &off); 6657 switch (pReNative->Core.aVars[idxVarDst].cbVar) 6658 { 6659 case sizeof(uint16_t): 6660 off = iemNativeEmitLoadGprFromGpr16(pReNative, off, idxRegDst, idxRegSrc); 6661 break; 6662 case sizeof(uint32_t): 6663 off = iemNativeEmitLoadGprFromGpr32(pReNative, off, idxRegDst, idxRegSrc); 6664 break; 6665 default: AssertFailed(); break; 6666 } 6667 } 6668 return off; 6669 } 6670 6671 6600 6672 6601 6673 /********************************************************************************************************************************* … … 6712 6784 Assert(pReNative->Core.bmVars & RT_BIT_32(pReNative->Core.aidxArgVars[i])); 6713 6785 } 6786 iemNativeRegAssertSanity(pReNative); 6714 6787 #endif 6715 6788 … … 6720 6793 uint32_t bmVars = pReNative->Core.bmVars; 6721 6794 if (bmVars) 6795 { 6722 6796 do 6723 6797 { … … 6744 6818 } 6745 6819 } while (bmVars != 0); 6820 #if 0 //def VBOX_STRICT 6821 iemNativeRegAssertSanity(pReNative); 6822 #endif 6823 } 6746 6824 6747 6825 uint8_t const cRegArgs = RT_MIN(cArgs, RT_ELEMENTS(g_aidxIemNativeCallRegs)); … … 6752 6830 */ 6753 6831 if (pReNative->Core.bmHstRegs & g_afIemNativeCallRegs[cRegArgs]) 6832 { 6754 6833 for (uint32_t i = 0; i < cRegArgs; i++) 6755 6834 { … … 6801 6880 } 6802 6881 } 6882 #if 0 //def VBOX_STRICT 6883 iemNativeRegAssertSanity(pReNative); 6884 #endif 6885 } 6803 6886 6804 6887 Assert(!(pReNative->Core.bmHstRegs & g_afIemNativeCallRegs[cHiddenArgs])); /* No variables for hidden arguments. */ … … 6812 6895 */ 6813 6896 if (cArgs > IEMNATIVE_CALL_ARG_GREG_COUNT) 6897 { 6814 6898 for (unsigned i = IEMNATIVE_CALL_ARG_GREG_COUNT; i < cArgs; i++) 6815 6899 { … … 6876 6960 } 6877 6961 } 6962 # if 0 //def VBOX_STRICT 6963 iemNativeRegAssertSanity(pReNative); 6964 # endif 6965 } 6878 6966 #else 6879 6967 AssertCompile(IEMNATIVE_CALL_MAX_ARG_COUNT <= IEMNATIVE_CALL_ARG_GREG_COUNT); … … 6888 6976 */ 6889 6977 if (~pReNative->Core.bmHstRegs & (g_afIemNativeCallRegs[cRegArgs] & ~g_afIemNativeCallRegs[cHiddenArgs])) 6978 { 6890 6979 for (unsigned i = cHiddenArgs; i < cRegArgs; i++) 6891 6980 { … … 6956 7045 } 6957 7046 } 7047 #if 0 //def VBOX_STRICT 7048 iemNativeRegAssertSanity(pReNative); 7049 #endif 7050 } 6958 7051 #ifdef VBOX_STRICT 6959 7052 else … … 7624 7717 else 7625 7718 { 7626 AssertStmt(pReNative->Core.aVars[idxValueVar].enmKind != kIemNativeVarKind_Immediate,7719 AssertStmt(pReNative->Core.aVars[idxValueVar].enmKind == kIemNativeVarKind_Immediate, 7627 7720 IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND)); 7628 7721 return iemNativeEmitStoreGregU8Const(pReNative, off, iGRegEx, (uint8_t)pReNative->Core.aVars[idxValueVar].u.uValue); … … 7756 7849 else 7757 7850 { 7758 AssertStmt(pReNative->Core.aVars[idxValueVar].enmKind != kIemNativeVarKind_Immediate,7851 AssertStmt(pReNative->Core.aVars[idxValueVar].enmKind == kIemNativeVarKind_Immediate, 7759 7852 IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND)); 7760 7853 return iemNativeEmitStoreGregU16Const(pReNative, off, iGReg, (uint16_t)pReNative->Core.aVars[idxValueVar].u.uValue); … … 7839 7932 else 7840 7933 { 7841 AssertStmt(pReNative->Core.aVars[idxValueVar].enmKind != kIemNativeVarKind_Immediate,7934 AssertStmt(pReNative->Core.aVars[idxValueVar].enmKind == kIemNativeVarKind_Immediate, 7842 7935 IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND)); 7843 7936 return iemNativeEmitStoreGregU32Const(pReNative, off, iGReg, (uint32_t)pReNative->Core.aVars[idxValueVar].u.uValue); … … 7892 7985 else 7893 7986 { 7894 AssertStmt(pReNative->Core.aVars[idxValueVar].enmKind != kIemNativeVarKind_Immediate,7987 AssertStmt(pReNative->Core.aVars[idxValueVar].enmKind == kIemNativeVarKind_Immediate, 7895 7988 IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND)); 7896 7989 return iemNativeEmitStoreGregU64Const(pReNative, off, iGReg, pReNative->Core.aVars[idxValueVar].u.uValue); -
trunk/src/VBox/VMM/include/IEMMc.h
r102448 r102471 208 208 do { pVCpu->cpum.GstCtx.eflags.u = (a_EFlags); Assert(pVCpu->cpum.GstCtx.eflags.u & X86_EFL_1); } while (0) 209 209 210 #define IEM_MC_ASSIGN_TO_SMALLER(a_VarOrArg, a_CVariableOrConst) (a_VarOrArg) = (a_CVariableOrConst) 210 /** ASSUMES the source variable not used after this statement. */ 211 #define IEM_MC_ASSIGN_TO_SMALLER(a_VarDst, a_VarSrcEol) (a_VarDst) = (a_VarSrcEol) 211 212 212 213 #define IEM_MC_FETCH_GREG_U8(a_u8Dst, a_iGReg) (a_u8Dst) = iemGRegFetchU8(pVCpu, (a_iGReg))
Note:
See TracChangeset
for help on using the changeset viewer.