VirtualBox

Changeset 99930 in vbox


Ignore:
Timestamp:
May 23, 2023 9:53:04 AM (23 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
157577
Message:

VMM/IEM: More recompiler work. bugref:10369

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/iem.h

    r98982 r99930  
    159159VMMDECL(VBOXSTRICTRC)       IEMExecOneIgnoreLock(PVMCPUCC pVCpu);
    160160VMMDECL(VBOXSTRICTRC)       IEMExecLots(PVMCPUCC pVCpu, uint32_t cMaxInstructions, uint32_t cPollRate, uint32_t *pcInstructions);
     161VMMDECL(VBOXSTRICTRC)       IEMExecRecompilerThreaded(PVMCC pVM, PVMCPUCC pVCpu);
    161162/** Statistics returned by IEMExecForExits. */
    162163typedef struct IEMEXECFOREXITSTATS
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r99739 r99930  
    1014310143
    1014410144
    10145 /** @def IEM_TRY_SETJMP
    10146  * Wrapper around setjmp / try, hiding all the ugly differences.
    10147  *
    10148  * @note Use with extreme care as this is a fragile macro.
    10149  * @param   a_pVCpu     The cross context virtual CPU structure of the calling EMT.
    10150  * @param   a_rcTarget  The variable that should receive the status code in case
    10151  *                      of a longjmp/throw.
    10152  */
    10153 /** @def IEM_TRY_SETJMP_AGAIN
    10154  * For when setjmp / try is used again in the same variable scope as a previous
    10155  * IEM_TRY_SETJMP invocation.
    10156  */
    10157 /** @def IEM_CATCH_LONGJMP_BEGIN
    10158  * Start wrapper for catch / setjmp-else.
    10159  *
    10160  * This will set up a scope.
    10161  *
    10162  * @note Use with extreme care as this is a fragile macro.
    10163  * @param   a_pVCpu     The cross context virtual CPU structure of the calling EMT.
    10164  * @param   a_rcTarget  The variable that should receive the status code in case
    10165  *                      of a longjmp/throw.
    10166  */
    10167 /** @def IEM_CATCH_LONGJMP_END
    10168  * End wrapper for catch / setjmp-else.
    10169  *
    10170  * This will close the scope set up by IEM_CATCH_LONGJMP_BEGIN and clean up the
    10171  * state.
    10172  *
    10173  * @note Use with extreme care as this is a fragile macro.
    10174  * @param   a_pVCpu     The cross context virtual CPU structure of the calling EMT.
    10175  */
    10176 #if defined(IEM_WITH_SETJMP) || defined(DOXYGEN_RUNNING)
    10177 # ifdef IEM_WITH_THROW_CATCH
    10178 #  define IEM_TRY_SETJMP(a_pVCpu, a_rcTarget) \
    10179         a_rcTarget = VINF_SUCCESS; \
    10180         try
    10181 #  define IEM_TRY_SETJMP_AGAIN(a_pVCpu, a_rcTarget) \
    10182         IEM_TRY_SETJMP(a_pVCpu, a_rcTarget)
    10183 #  define IEM_CATCH_LONGJMP_BEGIN(a_pVCpu, a_rcTarget) \
    10184         catch (int rcThrown) \
    10185         { \
    10186             a_rcTarget = rcThrown
    10187 #  define IEM_CATCH_LONGJMP_END(a_pVCpu) \
    10188         } \
    10189         ((void)0)
    10190 # else  /* !IEM_WITH_THROW_CATCH */
    10191 #  define IEM_TRY_SETJMP(a_pVCpu, a_rcTarget) \
    10192         jmp_buf  JmpBuf; \
    10193         jmp_buf * volatile pSavedJmpBuf = pVCpu->iem.s.CTX_SUFF(pJmpBuf); \
    10194         pVCpu->iem.s.CTX_SUFF(pJmpBuf) = &JmpBuf; \
    10195         if ((rcStrict = setjmp(JmpBuf)) == 0)
    10196 #  define IEM_TRY_SETJMP_AGAIN(a_pVCpu, a_rcTarget) \
    10197         pSavedJmpBuf = pVCpu->iem.s.CTX_SUFF(pJmpBuf); \
    10198         pVCpu->iem.s.CTX_SUFF(pJmpBuf) = &JmpBuf; \
    10199         if ((rcStrict = setjmp(JmpBuf)) == 0)
    10200 #  define IEM_CATCH_LONGJMP_BEGIN(a_pVCpu, a_rcTarget) \
    10201         else \
    10202         { \
    10203             ((void)0)
    10204 #  define IEM_CATCH_LONGJMP_END(a_pVCpu) \
    10205         } \
    10206         (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf) = pSavedJmpBuf
    10207 # endif /* !IEM_WITH_THROW_CATCH */
    10208 #endif  /* IEM_WITH_SETJMP */
    10209 
    10210 
    1021110145/**
    1021210146 * The actual code execution bits of IEMExecOne, IEMExecOneEx, and
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsThreadedRecompiler.cpp

    r99863 r99930  
    261261 */
    262262
     263static VBOXSTRICTRC iemThreadedCompile(PVMCCV pVM, PVMCPUCC pVCpu)
     264{
     265    RT_NOREF(pVM, pVCpu, pTb);
     266    return VERR_NOT_IMPLEMENTED;
     267}
     268
     269
     270static VBOXSTRICTRC iemThreadedCompileLongJumped(PVMCCV pVM, PVMCPUCC pVCpu, VBOXSTRICTRC rcStrict)
     271{
     272    RT_NOREF(pVM, pVCpu);
     273    return rcStrict;
     274}
     275
     276
     277static PIEMTB iemThreadedTbLookup(PVMCCV pVM, PVMCPUCC pVCpu)
     278{
     279    RT_NOREF(pVM, pVCpu);
     280    return NULL;
     281}
     282
     283
     284static VBOXSTRICTRC iemThreadedTbExec(PVMCCV pVM, PVMCPUCC pVCpu, PIEMTB pTb)
     285{
     286    RT_NOREF(pVM, pVCpu, pTb);
     287    return VERR_NOT_IMPLEMENTED;
     288}
     289
     290
     291VMMDECL(VBOXSTRICTRC) IEMExecRecompilerThreaded(PVMCC pVM, PVMCPUCC pVCpu)
     292{
     293    /*
     294     * Run-loop.
     295     * 
     296     * If we're using setjmp/longjmp we combine all the catching here to avoid
     297     * having to call setjmp for each block we're executing.
     298     */
     299    for (;;)
     300    {
     301        PIEMTB       pTb = NULL;
     302        VBOXSTRICTRC rcStrict;
     303#ifdef IEM_WITH_SETJMP
     304        IEM_TRY_SETJMP(pVCpu, rcStrict)
     305#endif
     306        {
     307            for (;;)
     308            {
     309                pTb = iemThreadedTbLookup(pVM, pVCpu);
     310                if (pTb)
     311                    rcStrict = iemThreadedTbExec(pVM, pVCpu, pTb);
     312                else
     313                    rcStrict = iemThreadedCompile(pVM, pVCpu);
     314                if (rcStrict == VINF_SUCCESS)
     315                { /* likely */ }
     316                else
     317                    return rcStrict;
     318            }
     319        }
     320#ifdef IEM_WITH_SETJMP
     321        IEM_CATCH_LONGJMP_BEGIN(pVCpu, rcStrict);
     322        {
     323            pVCpu->iem.s.cLongJumps++;
     324            if (pTb)
     325                return rcStrict;
     326            return iemThreadedCompileLongJumped(pVM, pVCpu, rcStrict);
     327        }
     328        IEM_CATCH_LONGJMP_END(pVCpu);
     329#endif
     330    }
     331}
     332
  • trunk/src/VBox/VMM/VMMR3/EM.cpp

    r99920 r99930  
    10821082#ifdef VBOX_WITH_IEM_RECOMPILER
    10831083            if (pVM->em.s.fIemRecompiled)
    1084                 rcStrict = IEMExecLots(pVCpu, 8192 /*cMaxInstructions*/, 4095 /*cPollRate*/, NULL /*pcInstructions*/);
     1084                rcStrict = IEMExecRecompilerThreaded(pVCpu);
    10851085            else
    10861086#endif
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r99832 r99930  
    957957# define IEM_GET_INSTR_LEN(a_pVCpu)     ((a_pVCpu)->iem.s.offOpcode)
    958958#endif
     959
     960/** @def IEM_TRY_SETJMP
     961 * Wrapper around setjmp / try, hiding all the ugly differences.
     962 *
     963 * @note Use with extreme care as this is a fragile macro.
     964 * @param   a_pVCpu     The cross context virtual CPU structure of the calling EMT.
     965 * @param   a_rcTarget  The variable that should receive the status code in case
     966 *                      of a longjmp/throw.
     967 */
     968/** @def IEM_TRY_SETJMP_AGAIN
     969 * For when setjmp / try is used again in the same variable scope as a previous
     970 * IEM_TRY_SETJMP invocation.
     971 */
     972/** @def IEM_CATCH_LONGJMP_BEGIN
     973 * Start wrapper for catch / setjmp-else.
     974 *
     975 * This will set up a scope.
     976 *
     977 * @note Use with extreme care as this is a fragile macro.
     978 * @param   a_pVCpu     The cross context virtual CPU structure of the calling EMT.
     979 * @param   a_rcTarget  The variable that should receive the status code in case
     980 *                      of a longjmp/throw.
     981 */
     982/** @def IEM_CATCH_LONGJMP_END
     983 * End wrapper for catch / setjmp-else.
     984 *
     985 * This will close the scope set up by IEM_CATCH_LONGJMP_BEGIN and clean up the
     986 * state.
     987 *
     988 * @note Use with extreme care as this is a fragile macro.
     989 * @param   a_pVCpu     The cross context virtual CPU structure of the calling EMT.
     990 */
     991#if defined(IEM_WITH_SETJMP) || defined(DOXYGEN_RUNNING)
     992# ifdef IEM_WITH_THROW_CATCH
     993#  define IEM_TRY_SETJMP(a_pVCpu, a_rcTarget) \
     994        a_rcTarget = VINF_SUCCESS; \
     995        try
     996#  define IEM_TRY_SETJMP_AGAIN(a_pVCpu, a_rcTarget) \
     997        IEM_TRY_SETJMP(a_pVCpu, a_rcTarget)
     998#  define IEM_CATCH_LONGJMP_BEGIN(a_pVCpu, a_rcTarget) \
     999        catch (int rcThrown) \
     1000        { \
     1001            a_rcTarget = rcThrown
     1002#  define IEM_CATCH_LONGJMP_END(a_pVCpu) \
     1003        } \
     1004        ((void)0)
     1005# else  /* !IEM_WITH_THROW_CATCH */
     1006#  define IEM_TRY_SETJMP(a_pVCpu, a_rcTarget) \
     1007        jmp_buf  JmpBuf; \
     1008        jmp_buf * volatile pSavedJmpBuf = pVCpu->iem.s.CTX_SUFF(pJmpBuf); \
     1009        pVCpu->iem.s.CTX_SUFF(pJmpBuf) = &JmpBuf; \
     1010        if ((rcStrict = setjmp(JmpBuf)) == 0)
     1011#  define IEM_TRY_SETJMP_AGAIN(a_pVCpu, a_rcTarget) \
     1012        pSavedJmpBuf = pVCpu->iem.s.CTX_SUFF(pJmpBuf); \
     1013        pVCpu->iem.s.CTX_SUFF(pJmpBuf) = &JmpBuf; \
     1014        if ((rcStrict = setjmp(JmpBuf)) == 0)
     1015#  define IEM_CATCH_LONGJMP_BEGIN(a_pVCpu, a_rcTarget) \
     1016        else \
     1017        { \
     1018            ((void)0)
     1019#  define IEM_CATCH_LONGJMP_END(a_pVCpu) \
     1020        } \
     1021        (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf) = pSavedJmpBuf
     1022# endif /* !IEM_WITH_THROW_CATCH */
     1023#endif  /* IEM_WITH_SETJMP */
    9591024
    9601025
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette