Request for reviews (L): 6814842: Load shortening optimizations

Ulf Zibis Ulf.Zibis at gmx.de
Fri May 8 03:29:19 PDT 2009


Much thanks for your fast answer and accepting my little error.  ;-)

Am 07.05.2009 15:55, Christian Thalinger schrieb:
> On Thu, 2009-05-07 at 15:40 +0200, Ulf Zibis wrote:
>   
>> E.g.:
>>     char decode(byte b) {
>>         return (char)(b & 0xFF);
>>     }
>>     
>
> This is handled by HotSpot for a long time.
>   

Hm, I can't share this experience.

Results from my benchmark on JDK7 b51:
<https://java-nio-charset-enhanced.dev.java.net/source/browse/java-nio-charset-enhanced/trunk/test/DecoderBenchmark.java?rev=672&view=markup>

time for (char)a: 1652 ms
time for (char)(a & 0xFF): 2772 ms

IMHO (char)(a & 0xFF) should be faster, or at least as fast as (char)a, 
because only basic LoadUB should be executed.

-Ulf







More information about the hotspot-compiler-dev mailing list