[Webkit-unassigned] [Bug 214142] [WTF] Fix PackedAlignedPtr for X86_64 canonical addresses

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jul 15 01:34:11 PDT 2020


https://bugs.webkit.org/show_bug.cgi?id=214142

--- Comment #40 from Jim Mason <jmason at ibinx.com> ---
(In reply to Mark Lam from comment #39)
> FWIW, after thinking about this some more, I think you can implement a fast
> version of this:
>     unsigned shiftBits = countOfBits<uintptr_t> -
> OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH);
>     value = (bitwise_cast<intptr_t>(value) << shiftBits) >> shiftBits;
> 
> The CPU should be able to compute the shifts much faster than the masking +
> conditional branch + masking.  Plus the bytes needed to encode the shift
> instructions is probably less too.

Thanks for the suggestion, Mark.  I think you're right.  The old way generates something like this:

        btq     $47, %rax
        jnc     .L2
        movabsq $-281474976710656, %rdx
        orq     %rdx, %rax
    .L2:

while your revision generates this:

        salq    $16, %rax
        sarq    $16, %rax

I am going to apply the revision, but will first validate in my environment before committing.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200715/64c6c484/attachment-0001.htm>


More information about the webkit-unassigned mailing list