Question: "backwards" adressing

Ulf Zibis Ulf.Zibis at gmx.de
Mon Aug 24 05:52:09 PDT 2009


Am 24.08.2009 14:40, Christian Thalinger schrieb:
> Ulf Zibis wrote:
>   
>> Hi Christian,
>>
>> can you give a hint, if following code from Character class is 
>> potentially slower after hotspot compile as if it would be coded 
>> "forwards" ?
>>
>>     static void toSurrogates(int codePoint, char[] dst, int index) {
>>         // We write elements "backwards" to guarantee all-or-nothing // 
>> TODO: isn't forward faster ?
>>         dst[index+1] = lowSurrogate(codePoint);
>>         dst[index] = highSurrogate(codePoint);
>>     }
>>     
>
> I don't see a reason why it should.  What would you expect the compiler
> to do when it would be coded "forwards"?
>
> -- Christian
>
>   

In case of "forwards", the compiler could create code which increments 
the index for the 2nd statement in _same CPU register_, whitout 
remembering the original value of index in a different place.

-Ulf





More information about the hotspot-compiler-dev mailing list