VirtualBox

Changeset 60741 in vbox


Ignore:
Timestamp:
Apr 28, 2016 1:22:07 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
106932
Message:

VMM/APIC: Eliminate multiplication with shift when possible.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/APICAll.cpp

    r60740 r60741  
    414414 * @param   rcNotFound      What to return when no bit is set.
    415415 */
    416 static int apicGetLastSetBit(volatile const XAPIC256BITREG *pReg, int rcNotFound)
    417 {
    418     unsigned const cBitsPerFragment = sizeof(pReg->u[0].u32Reg) * 8;
    419     ssize_t const  cFragments       = RT_ELEMENTS(pReg->u);
     416static int apicGetHighestSetBit(volatile const XAPIC256BITREG *pReg, int rcNotFound)
     417{
     418    ssize_t const  cFragments     = RT_ELEMENTS(pReg->u);
     419    unsigned const uFragmentShift = 5;
     420    AssertCompile(1 << uFragmentShift == sizeof(pReg->u[0].u32Reg) * 8);
    420421    for (ssize_t i = cFragments - 1; i >= 0; i--)
    421422    {
     
    425426            unsigned idxSetBit = ASMBitLastSetU32(uFragment);
    426427            --idxSetBit;
    427             idxSetBit += (i * cBitsPerFragment);
     428            idxSetBit |= i << uFragmentShift;
    428429            return idxSetBit;
    429430        }
     
    504505    if (pXApicPage->svr.u.fApicSoftwareEnable)
    505506    {
    506         int const irrv = apicGetLastSetBit(&pXApicPage->irr, -1 /* rcNotFound */);
     507        int const irrv = apicGetHighestSetBit(&pXApicPage->irr, -1 /* rcNotFound */);
    507508        if (irrv >= 0)
    508509        {
     
    10811082    /* See Intel spec 10.8.3.1 "Task and Processor Priorities". */
    10821083    PXAPICPAGE    pXApicPage = VMCPU_TO_XAPICPAGE(pVCpu);
    1083     uint8_t const uIsrv      = apicGetLastSetBit(&pXApicPage->isr, 0 /* rcNotFound */);
     1084    uint8_t const uIsrv      = apicGetHighestSetBit(&pXApicPage->isr, 0 /* rcNotFound */);
    10841085    uint8_t       uPpr;
    10851086    if (XAPIC_TPR_GET_TP(pXApicPage->tpr.u8Tpr) >= XAPIC_PPR_GET_PP(uIsrv))
     
    11571158
    11581159    PXAPICPAGE pXApicPage = VMCPU_TO_XAPICPAGE(pVCpu);
    1159     int isrv = apicGetLastSetBit(&pXApicPage->isr, -1 /* rcNotFound */);
     1160    int isrv = apicGetHighestSetBit(&pXApicPage->isr, -1 /* rcNotFound */);
    11601161    if (isrv >= 0)
    11611162    {
     
    21072108{
    21082109    PCXAPICPAGE pXApicPage = VMCPU_TO_CXAPICPAGE(pVCpu);
    2109     int const irrv = apicGetLastSetBit(&pXApicPage->irr, -1);
     2110    int const irrv = apicGetHighestSetBit(&pXApicPage->irr, -1);
    21102111    if (irrv >= 0)
    21112112    {
     
    23152316        && pXApicPage->svr.u.fApicSoftwareEnable)
    23162317    {
    2317         int const irrv = apicGetLastSetBit(&pXApicPage->irr, -1);
     2318        int const irrv = apicGetHighestSetBit(&pXApicPage->irr, -1);
    23182319        if (RT_LIKELY(irrv >= 0))
    23192320        {
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