VirtualBox

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


Ignore:
Timestamp:
Oct 20, 2023 2:46:13 PM (15 months ago)
Author:
vboxsync
Message:

VMM/IEM: Cleanups. bugref:10371

File:
1 edited

Legend:

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

    r101518 r101523  
    574574DECLHIDDEN(uint32_t)        iemNativeRegFlushPendingWrites(PIEMRECOMPILERSTATE pReNative, uint32_t off) RT_NOEXCEPT;
    575575
     576DECLHIDDEN(uint32_t)        iemNativeEmitLoadGprWithGstShadowReg(PIEMRECOMPILERSTATE pReNative, uint32_t off,
     577                                                                 uint8_t idxHstReg, IEMNATIVEGSTREG enmGstReg) RT_NOEXCEPT;
    576578DECLHIDDEN(uint32_t)        iemNativeEmitCheckCallRetAndPassUp(PIEMRECOMPILERSTATE pReNative, uint32_t off,
    577579                                                               uint8_t idxInstr) RT_NOEXCEPT;
     
    16451647
    16461648/**
    1647  * Emits a JMP rel32 / B imm19 to the given label (ASSUMED requiring fixup).
     1649 * Emits a JMP rel32 / B imm19 to the given label.
    16481650 */
    16491651DECLINLINE(uint32_t) iemNativeEmitJmpToLabel(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint32_t idxLabel)
    16501652{
    1651 #ifdef RT_ARCH_AMD64
    1652     /* jnz rel32 */
    1653     uint8_t * const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 5);
    1654     AssertReturn(pbCodeBuf, UINT32_MAX);
    1655     pbCodeBuf[off++] = 0xe9;
    1656     AssertReturn(iemNativeAddFixup(pReNative, off, idxLabel, kIemNativeFixupType_Rel32, -4), UINT32_MAX);
    1657     pbCodeBuf[off++] = 0xfe;
    1658     pbCodeBuf[off++] = 0xff;
    1659     pbCodeBuf[off++] = 0xff;
    1660     pbCodeBuf[off++] = 0xff;
     1653    Assert(idxLabel < pReNative->cLabels);
     1654
     1655#ifdef RT_ARCH_AMD64
     1656    uint8_t * const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 6);
     1657    AssertReturn(pbCodeBuf, UINT32_MAX);
     1658    if (pReNative->paLabels[idxLabel].off != UINT32_MAX)
     1659    {
     1660        uint32_t offRel = pReNative->paLabels[idxLabel].off - (off + 2);
     1661        if ((int32_t)offRel < 128 && (int32_t)offRel >= -128)
     1662        {
     1663            pbCodeBuf[off++] = 0xeb;                /* jmp rel8 */
     1664            pbCodeBuf[off++] = (uint8_t)offRel;
     1665            off++;
     1666        }
     1667        else
     1668        {
     1669            offRel -= 3;
     1670            pbCodeBuf[off++] = 0xe9;                /* jmp rel32 */
     1671            pbCodeBuf[off++] = RT_BYTE1(offRel);
     1672            pbCodeBuf[off++] = RT_BYTE2(offRel);
     1673            pbCodeBuf[off++] = RT_BYTE3(offRel);
     1674            pbCodeBuf[off++] = RT_BYTE4(offRel);
     1675        }
     1676    }
     1677    else
     1678    {
     1679        pbCodeBuf[off++] = 0xe9;                    /* jmp rel32 */
     1680        AssertReturn(iemNativeAddFixup(pReNative, off, idxLabel, kIemNativeFixupType_Rel32, -4), UINT32_MAX);
     1681        pbCodeBuf[off++] = 0xfe;
     1682        pbCodeBuf[off++] = 0xff;
     1683        pbCodeBuf[off++] = 0xff;
     1684        pbCodeBuf[off++] = 0xff;
     1685    }
     1686    pbCodeBuf[off++] = 0xcc;                        /* int3 poison */
    16611687
    16621688#elif defined(RT_ARCH_ARM64)
    16631689    uint32_t *pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1);
    16641690    AssertReturn(pu32CodeBuf, UINT32_MAX);
    1665     AssertReturn(iemNativeAddFixup(pReNative, off, idxLabel, kIemNativeFixupType_RelImm19At5), UINT32_MAX);
    1666     pu32CodeBuf[off++] = Armv8A64MkInstrB(-1);
     1691    if (pReNative->paLabels[idxLabel].off != UINT32_MAX)
     1692        pu32CodeBuf[off++] = Armv8A64MkInstrB(pReNative->paLabels[idxReturnLabel].off - off);
     1693    else
     1694    {
     1695        AssertReturn(iemNativeAddFixup(pReNative, off, idxLabel, kIemNativeFixupType_RelImm19At5), UINT32_MAX);
     1696        pu32CodeBuf[off++] = Armv8A64MkInstrB(-1);
     1697    }
    16671698
    16681699#else
     
    17001731                                             uint32_t idxLabel, IEMNATIVEINSTRCOND enmCond)
    17011732{
     1733    Assert(idxLabel < pReNative->cLabels);
     1734
    17021735#ifdef RT_ARCH_AMD64
    17031736    /* jcc rel32 */
     
    19371970
    19381971
     1972/**
     1973 * Emits a call to a 64-bit address.
     1974 */
     1975DECLINLINE(uint32_t) iemNativeEmitCallImm(PIEMRECOMPILERSTATE pReNative, uint32_t off, uintptr_t uPfn)
     1976{
     1977#ifdef RT_ARCH_AMD64
     1978    off = iemNativeEmitLoadGprImm64(pReNative, off, X86_GREG_xAX, uPfn);
     1979
     1980    /* call rax */
     1981    uint8_t * const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 2);
     1982    AssertReturn(pbCodeBuf, UINT32_MAX);
     1983    pbCodeBuf[off++] = 0xff;
     1984    pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 2, X86_GREG_xAX);
     1985
     1986#elif defined(RT_ARCH_ARM64)
     1987    off = iemNativeEmitLoadGprImm64(pReNative, off, IEMNATIVE_REG_FIXED_TMP0, uPfn);
     1988
     1989    uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1);
     1990    AssertReturn(pu32CodeBuf, UINT32_MAX);
     1991    pu32CodeBuf[off++] = Armv8A64MkInstrBlr(IEMNATIVE_REG_FIXED_TMP0);
     1992#else
     1993# error "port me"
     1994#endif
     1995    return off;
     1996}
     1997
     1998
    19391999
    19402000/** @} */
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