VirtualBox

Changeset 1614 in vbox


Ignore:
Timestamp:
Mar 21, 2007 8:42:28 PM (18 years ago)
Author:
vboxsync
Message:

some profiling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/recompiler/new/VBoxRecompiler.c

    r1613 r1614  
    8787static DECLCALLBACK(int) remR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
    8888static void     remR3StateUpdate(PVM pVM);
     89
     90#ifdef PGM_DYNAMIC_RAM_ALLOC
     91DECLINLINE(target_ulong) remR3HCVirt2GCPhysInlined(PVM pVM, void *addr);
     92DECLINLINE(void *) remR3GCPhys2HCVirtInlined(PVM pVM, target_ulong addr);
     93#endif
     94
    8995static uint32_t remR3MMIOReadU8(void *pvVM, target_phys_addr_t GCPhys);
    9096static uint32_t remR3MMIOReadU16(void *pvVM, target_phys_addr_t GCPhys);
     
    117123static STAMPROFILEADV gStatRawCheck;
    118124static STAMPROFILEADV gStatMemRead;
     125static STAMPROFILEADV gStatMemWrite;
     126#ifndef REM_PHYS_ADDR_IN_TLB
    119127static STAMPROFILEADV gStatMemReadHCPtr;
    120 static STAMPROFILEADV gStatMemWrite;
    121128static STAMPROFILEADV gStatMemWriteHCPtr;
     129#endif
     130#ifdef PGM_DYNAMIC_RAM_ALLOC
     131static STAMPROFILE    gStatGCPhys2HCVirt;
     132static STAMPROFILE    gStatHCVirt2GCPhys;
     133#endif
    122134static STAMCOUNTER    gStatRefuseTFInhibit;
    123135static STAMCOUNTER    gStatRefuseVM86;
     
    301313    pVM->rem.s.u32PendingInterrupt = REM_NO_PENDING_IRQ;
    302314
    303 #ifdef DEBUG_bird
    304     //cpu_breakpoint_insert(&pVM->rem.s.Env, some-address);
    305 #endif
    306 
    307315    /*
    308316     * Register ram types.
     
    352360    STAM_REG(pVM, &gStatRawCheck,           STAMTYPE_PROFILE, "/PROF/REM/RawCheck",   STAMUNIT_TICKS_PER_CALL, "Profiling timer scheduling.");
    353361    STAM_REG(pVM, &gStatMemRead,            STAMTYPE_PROFILE, "/PROF/REM/MemRead",    STAMUNIT_TICKS_PER_CALL, "Profiling memory access.");
     362    STAM_REG(pVM, &gStatMemWrite,           STAMTYPE_PROFILE, "/PROF/REM/MemWrite",   STAMUNIT_TICKS_PER_CALL, "Profiling memory access.");
     363#ifndef REM_PHYS_ADDR_IN_TLB
    354364    STAM_REG(pVM, &gStatMemReadHCPtr,       STAMTYPE_PROFILE, "/PROF/REM/MemReadHCPtr", STAMUNIT_TICKS_PER_CALL, "Profiling memory access.");
    355     STAM_REG(pVM, &gStatMemWrite,           STAMTYPE_PROFILE, "/PROF/REM/MemWrite",   STAMUNIT_TICKS_PER_CALL, "Profiling memory access.");
    356365    STAM_REG(pVM, &gStatMemWriteHCPtr,      STAMTYPE_PROFILE, "/PROF/REM/MemWriteHCPtr", STAMUNIT_TICKS_PER_CALL, "Profiling memory access.");
     366#endif
     367#ifdef PGM_DYNAMIC_RAM_ALLOC
     368    STAM_REG(pVM, &gStatHCVirt2GCPhys,      STAMTYPE_PROFILE, "/PROF/REM/HCVirt2GCPhys", STAMUNIT_TICKS_PER_CALL, "Profiling memory convertion.");
     369    STAM_REG(pVM, &gStatGCPhys2HCVirt,      STAMTYPE_PROFILE, "/PROF/REM/GCPhys2HCVirt", STAMUNIT_TICKS_PER_CALL, "Profiling memory convertion.");
     370#endif
    357371
    358372    STAM_REG(pVM, &gStatRefuseTFInhibit,    STAMTYPE_COUNTER, "/REM/Refuse/TFInibit", STAMUNIT_OCCURENCES,     "Raw mode refused because of TF or irq inhibit");
     
    834848         * right way in will cause serious trouble if a longjmp was attempted.)
    835849         */
    836         #ifdef DEBUG_bird
     850# ifdef DEBUG_bird
    837851        remR3DisasInstr(&pVM->rem.s.Env, 1, "REMR3EmulateInstruction");
    838         #endif
     852# endif
    839853        int cTimesMax = 16384;
    840854        uint32_t eip = pVM->rem.s.Env.eip;
     
    14001414            phys_addr = virt_addr + addend;
    14011415# elif defined(PGM_DYNAMIC_RAM_ALLOC)
    1402             phys_addr = remR3HCVirt2GCPhys(env, (void *)(virt_addr + addend));
     1416            phys_addr = remR3HCVirt2GCPhysInlined(env->pVM, (void *)(virt_addr + addend));
    14031417# else
    14041418            phys_addr = virt_addr - (uintptr_t)phys_ram_base + addend;
     
    26662680#ifdef PGM_DYNAMIC_RAM_ALLOC
    26672681# ifndef REM_PHYS_ADDR_IN_TLB
     2682#if 0
     2683static const uint8_t gabZeroPage[PAGE_SIZE];
     2684#endif
     2685
    26682686/**
    26692687 *  Convert GC physical address to HC virt
     
    26732691 * @param   addr        The physical address.
    26742692 */
    2675 void *remR3GCPhys2HCVirt(void *env, target_ulong addr)
    2676 {
    2677     PVM      pVM = ((CPUState *)env)->pVM;
     2693DECLINLINE(void *) remR3GCPhys2HCVirtInlined(PVM pVM, target_ulong addr)
     2694{
    26782695    uint32_t i;
    2679 
     2696    void    *pv;
     2697    STAM_PROFILE_START(&gStatGCPhys2HCVirt, a);
     2698
     2699#if 1
    26802700    /* lookup in pVM->rem.s.aPhysReg array first (for ROM range(s) inside the guest's RAM) */
    26812701    for (i = 0; i < pVM->rem.s.cPhysRegistrations; i++)
    26822702    {
    2683         uint32_t off = addr - pVM->rem.s.aPhysReg[i].GCPhys;
     2703        RTGCPHYS off = addr - pVM->rem.s.aPhysReg[i].GCPhys;
    26842704        if (off < pVM->rem.s.aPhysReg[i].cb)
    26852705        {
    2686             Log(("remR3GCPhys2HCVirt: %x -> %x\n", addr, pVM->rem.s.aPhysReg[i].HCVirt + off));
    2687             return (void *)(pVM->rem.s.aPhysReg[i].HCVirt + off);
     2706            pv = (void *)(pVM->rem.s.aPhysReg[i].HCVirt + off);
     2707            Log(("remR3GCPhys2HCVirt: %x -> %x\n", addr, pv));
     2708            STAM_PROFILE_STOP(&gStatGCPhys2HCVirt, a);
     2709            return pv;
    26882710        }
    26892711    }
    26902712    AssertMsg(addr < phys_ram_size, ("remR3GCPhys2HCVirt: unknown physical address %x\n", addr));
    2691     Log(("remR3GCPhys2HCVirt: %x -> %x\n", addr, pVM->rem.s.paGCPhysToHCVirt[addr >> PGM_DYNAMIC_CHUNK_SHIFT] + (addr & PGM_DYNAMIC_CHUNK_OFFSET_MASK)));
    2692     return (void *)(pVM->rem.s.paGCPhysToHCVirt[addr >> PGM_DYNAMIC_CHUNK_SHIFT] + (addr & PGM_DYNAMIC_CHUNK_OFFSET_MASK));
     2713    pv = (void *)(pVM->rem.s.paGCPhysToHCVirt[addr >> PGM_DYNAMIC_CHUNK_SHIFT] + (addr & PGM_DYNAMIC_CHUNK_OFFSET_MASK));
     2714    Log(("remR3GCPhys2HCVirt: %x -> %x\n", addr, pv));
     2715#else
     2716    /** @todo figure out why this is faster than the above code. */
     2717    int rc = PGMPhysGCPhys2HCPtr(pVM, addr & X86_PTE_PAE_PG_MASK, PAGE_SIZE, &pv);
     2718    if (RT_FAILURE(rc))
     2719    {
     2720        AssertMsgFailed(("remR3GCPhys2HCVirt: unknown physical address %x\n", addr));
     2721        pv = gabZeroPage;
     2722    }
     2723    pv = (void *)((uintptr_t)pv | (addr & PAGE_OFFSET_MASK));
     2724#endif
     2725    return pv;
    26932726}
    26942727
     
    27012734 * @param   addr        The physical address.
    27022735 */
    2703 target_ulong remR3HCVirt2GCPhys(void *env, void *addr)
    2704 {
    2705     PVM         pVM    = ((CPUState *)env)->pVM;
     2736DECLINLINE(target_ulong) remR3HCVirt2GCPhysInlined(PVM pVM, void *addr)
     2737{
    27062738    RTHCUINTPTR HCVirt = (RTHCUINTPTR)addr;
    27072739    uint32_t    idx    = (HCVirt >> PGM_DYNAMIC_CHUNK_SHIFT);
    27082740    RTHCUINTPTR off;
    27092741    RTUINT      i;
     2742    target_ulong GCPhys;
    27102743
    27112744    off = HCVirt - pVM->rem.s.paHCVirtToGCPhys[idx].pChunk1;
     
    27142747        &&  off < PGM_DYNAMIC_CHUNK_SIZE)
    27152748    {
    2716         Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys1 + off));
    2717         return pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys1 + off;
     2749        GCPhys = pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys1 + off;
     2750        Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, GCPhys));
     2751        return GCPhys;
    27182752    }
    27192753
     
    27222756        &&  off < PGM_DYNAMIC_CHUNK_SIZE)
    27232757    {
    2724         Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys2 + off));
    2725         return pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys2 + off;
     2758        GCPhys = pVM->rem.s.paHCVirtToGCPhys[idx].GCPhys2 + off;
     2759        Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, GCPhys));
     2760        return GCPhys;
    27262761    }
    27272762
     
    27322767        if (off < pVM->rem.s.aPhysReg[i].cb)
    27332768        {
    2734             Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, pVM->rem.s.aPhysReg[i].GCPhys + off));
    2735             return pVM->rem.s.aPhysReg[i].GCPhys + off;
     2769            GCPhys = pVM->rem.s.aPhysReg[i].GCPhys + off;
     2770            Log2(("remR3HCVirt2GCPhys %x -> %x\n", addr, GCPhys));
     2771            return GCPhys;
    27362772        }
    27372773    }
     
    27392775    return 0;
    27402776}
     2777
     2778/**
     2779 *  Convert GC physical address to HC virt
     2780 *
     2781 * @returns The HC virt address corresponding to addr.
     2782 * @param   env         The cpu environment.
     2783 * @param   addr        The physical address.
     2784 */
     2785void *remR3GCPhys2HCVirt(void *env, target_ulong addr)
     2786{
     2787    PVM     pVM = ((CPUState *)env)->pVM;
     2788    void   *pv;
     2789    STAM_PROFILE_START(&gStatGCPhys2HCVirt, a);
     2790    pv = remR3GCPhys2HCVirtInlined(pVM, addr);
     2791    STAM_PROFILE_STOP(&gStatGCPhys2HCVirt, a);
     2792    return pv;
     2793}
     2794
     2795
     2796/**
     2797 *  Convert GC physical address to HC virt
     2798 *
     2799 * @returns The HC virt address corresponding to addr.
     2800 * @param   env         The cpu environment.
     2801 * @param   addr        The physical address.
     2802 */
     2803target_ulong remR3HCVirt2GCPhys(void *env, void *addr)
     2804{
     2805    PVM pVM = ((CPUState *)env)->pVM;
     2806    target_ulong GCPhys;
     2807    STAM_PROFILE_START(&gStatHCVirt2GCPhys, a);
     2808    GCPhys = remR3HCVirt2GCPhysInlined(pVM, addr);
     2809    STAM_PROFILE_STOP(&gStatHCVirt2GCPhys, a);
     2810    return GCPhys;
     2811}
     2812
    27412813# endif /* !REM_PHYS_ADDR_IN_TLB */
    27422814
     
    29363008            cpu_register_physical_memory(GCPhys, cb, GCPhys);
    29373009#elif defined(PGM_DYNAMIC_RAM_ALLOC)
    2938             Assert(remR3HCVirt2GCPhys(cpu_single_env, pvHCPtr) < MMR3PhysGetRamSize(pVM));
     3010            Assert(remR3HCVirt2GCPhysInlined(pVM, pvHCPtr) < MMR3PhysGetRamSize(pVM));
    29393011            cpu_register_physical_memory(GCPhys, cb, GCPhys);
    29403012#else
     
    29893061            cpu_register_physical_memory(GCPhysOld, cb, GCPhysOld);
    29903062#elif defined(PGM_DYNAMIC_RAM_ALLOC)
    2991             Assert(remR3HCVirt2GCPhys(cpu_single_env, pvHCPtr) < MMR3PhysGetRamSize(pVM));
     3063            Assert(remR3HCVirt2GCPhysInlined(pVM, pvHCPtr) < MMR3PhysGetRamSize(pVM));
    29923064            cpu_register_physical_memory(GCPhysOld, cb, GCPhysOld);
    29933065#else
     
    32213293    VBOX_CHECK_ADDR(DstGCPhys);
    32223294    PGMPhysWrite(cpu_single_env->pVM, DstGCPhys, pvSrc, cb);
    3223     STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);
     3295    STAM_PROFILE_ADV_STOP(&gStatMemWrite, a);
    32243296}
    32253297
     
    32333305void remR3PhysWriteU8(RTGCPHYS DstGCPhys, uint8_t val)
    32343306{
    3235     STAM_PROFILE_ADV_START(&gStatMemWriteHCPtr, a);
     3307    STAM_PROFILE_ADV_START(&gStatMemWrite, a);
    32363308    VBOX_CHECK_ADDR(DstGCPhys);
    32373309    PGMR3PhysWriteByte(cpu_single_env->pVM, DstGCPhys, val);
    3238     STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);
     3310    STAM_PROFILE_ADV_STOP(&gStatMemWrite, a);
    32393311}
    32403312
     
    32483320void remR3PhysWriteU16(RTGCPHYS DstGCPhys, uint16_t val)
    32493321{
    3250     STAM_PROFILE_ADV_START(&gStatMemWriteHCPtr, a);
     3322    STAM_PROFILE_ADV_START(&gStatMemWrite, a);
    32513323    VBOX_CHECK_ADDR(DstGCPhys);
    32523324    PGMR3PhysWriteWord(cpu_single_env->pVM, DstGCPhys, val);
    3253     STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);
     3325    STAM_PROFILE_ADV_STOP(&gStatMemWrite, a);
    32543326}
    32553327
     
    32633335void remR3PhysWriteU32(RTGCPHYS DstGCPhys, uint32_t val)
    32643336{
    3265     STAM_PROFILE_ADV_START(&gStatMemWriteHCPtr, a);
     3337    STAM_PROFILE_ADV_START(&gStatMemWrite, a);
    32663338    VBOX_CHECK_ADDR(DstGCPhys);
    32673339    PGMR3PhysWriteDword(cpu_single_env->pVM, DstGCPhys, val);
    3268     STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);
     3340    STAM_PROFILE_ADV_STOP(&gStatMemWrite, a);
    32693341}
    32703342
     
    32783350void remR3PhysWriteU64(RTGCPHYS DstGCPhys, uint64_t val)
    32793351{
    3280     STAM_PROFILE_ADV_START(&gStatMemWriteHCPtr, a);
     3352    STAM_PROFILE_ADV_START(&gStatMemWrite, a);
    32813353    VBOX_CHECK_ADDR(DstGCPhys);
    32823354    PGMR3PhysWriteDword(cpu_single_env->pVM, DstGCPhys, (uint32_t)val); /** @todo add U64 interface. */
    32833355    PGMR3PhysWriteDword(cpu_single_env->pVM, DstGCPhys + 4, val >> 32);
    3284     STAM_PROFILE_ADV_STOP(&gStatMemWriteHCPtr, a);
     3356    STAM_PROFILE_ADV_STOP(&gStatMemWrite, a);
    32853357}
    32863358
     
    33053377    /** @todo This is rather ugly, but there's no other way when we don't wish to touch *many* other files. */
    33063378#ifdef PGM_DYNAMIC_RAM_ALLOC
    3307     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbSrcPhys);
     3379    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);
    33083380#else
    33093381    uintptr_t off = pbSrcPhys - phys_ram_base;
     
    33373409     */
    33383410#ifdef PGM_DYNAMIC_RAM_ALLOC
    3339     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbSrcPhys);
     3411    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);
    33403412#else
    33413413    uintptr_t off = pbSrcPhys - phys_ram_base;
     
    33703442     */
    33713443#ifdef PGM_DYNAMIC_RAM_ALLOC
    3372     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbSrcPhys);
     3444    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);
    33733445#else
    33743446    uintptr_t off = pbSrcPhys - phys_ram_base;
     
    34033475     */
    34043476#ifdef PGM_DYNAMIC_RAM_ALLOC
    3405     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbSrcPhys);
     3477    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);
    34063478#else
    34073479    uintptr_t off = pbSrcPhys - phys_ram_base;
     
    34373509    /** @todo This is rather ugly, but there's no other way when we don't wish to touch *many* other files. */
    34383510#ifdef PGM_DYNAMIC_RAM_ALLOC
    3439     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbSrcPhys);
     3511    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);
    34403512#else
    34413513    uintptr_t off = pbSrcPhys - phys_ram_base;
     
    34703542     */
    34713543#ifdef PGM_DYNAMIC_RAM_ALLOC
    3472     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbSrcPhys);
     3544    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);
    34733545#else
    34743546    uintptr_t off = pbSrcPhys - phys_ram_base;
     
    35033575     */
    35043576#ifdef PGM_DYNAMIC_RAM_ALLOC
    3505     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbSrcPhys);
     3577    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);
    35063578#else
    35073579    uintptr_t off = pbSrcPhys - phys_ram_base;
     
    35363608     */
    35373609#ifdef PGM_DYNAMIC_RAM_ALLOC
    3538     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbSrcPhys);
     3610    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbSrcPhys);
    35393611#else
    35403612    uintptr_t off = pbSrcPhys - phys_ram_base;
     
    35683640     */
    35693641#ifdef PGM_DYNAMIC_RAM_ALLOC
    3570     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbDstPhys);
     3642    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys);
    35713643#else
    35723644    uintptr_t off = pbDstPhys - phys_ram_base;
     
    35933665     */
    35943666#ifdef PGM_DYNAMIC_RAM_ALLOC
    3595     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbDstPhys);
     3667    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys);
    35963668#else
    35973669    uintptr_t off = pbDstPhys - phys_ram_base;
     
    36183690     */
    36193691#ifdef PGM_DYNAMIC_RAM_ALLOC
    3620     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbDstPhys);
     3692    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys);
    36213693#else
    36223694    uintptr_t off = pbDstPhys - phys_ram_base;
     
    36433715     */
    36443716#ifdef PGM_DYNAMIC_RAM_ALLOC
    3645     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbDstPhys);
     3717    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys);
    36463718#else
    36473719    uintptr_t off = pbDstPhys - phys_ram_base;
     
    36683740     */
    36693741#ifdef PGM_DYNAMIC_RAM_ALLOC
    3670     uintptr_t off = remR3HCVirt2GCPhys(cpu_single_env, pbDstPhys);
     3742    uintptr_t off = remR3HCVirt2GCPhysInlined(cpu_single_env->pVM, pbDstPhys);
    36713743#else
    36723744    uintptr_t off = pbDstPhys - phys_ram_base;
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