Changeset 106329 in vbox
- Timestamp:
- Oct 15, 2024 2:19:43 PM (6 weeks ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllN8veExecMem.cpp
r106326 r106329 367 367 * Before we can start, we must process delayed frees. 368 368 */ 369 #if 1 370 PIEMTBALLOCATOR const pTbAllocator = iemTbAllocatorFreeBulkStart(pVCpu); 371 #else 369 372 iemTbAllocatorProcessDelayedFrees(pVCpu, pVCpu->iem.s.pTbAllocatorR3); 373 #endif 370 374 371 375 AssertCompile(RT_IS_POWER_OF_TWO(IEMEXECMEM_ALT_SUB_ALLOC_UNIT_SIZE)); … … 455 459 cbPruned += cbBlock; 456 460 461 #if 1 462 iemTbAllocatorFreeBulk(pVCpu, pTbAllocator, pTb); 463 #else 457 464 iemTbAllocatorFree(pVCpu, pTb); 465 #endif 458 466 } 459 467 else … … 461 469 } 462 470 STAM_REL_PROFILE_ADD_PERIOD(&pExecMemAllocator->StatPruneRecovered, cbPruned); 471 472 pVCpu->iem.s.ppTbLookupEntryR3 = &pVCpu->iem.s.pTbLookupEntryDummyR3; 463 473 464 474 /* -
trunk/src/VBox/VMM/VMMAll/IEMAllThrdRecompiler.cpp
r106313 r106329 912 912 /** 913 913 * Inner free worker. 914 */ 915 static void iemTbAllocatorFreeInner(PVMCPUCC pVCpu, PIEMTBALLOCATOR pTbAllocator, 916 PIEMTB pTb, uint32_t idxChunk, uint32_t idxInChunk) 917 { 914 * 915 * The @a a_fType parameter allows us to eliminate the type check when we know 916 * which type of TB is being freed. 917 */ 918 template<uint32_t a_fType> 919 DECL_FORCE_INLINE(void) 920 iemTbAllocatorFreeInner(PVMCPUCC pVCpu, PIEMTBALLOCATOR pTbAllocator, PIEMTB pTb, uint32_t idxChunk, uint32_t idxInChunk) 921 { 922 #ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER 923 AssertCompile(a_fType == 0 || a_fType == IEMTB_F_TYPE_THREADED || a_fType == IEMTB_F_TYPE_NATIVE); 924 #else 925 AssertCompile(a_fType == 0 || a_fType == IEMTB_F_TYPE_THREADED); 926 #endif 918 927 Assert(idxChunk < pTbAllocator->cAllocatedChunks); RT_NOREF(idxChunk); 919 928 Assert(idxInChunk < pTbAllocator->cTbsPerChunk); RT_NOREF(idxInChunk); … … 932 941 * Free the TB itself. 933 942 */ 934 switch (pTb->fFlags & IEMTB_F_TYPE_MASK) 935 { 936 case IEMTB_F_TYPE_THREADED: 937 pTbAllocator->cThreadedTbs -= 1; 938 RTMemFree(pTb->Thrd.paCalls); 939 break; 943 if RT_CONSTEXPR_IF(a_fType == 0) 944 switch (pTb->fFlags & IEMTB_F_TYPE_MASK) 945 { 946 case IEMTB_F_TYPE_THREADED: 947 pTbAllocator->cThreadedTbs -= 1; 948 RTMemFree(pTb->Thrd.paCalls); 949 break; 940 950 #ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER 941 case IEMTB_F_TYPE_NATIVE: 942 pTbAllocator->cNativeTbs -= 1; 943 iemExecMemAllocatorFree(pVCpu, pTb->Native.paInstructions, 944 pTb->Native.cInstructions * sizeof(pTb->Native.paInstructions[0])); 945 pTb->Native.paInstructions = NULL; /* required by iemExecMemAllocatorPrune */ 946 break; 947 #endif 948 default: 949 AssertFailed(); 951 case IEMTB_F_TYPE_NATIVE: 952 pTbAllocator->cNativeTbs -= 1; 953 iemExecMemAllocatorFree(pVCpu, pTb->Native.paInstructions, 954 pTb->Native.cInstructions * sizeof(pTb->Native.paInstructions[0])); 955 pTb->Native.paInstructions = NULL; /* required by iemExecMemAllocatorPrune */ 956 break; 957 #endif 958 default: 959 AssertFailed(); 960 } 961 #ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER 962 else if RT_CONSTEXPR_IF(a_fType == IEMTB_F_TYPE_NATIVE) 963 { 964 Assert((pTb->fFlags & IEMTB_F_TYPE_MASK) == IEMTB_F_TYPE_NATIVE); 965 pTbAllocator->cNativeTbs -= 1; 966 iemExecMemAllocatorFree(pVCpu, pTb->Native.paInstructions, 967 pTb->Native.cInstructions * sizeof(pTb->Native.paInstructions[0])); 968 pTb->Native.paInstructions = NULL; /* required by iemExecMemAllocatorPrune */ 969 } 970 #endif 971 else 972 { 973 Assert((pTb->fFlags & IEMTB_F_TYPE_MASK) == IEMTB_F_TYPE_THREADED); 974 pTbAllocator->cThreadedTbs -= 1; 975 RTMemFree(pTb->Thrd.paCalls); 950 976 } 951 977 … … 993 1019 */ 994 1020 pVCpu->iem.s.ppTbLookupEntryR3 = &pVCpu->iem.s.pTbLookupEntryDummyR3; 995 iemTbAllocatorFreeInner(pVCpu, pTbAllocator, pTb, idxChunk, (uint32_t)idxInChunk); 996 } 997 1021 iemTbAllocatorFreeInner<0>(pVCpu, pTbAllocator, pTb, idxChunk, (uint32_t)idxInChunk); 1022 } 1023 1024 #ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER 1025 1026 /** 1027 * Interface used by iemExecMemAllocatorPrune. 1028 */ 1029 DECLHIDDEN(void) iemTbAllocatorFreeBulk(PVMCPUCC pVCpu, PIEMTBALLOCATOR pTbAllocator, PIEMTB pTb) 1030 { 1031 Assert(pTbAllocator->uMagic == IEMTBALLOCATOR_MAGIC); 1032 1033 uint8_t const idxChunk = pTb->idxAllocChunk; 1034 AssertLogRelReturnVoid(idxChunk < pTbAllocator->cAllocatedChunks); 1035 uintptr_t const idxInChunk = pTb - pTbAllocator->aChunks[idxChunk].paTbs; 1036 AssertLogRelReturnVoid(idxInChunk < pTbAllocator->cTbsPerChunk); 1037 1038 iemTbAllocatorFreeInner<IEMTB_F_TYPE_NATIVE>(pVCpu, pTbAllocator, pTb, idxChunk, (uint32_t)idxInChunk); 1039 } 1040 1041 1042 /** 1043 * Interface used by iemExecMemAllocatorPrune. 1044 */ 1045 DECLHIDDEN(PIEMTBALLOCATOR) iemTbAllocatorFreeBulkStart(PVMCPUCC pVCpu) 1046 { 1047 PIEMTBALLOCATOR const pTbAllocator = pVCpu->iem.s.pTbAllocatorR3; 1048 Assert(pTbAllocator && pTbAllocator->uMagic == IEMTBALLOCATOR_MAGIC); 1049 1050 iemTbAllocatorProcessDelayedFrees(pVCpu, pTbAllocator); 1051 1052 /* It should be sufficient to do this once. */ 1053 pVCpu->iem.s.ppTbLookupEntryR3 = &pVCpu->iem.s.pTbLookupEntryDummyR3; 1054 1055 return pTbAllocator; 1056 } 1057 1058 #endif /* VBOX_WITH_IEM_NATIVE_RECOMPILER */ 998 1059 999 1060 /** … … 1083 1144 PIEMTB const pTb = &paTbs[idxTb]; 1084 1145 if (pTb->fFlags) 1085 iemTbAllocatorFreeInner (pVCpu, pTbAllocator, pTb, idxChunk, idxTb);1146 iemTbAllocatorFreeInner<0>(pVCpu, pTbAllocator, pTb, idxChunk, idxTb); 1086 1147 } 1087 1148 } … … 1247 1308 1248 1309 /* Free the TB. */ 1249 iemTbAllocatorFreeInner (pVCpu, pTbAllocator, pTb, idxChunk, idxInChunk);1310 iemTbAllocatorFreeInner<0>(pVCpu, pTbAllocator, pTb, idxChunk, idxInChunk); 1250 1311 cFreedTbs++; /* paranoia */ 1251 1312 } … … 1370 1431 { 1371 1432 cMaxInstrs = RT_MAX(cMaxInstrs, pTb->Native.cInstructions); 1372 iemTbAllocatorFreeInner (pVCpu, pTbAllocator, pTb, idxChunk, idxInChunk);1433 iemTbAllocatorFreeInner<IEMTB_F_TYPE_NATIVE>(pVCpu, pTbAllocator, pTb, idxChunk, idxInChunk); 1373 1434 cFreedTbs++; 1374 1435 if (cFreedTbs >= 8 && cMaxInstrs >= cNeededInstrs) -
trunk/src/VBox/VMM/include/IEMInternal.h
r106297 r106329 6704 6704 void iemTbAllocatorProcessDelayedFrees(PVMCPUCC pVCpu, PIEMTBALLOCATOR pTbAllocator); 6705 6705 void iemTbAllocatorFreeupNativeSpace(PVMCPUCC pVCpu, uint32_t cNeededInstrs); 6706 DECLHIDDEN(PIEMTBALLOCATOR) iemTbAllocatorFreeBulkStart(PVMCPUCC pVCpu); 6707 DECLHIDDEN(void) iemTbAllocatorFreeBulk(PVMCPUCC pVCpu, PIEMTBALLOCATOR pTbAllocator, PIEMTB pTb); 6706 6708 DECLHIDDEN(const char *) iemTbFlagsToString(uint32_t fFlags, char *pszBuf, size_t cbBuf) RT_NOEXCEPT; 6707 6709 DECLHIDDEN(void) iemThreadedDisassembleTb(PCIEMTB pTb, PCDBGFINFOHLP pHlp) RT_NOEXCEPT;
Note:
See TracChangeset
for help on using the changeset viewer.