VirtualBox

Changeset 102724 in vbox for trunk/src/VBox/VMM/include


Ignore:
Timestamp:
Dec 28, 2023 9:15:52 PM (14 months ago)
Author:
vboxsync
Message:

VMM/IEM: Moved the TLB lookup code emitting into a separate function and straighten the code path a little by starting with a jump and moving the check_expand_down stuff in after tlbmiss. bugref:10371

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/IEMN8veRecompiler.h

    r102717 r102724  
    319319    kIemNativeLabelType_Endif,
    320320    kIemNativeLabelType_CheckIrq,
     321    kIemNativeLabelType_TlbLookup,
    321322    kIemNativeLabelType_TlbMiss,
    322323    kIemNativeLabelType_TlbDone,
  • trunk/src/VBox/VMM/include/IEMN8veRecompilerEmit.h

    r102720 r102724  
    8282 * Emit a breakpoint instruction.
    8383 */
     84DECL_FORCE_INLINE(uint32_t) iemNativeEmitBrkEx(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint32_t uInfo)
     85{
     86#ifdef RT_ARCH_AMD64
     87    pCodeBuf[off++] = 0xcc;
     88    RT_NOREF(uInfo);   /** @todo use multibyte nop for info? */
     89
     90#elif defined(RT_ARCH_ARM64)
     91    pCodeBuf[off++] = Armv8A64MkInstrBrk(uInfo & UINT32_C(0xffff));
     92
     93#else
     94# error "error"
     95#endif
     96    return off;
     97}
     98
     99
     100/**
     101 * Emit a breakpoint instruction.
     102 */
    84103DECL_INLINE_THROW(uint32_t) iemNativeEmitBrk(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint32_t uInfo)
    85104{
    86105#ifdef RT_ARCH_AMD64
    87     uint8_t * const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1);
    88     pbCodeBuf[off++] = 0xcc;
    89     RT_NOREF(uInfo);
    90 
    91 #elif defined(RT_ARCH_ARM64)
    92     uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1);
    93     pu32CodeBuf[off++] = Armv8A64MkInstrBrk(uInfo & UINT32_C(0xffff));
    94 
     106    off = iemNativeEmitBrkEx(iemNativeInstrBufEnsure(pReNative, off, 1), off, uInfo);
     107#elif defined(RT_ARCH_ARM64)
     108    off = iemNativeEmitBrkEx(iemNativeInstrBufEnsure(pReNative, off, 1), off, uInfo);
    95109#else
    96110# error "error"
     
    33213335    Assert(idxLabel < pReNative->cLabels);
    33223336
    3323 #ifdef RT_ARCH_AMD64
    3324     /* jcc rel32 */
    3325     pCodeBuf[off++] = 0x0f;
    3326     pCodeBuf[off++] = (uint8_t)enmCond | 0x80;
    3327     iemNativeAddFixup(pReNative, off, idxLabel, kIemNativeFixupType_Rel32, -4);
    3328     pCodeBuf[off++] = 0x00;
    3329     pCodeBuf[off++] = 0x00;
    3330     pCodeBuf[off++] = 0x00;
    3331     pCodeBuf[off++] = 0x00;
    3332 
    3333 #elif defined(RT_ARCH_ARM64)
    3334     iemNativeAddFixup(pReNative, off, idxLabel, kIemNativeFixupType_RelImm19At5);
    3335     pCodeBuf[off++] = Armv8A64MkInstrBCond(enmCond, -1);
     3337    uint32_t const offLabel = pReNative->paLabels[idxLabel].off;
     3338#ifdef RT_ARCH_AMD64
     3339    if (offLabel >= off)
     3340    {
     3341        /* jcc rel32 */
     3342        pCodeBuf[off++] = 0x0f;
     3343        pCodeBuf[off++] = (uint8_t)enmCond | 0x80;
     3344        iemNativeAddFixup(pReNative, off, idxLabel, kIemNativeFixupType_Rel32, -4);
     3345        pCodeBuf[off++] = 0x00;
     3346        pCodeBuf[off++] = 0x00;
     3347        pCodeBuf[off++] = 0x00;
     3348        pCodeBuf[off++] = 0x00;
     3349    }
     3350    else
     3351    {
     3352        int32_t offDisp = offLabel - (off + 2);
     3353        if ((int8_t)offDisp == offDisp)
     3354        {
     3355            /* jcc rel8 */
     3356            pCodeBuf[off++] = (uint8_t)enmCond | 0x70;
     3357            pCodeBuf[off++] = RT_BYTE1((uint32_t)offDisp);
     3358        }
     3359        else
     3360        {
     3361            /* jcc rel32 */
     3362            offDisp -= 4;
     3363            pCodeBuf[off++] = 0x0f;
     3364            pCodeBuf[off++] = (uint8_t)enmCond | 0x80;
     3365            pCodeBuf[off++] = RT_BYTE1((uint32_t)offDisp);
     3366            pCodeBuf[off++] = RT_BYTE2((uint32_t)offDisp);
     3367            pCodeBuf[off++] = RT_BYTE3((uint32_t)offDisp);
     3368            pCodeBuf[off++] = RT_BYTE4((uint32_t)offDisp);
     3369        }
     3370    }
     3371
     3372#elif defined(RT_ARCH_ARM64)
     3373    if (offLabel >= off)
     3374    {
     3375        iemNativeAddFixup(pReNative, off, idxLabel, kIemNativeFixupType_RelImm19At5);
     3376        pCodeBuf[off++] = Armv8A64MkInstrBCond(enmCond, -1);
     3377    }
     3378    else
     3379    {
     3380        Assert(offLabel - off <= -0x3ffff);
     3381        pCodeBuf[off++] = Armv8A64MkInstrBCond(enmCond, offLabel - off);
     3382    }
    33363383
    33373384#else
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