Swap should be better done native?
Martin Buchholz
martinrb at google.com
Wed Mar 31 12:06:44 PDT 2010
On Wed, Mar 31, 2010 at 12:01, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
> Am 31.03.2010 20:40, schrieb Martin Buchholz:
>>
>> On Wed, Mar 31, 2010 at 11:23, Ulf Zibis<Ulf.Zibis at gmx.de> wrote:
>>
>>>
>>> Am 30.03.2010 20:23, schrieb Florian Weimer:
>>>
>>
>>
>>>
>>> Looking at the disassembly, I can't see any intrinsic method for swap.
>>>
>>
>> There's a hotspot intrinsic for the reverseBytes methods.
>>
>
> You mean for Integer.reverseBytes, Long.reverseBytes, but not for Bits.swap
> ?
>
> That would explain my disassembly.
>
> What's about swap(short), swap(char) ?
My understanding is that there are no "short" or "char" types at the
bytecode level.
So perhaps we can optimize by using integer-level swaps
swap(x) { return (char) Integer.swapBytes(x << 16); }
Please try benchmarking/disassembling that.
Martin
More information about the nio-discuss
mailing list