VirtualBox

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


Ignore:
Timestamp:
Sep 18, 2023 8:44:24 PM (18 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159136
Message:

VMM/IEM: Experimental recompilation of threaded blocks into native code on linux.amd64. bugref:10370

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

Legend:

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

    r100998 r101163  
    332332}
    333333
     334#ifdef VBOX_INCLUDED_vmm_dbgf_h /* VM::dbgf.ro.cEnabledHwBreakpoints is only accessible if VBox/vmm/dbgf.h is included. */
    334335
    335336/**
     
    392393}
    393394
     395#endif /* VBOX_INCLUDED_vmm_dbgf_h */
     396
    394397
    395398#ifndef IEM_WITH_OPAQUE_DECODER_STATE
    396399
    397400# if defined(VBOX_INCLUDED_vmm_dbgf_h) || defined(DOXYGEN_RUNNING) /* dbgf.ro.cEnabledHwBreakpoints */
     401
    398402/**
    399403 * Initializes the execution state.
     
    458462#  endif /* VBOX_STRICT */
    459463}
    460 # endif /* VBOX_INCLUDED_vmm_dbgf_h */
    461 
    462 
    463 # if defined(VBOX_WITH_NESTED_HWVIRT_SVM) || defined(VBOX_WITH_NESTED_HWVIRT_VMX)
     464
     465
     466#  if defined(VBOX_WITH_NESTED_HWVIRT_SVM) || defined(VBOX_WITH_NESTED_HWVIRT_VMX)
    464467/**
    465468 * Performs a minimal reinitialization of the execution state.
     
    477480    iemOpcodeFlushHeavy(pVCpu, cbInstr);
    478481}
    479 # endif
    480 
     482#  endif
     483
     484# endif /* VBOX_INCLUDED_vmm_dbgf_h || DOXYGEN_RUNNING */
    481485
    482486/**
     
    35643568
    35653569
     3570# ifdef XAPIC_OFF_END /* Requires VBox/apic.h to be included before IEMInline.h. */
    35663571/**
    35673572 * Sets virtual-APIC write emulation as pending.
     
    35883593        VMCPU_FF_SET(pVCpu, VMCPU_FF_VMX_APIC_WRITE);
    35893594}
     3595# endif /* XAPIC_OFF_END */
    35903596
    35913597#endif /* VBOX_WITH_NESTED_HWVIRT_VMX */
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r101111 r101163  
    742742AssertCompile(!(IEM_F_MODE_X86_64BIT              & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
    743743
     744/** Native instruction type for use with the native code generator.
     745 * This is a byte (uint8_t) for x86 and amd64 and uint32_t for the other(s). */
     746#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     747typedef uint8_t IEMNATIVEINSTR;
     748#else
     749typedef uint32_t IEMNATIVEINSTR;
     750#endif
     751/** Pointer to a native instruction unit. */
     752typedef IEMNATIVEINSTR *PIEMNATIVEINSTR;
     753
    744754/**
    745755 * A call for the threaded call table.
     
    826836        struct
    827837        {
    828             uint8_t            *pbCode;
    829             /** Amount of code that pbCode points to. */
    830             uint32_t            cbAllocated;
     838            /** The native instructions. */
     839            PIEMNATIVEINSTR     paInstructions;
     840            /** Number of instructions pointed to by paInstructions. */
     841            uint32_t            cInstructions;
    831842        } Native;
    832843        /** Generic view for zeroing when freeing. */
     
    974985    /** Statistics: Time spend pruning. */
    975986    STAMPROFILE     StatPrune;
     987
     988    /** The delayed free list (see iemTbAlloctorScheduleForFree). */
     989    PIEMTB          pDelayedFreeHead;
    976990
    977991    /** Allocation chunks. */
     
    13681382     * This is allocated once with maxed-out sizes and re-used afterwards. */
    13691383    R3PTRTYPE(PIEMTB)       pThrdCompileTbR3;
    1370     /** Fixed TB used for native recompilation.
    1371      * This is allocated once and re-used afterwards, growing individual
    1372      * components as needed. */
    1373     R3PTRTYPE(PIEMTB)       pNativeCompileTbR3;
    13741384    /** Pointer to the ring-3 TB cache for this EMT. */
    13751385    R3PTRTYPE(PIEMTBCACHE)  pTbCacheR3;
     
    13781388     * RIP to opcode bytes stored in the TB (AMD-V / VT-x). */
    13791389    uint64_t                uCurTbStartPc;
    1380     /** Number of TBs executed. */
    1381     uint64_t                cTbExec;
     1390    /** Number of threaded TBs executed. */
     1391    uint64_t                cTbExecThreaded;
     1392    /** Number of native TBs executed. */
     1393    uint64_t                cTbExecNative;
    13821394    /** Whether we need to check the opcode bytes for the current instruction.
    13831395     * This is set by a previous instruction if it modified memory or similar.  */
     
    14141426    /** Pointer to the ring-3 TB allocator for this EMT. */
    14151427    R3PTRTYPE(PIEMTBALLOCATOR) pTbAllocatorR3;
    1416     /* Alignment. */
    1417     uint64_t                auAlignment10[7];
     1428    /** Pointer to the ring-3 executable memory allocator for this EMT. */
     1429    R3PTRTYPE(struct IEMEXECMEMALLOCATOR *) pExecMemAllocatorR3;
     1430
     1431    /** Native recompiler state for ring-3. */
     1432    struct IEMRECOMPILERSTATE
     1433    {
     1434        /** Size of the buffer that pbNativeRecompileBufR3 points to in
     1435         * IEMNATIVEINSTR units. */
     1436        uint32_t                            cInstrBufAlloc;
     1437        uint32_t                            uPadding; /* We don't keep track of this here... */
     1438        /** Fixed temporary code buffer for native recompilation. */
     1439        R3PTRTYPE(PIEMNATIVEINSTR)          pInstrBuf;
     1440
     1441        /** Actual number of labels in paLabels. */
     1442        uint32_t                            cLabels;
     1443        /** Max number of entries allowed in paLabels before reallocating it. */
     1444        uint32_t                            cLabelsAlloc;
     1445        /** Labels defined while recompiling (referenced by fixups). */
     1446        R3PTRTYPE(struct IEMNATIVELABEL *)  paLabels;
     1447
     1448        /** Actual number of fixups paFixups. */
     1449        uint32_t                            cFixups;
     1450        /** Max number of entries allowed in paFixups before reallocating it. */
     1451        uint32_t                            cFixupsAlloc;
     1452        /** Buffer used by the recompiler for recording fixups when generating code. */
     1453        R3PTRTYPE(struct IEMNATIVEFIXUP *)  paFixups;
     1454    } Native;
     1455
     1456//    /* Alignment. */
     1457//    uint64_t                auAlignment10[1];
    14181458    /** Statistics: Times TB execution was broken off before reaching the end. */
    14191459    STAMCOUNTER             StatTbExecBreaks;
     
    14301470    /** Threaded TB statistics: Number of calls per TB. */
    14311471    STAMPROFILE             StatTbThreadedCalls;
     1472    /** Native TB statistics: Native code size per TB. */
     1473    STAMPROFILE             StatTbNativeCode;
     1474    /** Native TB statistics: Profiling native recompilation. */
     1475    STAMPROFILE             StatNativeRecompilation;
    14321476    /** @} */
    14331477
     
    52905334extern const PFNIEMOP g_apfnIemThreadedRecompilerVecMap3[1024];
    52915335
    5292 DECLCALLBACK(int) iemTbInit(PVMCC pVM, uint32_t cInitialTbs, uint32_t cMaxTbs);
    5293 void            iemThreadedTbObsolete(PVMCPUCC pVCpu, PIEMTB pTb);
     5336DECLCALLBACK(int)   iemTbInit(PVMCC pVM, uint32_t cInitialTbs, uint32_t cMaxTbs,
     5337                              uint64_t cbInitialExec, uint64_t cbMaxExec, uint32_t cbChunkExec);
     5338void                iemThreadedTbObsolete(PVMCPUCC pVCpu, PIEMTB pTb, bool fSafeToFree);
     5339void                iemTbAllocatorProcessDelayedFrees(PVMCPU pVCpu, PIEMTBALLOCATOR pTbAllocator);
     5340
    52945341
    52955342/** @todo FNIEMTHREADEDFUNC and friends may need more work... */
     
    53485395bool iemThreadedCompileBeginEmitCallsComplications(PVMCPUCC pVCpu, PIEMTB pTb);
    53495396
     5397/* Native recompiler public bits: */
     5398PIEMTB iemNativeRecompile(PVMCPUCC pVCpu, PIEMTB pTb);
     5399int    iemExecMemAllocatorInit(PVMCPU pVCpu, uint64_t cbMax, uint64_t cbInitial, uint32_t cbChunk);
     5400void   iemExecMemAllocatorFree(PVMCPU pVCpu, void *pv, size_t cb);
     5401
    53505402
    53515403/** @} */
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