VirtualBox

Changeset 103013 in vbox


Ignore:
Timestamp:
Jan 24, 2024 12:50:12 AM (16 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
161247
Message:

iprt/asm-mem.h,zip.cpp,tstRTInlineAsm.cpp: Eliminated unused ASMMemIsZeroPage function.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm-mem.h

    r103005 r103013  
    298298
    299299
    300 #ifdef RT_ASM_PAGE_SIZE
    301 /**
    302  * Checks if a memory page is all zeros.
    303  *
    304  * @returns true / false.
    305  *
    306  * @param   pvPage      Pointer to the page.  Must be aligned on 16 byte
    307  *                      boundary
    308  */
    309 DECLINLINE(bool) ASMMemIsZeroPage(void const RT_FAR *pvPage) RT_NOTHROW_DEF
    310 {
    311 # if 0 /*RT_INLINE_ASM_GNU_STYLE - this is actually slower... */
    312     union { RTCCUINTREG r; bool f; } uAX;
    313     RTCCUINTREG xCX, xDI;
    314    Assert(!((uintptr_t)pvPage & 15));
    315     __asm__ __volatile__("repe; "
    316 #  ifdef RT_ARCH_AMD64
    317                          "scasq\n\t"
    318 #  else
    319                          "scasl\n\t"
    320 #  endif
    321                          "setnc %%al\n\t"
    322                          : "=&c" (xCX)
    323                          , "=&D" (xDI)
    324                          , "=&a" (uAX.r)
    325                          : "mr" (pvPage)
    326 #  ifdef RT_ARCH_AMD64
    327                          , "0" (RT_ASM_PAGE_SIZE/8)
    328 #  else
    329                          , "0" (RT_ASM_PAGE_SIZE/4)
    330 #  endif
    331                          , "1" (pvPage)
    332                          , "2" (0)
    333                          : "cc");
    334     return uAX.f;
    335 # else
    336    uintptr_t const RT_FAR *puPtr = (uintptr_t const RT_FAR *)pvPage;
    337    size_t                  cLeft = RT_ASM_PAGE_SIZE / sizeof(uintptr_t) / 8;
    338    Assert(!((uintptr_t)pvPage & 15));
    339    for (;;)
    340    {
    341        if (puPtr[0])        return false;
    342        if (puPtr[4])        return false;
    343 
    344        if (puPtr[2])        return false;
    345        if (puPtr[6])        return false;
    346 
    347        if (puPtr[1])        return false;
    348        if (puPtr[5])        return false;
    349 
    350        if (puPtr[3])        return false;
    351        if (puPtr[7])        return false;
    352 
    353        if (!--cLeft)
    354            return true;
    355        puPtr += 8;
    356    }
    357 # endif
    358 }
    359 #endif /* RT_ASM_PAGE_SIZE */
    360 
    361 
    362300/**
    363301 * Checks if a memory block is filled with the specified byte, returning the
  • trunk/src/VBox/Runtime/common/zip/zip.cpp

    r98103 r103013  
    17701770            if (    cbSrc == _4K
    17711771                &&  !((uintptr_t)pvSrc & 15)
    1772                 &&  ASMMemIsZeroPage(pvSrc))
     1772                &&  ASMMemIsZero(pvSrc, _4K))
    17731773            {
    17741774                if (RT_UNLIKELY(cbDst < sizeof(s_abZero4K)))
  • trunk/src/VBox/Runtime/testcase/tstRTInlineAsm.cpp

    r103005 r103013  
    23982398            if (pPage->ab[i])
    23992399                RTTestFailed(g_hTest, "ASMMemZeroPage didn't clear byte at offset %#x!\n", i);
    2400         if (ASMMemIsZeroPage(pPage) != true)
    2401             RTTestFailed(g_hTest, "ASMMemIsZeroPage returns false after ASMMemZeroPage!\n");
     2400        if (ASMMemIsZero(pPage, RT_ASM_PAGE_SIZE) != true)
     2401            RTTestFailed(g_hTest, "ASMMemIsZero/RT_ASM_PAGE_SIZE returns false after ASMMemZeroPage!\n");
    24022402        if (ASMMemFirstMismatchingU32(pPage, sizeof(pPage), 0) != NULL)
    24032403            RTTestFailed(g_hTest, "ASMMemFirstMismatchingU32(,,0) returns non-NULL after ASMMemZeroPage!\n");
     
    24102410    RTTestISub("ASMMemZeroPage");
    24112411    DO_SIMPLE_TEST_NO_SUB_NO_STACK(tstASMMemZeroPageWorker, TSTPAGE);
    2412 }
    2413 
    2414 
    2415 static void tstASMMemIsZeroPage(RTTEST hTest)
    2416 {
    2417     RTTestSub(hTest, "ASMMemIsZeroPage");
    2418 
    2419     void *pvPage1 = RTTestGuardedAllocHead(hTest, PAGE_SIZE);
    2420     void *pvPage2 = RTTestGuardedAllocTail(hTest, PAGE_SIZE);
    2421     RTTESTI_CHECK_RETV(pvPage1 && pvPage2);
    2422 
    2423     memset(pvPage1, 0, PAGE_SIZE);
    2424     memset(pvPage2, 0, PAGE_SIZE);
    2425     RTTESTI_CHECK(ASMMemIsZeroPage(pvPage1));
    2426     RTTESTI_CHECK(ASMMemIsZeroPage(pvPage2));
    2427 
    2428     memset(pvPage1, 0xff, PAGE_SIZE);
    2429     memset(pvPage2, 0xff, PAGE_SIZE);
    2430     RTTESTI_CHECK(!ASMMemIsZeroPage(pvPage1));
    2431     RTTESTI_CHECK(!ASMMemIsZeroPage(pvPage2));
    2432 
    2433     memset(pvPage1, 0, PAGE_SIZE);
    2434     memset(pvPage2, 0, PAGE_SIZE);
    2435     for (unsigned off = 0; off < PAGE_SIZE; off++)
    2436     {
    2437         ((uint8_t *)pvPage1)[off] = 1;
    2438         RTTESTI_CHECK(!ASMMemIsZeroPage(pvPage1));
    2439         ((uint8_t *)pvPage1)[off] = 0;
    2440 
    2441         ((uint8_t *)pvPage2)[off] = 0x80;
    2442         RTTESTI_CHECK(!ASMMemIsZeroPage(pvPage2));
    2443         ((uint8_t *)pvPage2)[off] = 0;
    2444     }
    2445 
    2446     RTTestSubDone(hTest);
    24472412}
    24482413
     
    33333298
    33343299    tstASMMemZeroPage();
    3335     tstASMMemIsZeroPage(g_hTest);
    33363300    tstASMMemFirstMismatchingU8(g_hTest);
    33373301    tstASMMemZero32();
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