VirtualBox

Changeset 106478 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Oct 18, 2024 1:20:19 PM (3 months ago)
Author:
vboxsync
Message:

VMM/IEM: Some IEMNATIVEVAR / iemNativeVarAllocInt optimization tweaks. bugref:10720

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

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

    r106465 r106478  
    70987098 * @internal
    70997099 */
    7100 static uint8_t iemNativeVarAllocInt(PIEMRECOMPILERSTATE pReNative, uint8_t cbType)
     7100DECL_INLINE_THROW(uint8_t) iemNativeVarAllocInt(PIEMRECOMPILERSTATE pReNative, uint8_t cbType)
    71017101{
    71027102    Assert(cbType > 0 && cbType <= 64);
    71037103    unsigned const idxVar = ASMBitFirstSetU32(~pReNative->Core.bmVars) - 1;
    71047104    AssertStmt(idxVar < RT_ELEMENTS(pReNative->Core.aVars), IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_EXHAUSTED));
     7105
    71057106    pReNative->Core.bmVars |= RT_BIT_32(idxVar);
    7106     pReNative->Core.aVars[idxVar].enmKind        = kIemNativeVarKind_Invalid;
    7107     pReNative->Core.aVars[idxVar].cbVar          = cbType;
    7108     pReNative->Core.aVars[idxVar].idxStackSlot   = UINT8_MAX;
    7109     pReNative->Core.aVars[idxVar].idxReg         = UINT8_MAX;
    7110     pReNative->Core.aVars[idxVar].uArgNo         = UINT8_MAX;
    7111     pReNative->Core.aVars[idxVar].idxReferrerVar = UINT8_MAX;
    7112     pReNative->Core.aVars[idxVar].enmGstReg      = kIemNativeGstReg_End;
    7113     pReNative->Core.aVars[idxVar].fRegAcquired   = false;
    7114     pReNative->Core.aVars[idxVar].u.uValue       = 0;
    7115     pReNative->Core.aVars[idxVar].fSimdReg       = false;
     7107
     7108    PIEMNATIVEVAR const pVar = &pReNative->Core.aVars[idxVar]; /* VS 2019 gets a bit weird on us otherwise. */
     7109#if 0
     7110    pVar->cbVar          = cbType;
     7111    pVar->enmKind        = kIemNativeVarKind_Invalid;
     7112    pVar->fRegAcquired   = false;
     7113    pVar->fSimdReg       = false;
     7114    pVar->idxReg         = UINT8_MAX;
     7115    pVar->uArgNo         = UINT8_MAX;
     7116    pVar->idxStackSlot   = UINT8_MAX;
     7117    pVar->idxReferrerVar = UINT8_MAX;
     7118    pVar->u.uValue       = 0;
     7119#else
     7120    /* Neither clang 15 nor VC++ 2019 is able to generate this from the above. */
     7121    AssertCompileMemberOffset(IEMNATIVEVAR, cbVar, 1);
     7122    AssertCompile((int)kIemNativeVarKind_Invalid == 0);
     7123    pVar->u32Init0       = (uint32_t)cbType << 8;
     7124    pVar->u32Init1       = UINT32_MAX;
     7125    pVar->u.uValue       = 0;
     7126#endif
    71167127    return idxVar;
    71177128}
     
    78227833                   g_apszIemNativeHstRegNames[idxReg], g_aGstShadowInfo[enmGstReg].pszName));
    78237834        }
    7824         /** @todo figure this one out. We need some way of making sure the register isn't
    7825          * modified after this point, just in case we start writing crappy MC code. */
    7826         pVar->enmGstReg    = enmGstReg;
    78277835        pVar->fRegAcquired = true;
    78287836        return idxReg;
  • trunk/src/VBox/VMM/include/IEMN8veRecompiler.h

    r106465 r106478  
    15631563typedef struct IEMNATIVEVAR
    15641564{
    1565     /** The kind of variable. */
    1566     IEMNATIVEVARKIND    enmKind;
    1567     /** The variable size in bytes. */
    1568     uint8_t             cbVar;
    1569     /** The first stack slot (uint64_t), except for immediate and references
    1570      *  where it usually is UINT8_MAX. This is allocated lazily, so if a variable
    1571      *  has a stack slot it has been initialized and has a value.  Unused variables
    1572      *  has neither a stack slot nor a host register assignment. */
    1573     uint8_t             idxStackSlot;
    1574     /** The host register allocated for the variable, UINT8_MAX if not. */
    1575     uint8_t             idxReg;
    1576     /** The argument number if argument, UINT8_MAX if regular variable. */
    1577     uint8_t             uArgNo;
    1578     /** If referenced, the index (unpacked) of the variable referencing this one,
    1579      * otherwise UINT8_MAX.  A referenced variable must only be placed on the stack
    1580      * and must be either kIemNativeVarKind_Stack or kIemNativeVarKind_Immediate. */
    1581     uint8_t             idxReferrerVar;
    1582     /** Guest register being shadowed here, kIemNativeGstReg_End(/UINT8_MAX) if not.
    1583      * @todo not sure what this really is for...   */
    1584     IEMNATIVEGSTREG     enmGstReg;
    1585     /** Flag whether this variable is held in a SIMD register (only supported for 128-bit and 256-bit variables),
    1586      * only valid when idxReg is not UINT8_MAX. */
    1587     bool                fSimdReg     : 1;
    1588     /** Set if the registered is currently used exclusively, false if the
    1589      *  variable is idle and the register can be grabbed. */
    1590     bool                fRegAcquired : 1;
     1565    union
     1566    {
     1567        struct
     1568        {
     1569            /** The kind of variable. */
     1570            IEMNATIVEVARKIND    enmKind;
     1571            /** The variable size in bytes. */
     1572            uint8_t             cbVar;
     1573            /** Set if the registered is currently used exclusively, false if the
     1574             *  variable is idle and the register can be grabbed. */
     1575            bool                fRegAcquired;
     1576            /** Flag whether this variable is held in a SIMD register (only supported for
     1577             * 128-bit and 256-bit variables), only valid when idxReg is not UINT8_MAX. */
     1578            bool                fSimdReg;
     1579        };
     1580        uint32_t        u32Init0;   /**< Init optimzation - cbVar is set, the other are initialized with zeros. */
     1581    };
     1582
     1583    union
     1584    {
     1585        struct
     1586        {
     1587            /** The host register allocated for the variable, UINT8_MAX if not. */
     1588            uint8_t             idxReg;
     1589            /** The argument number if argument, UINT8_MAX if regular variable. */
     1590            uint8_t             uArgNo;
     1591            /** The first stack slot (uint64_t), except for immediate and references
     1592             *  where it usually is UINT8_MAX. This is allocated lazily, so if a variable
     1593             *  has a stack slot it has been initialized and has a value.  Unused variables
     1594             *  has neither a stack slot nor a host register assignment. */
     1595            uint8_t             idxStackSlot;
     1596            /** If referenced, the index (unpacked) of the variable referencing this one,
     1597             * otherwise UINT8_MAX.  A referenced variable must only be placed on the stack
     1598             * and must be either kIemNativeVarKind_Stack or kIemNativeVarKind_Immediate. */
     1599            uint8_t             idxReferrerVar;
     1600        };
     1601        uint32_t        u32Init1;   /**< Init optimization; all these are initialized to 0xff. */
     1602    };
    15911603
    15921604    union
     
    16061618    } u;
    16071619} IEMNATIVEVAR;
     1620AssertCompileSize(IEMNATIVEVAR, 16);
    16081621/** Pointer to a variable or argument. */
    16091622typedef IEMNATIVEVAR *PIEMNATIVEVAR;
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