VirtualBox

Ignore:
Timestamp:
Sep 12, 2023 10:59:30 PM (15 months ago)
Author:
vboxsync
Message:

VMM/IEM: Fixed a bug in the TB allocator pruning code and another one wrt initial chunk allocations. bugref:10369

File:
1 edited

Legend:

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

    r101091 r101096  
    788788        pTbAllocator->cTotalTbs       += cTbsPerChunk;
    789789
    790         if (idxChunk * cTbsPerChunk >= cInitialTbs)
     790        if ((idxChunk + 1) * cTbsPerChunk >= cInitialTbs)
    791791            break;
    792792    }
     
    10031003    STAM_PROFILE_START(&pTbAllocator->StatPrune, a);
    10041004    uint32_t const msNow          = pVCpu->iem.s.msRecompilerPollNow;
     1005    uint32_t const cTbsToPrune    = 128;
     1006    uint32_t const cTbsPerGroup   = 4;
    10051007    uint32_t       cFreedTbs      = 0;
    10061008#ifdef IEMTB_SIZE_IS_POWER_OF_TWO
    1007     uint32_t       idxTbPruneFrom = pTbAllocator->iPruneFrom & ~(uint32_t)3;
     1009    uint32_t       idxTbPruneFrom = pTbAllocator->iPruneFrom & ~(uint32_t)(cTbsToPrune - 1); /* Stay within a chunk! */
    10081010#else
    10091011    uint32_t       idxTbPruneFrom = pTbAllocator->iPruneFrom;
    10101012#endif
    1011     if (idxTbPruneFrom > pTbAllocator->cMaxTbs)
     1013    if (idxTbPruneFrom >= pTbAllocator->cMaxTbs)
    10121014        idxTbPruneFrom = 0;
    1013     for (uint32_t i = 0; i < 128; i += 4, idxTbPruneFrom += 4)
     1015    for (uint32_t i = 0; i < cTbsToPrune; i += cTbsPerGroup, idxTbPruneFrom += cTbsPerGroup)
    10141016    {
    10151017        uint32_t idxChunk   = IEMTBALLOC_IDX_TO_CHUNK(pTbAllocator, idxTbPruneFrom);
     
    10171019        PIEMTB   pTb        = &pTbAllocator->aChunks[idxChunk].paTbs[idxInChunk];
    10181020        uint32_t cMsAge     = msNow - pTb->msLastUsed;
    1019         for (uint32_t j = 1, idxChunk2 = idxChunk, idxInChunk2 = idxInChunk + 1; j < 4; j++, idxInChunk2++)
     1021        for (uint32_t j = 1, idxChunk2 = idxChunk, idxInChunk2 = idxInChunk + 1; j < cTbsPerGroup; j++, idxInChunk2++)
    10201022        {
    10211023#ifndef IEMTB_SIZE_IS_POWER_OF_TWO
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