Swap should be better done native?

Martin Buchholz martinrb at google.com
Wed Mar 31 15:57:06 PDT 2010


On Wed, Mar 31, 2010 at 15:51, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
> Am 31.03.2010 23:05, schrieb Ulf Zibis:
>>
>> Am 31.03.2010 02:59, schrieb Martin Buchholz:
>>>
>>> On Tue, Mar 30, 2010 at 07:39, Ulf Zibis<Ulf.Zibis at gmx.de>  wrote:
>>>>
>>>> In java.nio.Bits, there are several swap methods.
>>>> Shouldn't this be done better by a native method, as popular CPU's IMO
>>>> would
>>>> do that faster, and HotSpot easily could inline the single instruction?
>>>
>>> http://cr.openjdk.java.net/~martin/webrevs/openjdk7/nioBits.java/
>>
>> Additionally you could inline Integer/Long.reverseBytes directly to
>> java.nio.Direct-X-Buffer.java.template and
>> java.nio.Direct-X-Buffer-bin.java.template.

We can't do that until all the primitive types have a reverseBytes method.

> Additionally you could include change for Character/Short.reverseBytes and
> patch get/putChar/Short and swap(char/short).

The patch has been updated.

Perhaps you would like to provide a patch for Character/Short.reverseBytes?

Martin


More information about the nio-discuss mailing list