StringCoding.hasNegatives

Aleksey Shipilev shade at redhat.com
Fri Oct 1 14:53:00 UTC 2021


On 10/1/21 4:46 PM, Brett Okken wrote:
>> The current pure Java implementation does two things: it provides a fallback
>> for pure-interpreter JVMs and it provides the reader with a simple implementation.
>> I'm not at all sure we'd want a complex implementation.
> 
> I thought this might be the case.
> 
>> Having said that, if I were looking at a faster pure Java version of
>> this logic, I'd look at MethodHandles.byteArrayViewVarHandle().
> 
> I considered that, but had 2 concerns:
> 1. creating potential dependency/initialization order issues
> 2. creating/managing a constant VarHandle that would never be used
> with normal compiler behavior

Also, interpreter-only VMs are likely to be pessimized by Var/MethodHandles, as they would not be 
able to fold a lot of code (e.g. checks) on the hotpaths. I have seen this after SHA-2 was rewritten 
to use byteViews (that one was done for simplicity, rather than directly for performance, I think).

Optimizing this does not seem worth it, in my opinion. The only reason to do this would be showing 
that it improves the interpreter performance so much it improves startup until compilers are coming 
up with the optimized code.

-- 
Thanks,
-Aleksey



More information about the core-libs-dev mailing list