Improving the performance of OpenJDK

Andrew Haley aph at redhat.com
Wed Feb 18 03:19:15 PST 2009


Gary Benson wrote:
> Andrew Haley wrote:
>> Gary Benson wrote:
>>> Edward Nevill wrote:
>>>> get_native_u2() and get_Java_u2() ... This seems to be a
>>>> misguided attempt of the original authors to optimised reading
>>>> of halfwords (judging by the comment immediate preceding the
>>>> code).
>>> It's not an optimization, it's to do unaligned access on hardware
>>> that doesn't support it.  I'm guessing ARM does allow unaligned
>>> access by the fact that your code didn't segfault instantly ;)
>> ARM doesn't support unaligned loads.  The new ARM code as posted is
>>
>> 	ldrsb	r0, [java_pc, #0]
>> 	ldrb	r1, [java_pc, #1]
>> 	orr	r1, r1, r0, lsl #8
>>
>> i.e two byte loads.
> 
> Ah, I didn't realise.  Which is good, it means this optimization is
> generic :)

Right.  The whole idea of the way it's don ATM is bonkers: do a byte-
at-a-time unaligned load into machine order, then reverse the bytes.
Maybe the hope was that the compiler would see all this cruft and
silently convert it into an efficient form, but, er, no.  :-(

Andrew.



More information about the zero-dev mailing list