VirtualBox

Changeset 103907 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Mar 19, 2024 7:48:28 AM (9 months ago)
Author:
vboxsync
Message:

VMM/IEM: Fix the stack slot allocator for values spanning multiple slots and fix a todo, fix reading the variable index from the wrong register set, bugref:10614

File:
1 edited

Legend:

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

    r103895 r103907  
    70187018        pReNative->Core.bmStack |= RT_BIT_32(iSlot);
    70197019        pVar->idxStackSlot       = (uint8_t)iSlot;
    7020         Log11(("iemNativeVarSetKindToStack: idxVar=%#x iSlot=%#x\n", idxVar, iSlot));
     7020        Log11(("iemNativeVarGetStackSlot: idxVar=%#x iSlot=%#x\n", idxVar, iSlot));
    70217021        return (uint8_t)iSlot;
    70227022    }
     
    70317031    uint32_t const fBitAlignMask = RT_BIT_32(ASMBitLastSetU32(pVar->cbVar) - 4) - 1;
    70327032    uint32_t       fBitAllocMask = RT_BIT_32((pVar->cbVar + 7) >> 3) - 1;
    7033     uint32_t       bmStack       = ~pReNative->Core.bmStack;
    7034     while (bmStack != 0)
    7035     {
    7036 /** @todo allocate from the top to reduce BP displacement. */
    7037         unsigned const iSlot = ASMBitFirstSetU32(bmStack) - 1;
    7038         AssertStmt(iSlot < IEMNATIVE_FRAME_VAR_SLOTS, IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_OUT_OF_STACK_SLOTS));
    7039         if (!(iSlot & fBitAlignMask))
     7033    uint32_t       bmStack       = pReNative->Core.bmStack;
     7034    while (bmStack != UINT32_MAX)
     7035    {
     7036        unsigned iSlot = ASMBitLastSetU32(~bmStack);
     7037        AssertStmt(iSlot, IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_OUT_OF_STACK_SLOTS));
     7038        iSlot = (iSlot - 1) & ~fBitAlignMask;
     7039        if ((bmStack & ~(fBitAllocMask << iSlot)) == bmStack)
    70407040        {
    7041             if ((bmStack & (fBitAllocMask << iSlot)) == (fBitAllocMask << iSlot))
    7042             {
    7043                 pReNative->Core.bmStack |= (fBitAllocMask << iSlot);
    7044                 pVar->idxStackSlot       = (uint8_t)iSlot;
    7045                 Log11(("iemNativeVarSetKindToStack: idxVar=%#x iSlot=%#x/%#x (cbVar=%#x)\n",
    7046                        idxVar, iSlot, fBitAllocMask, pVar->cbVar));
    7047                 return (uint8_t)iSlot;
    7048             }
     7041            pReNative->Core.bmStack |= (fBitAllocMask << iSlot);
     7042            pVar->idxStackSlot       = (uint8_t)iSlot;
     7043            Log11(("iemNativeVarGetStackSlot: idxVar=%#x iSlot=%#x/%#x (cbVar=%#x)\n",
     7044                   idxVar, iSlot, fBitAllocMask, pVar->cbVar));
     7045            return (uint8_t)iSlot;
    70497046        }
    7050         bmStack &= ~(fBitAlignMask << (iSlot & ~fBitAlignMask));
     7047
     7048        bmStack |= (fBitAllocMask << iSlot);
    70517049    }
    70527050    AssertFailedStmt(IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_OUT_OF_STACK_SLOTS));
     
    78457843            Assert(pReNative->Core.aHstSimdRegs[idxHstReg].enmWhat == kIemNativeWhat_Var);
    78467844
    7847             uint8_t const idxVar = pReNative->Core.aHstRegs[idxHstReg].idxVar;
     7845            uint8_t const idxVar = pReNative->Core.aHstSimdRegs[idxHstReg].idxVar;
    78487846            IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
    78497847            AssertStmt(   IEMNATIVE_VAR_IDX_UNPACK(idxVar) < RT_ELEMENTS(pReNative->Core.aVars)
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