On 11/09/2015 02:13 PM, Claes Redestad wrote:
>> Can we avoid shared secrets by doing the following?
>>
>> @HotSpotIntrinsicCandidate
>> public static Byte valueOf(byte b) {
>>      if (b == 0) return ZERO;
>>      final int offset = 128;
>>      return ByteCache.cache[(int)b + offset];
>> }
> 
> I considered this and would like to avoid it since it has potential to
> regress the hot path. It's quite possible it'll have no measurable
> effect on any benchmarks we have, but I'm still more comfortable with
> having somewhat sketchy code warts in initialization code that will only
> run once.

I agree with Claes here: let's not touch the valueOf hotpath.

Granted, valueOf would be intrinsified by most compilers, and that zero
check dropped, but that may lead to other slowdowns during the initial
startup when optimized code is not available yet. Plus, I am
uncomfortable with a potential desync between ByteCache.cache[0 +
offset] value and ZERO.

Thanks,
-Aleksey

Reply via email to