RFR: JDK-8269650: Optimize gc-locker in [Get|Release]StringCritical for latin string
Kim Barrett
kbarrett at openjdk.java.net
Wed Jun 30 23:30:59 UTC 2021
On Wed, 30 Jun 2021 11:55:49 GMT, Hamlin Li <mli at openjdk.org> wrote:
> Currently, JNI GetStringCritical locks gc locker for all strings including latin and non-latin until ReleaseStringCritical.
> But for latin, it's not necessary to still lock gc locker after GetStringCritical, as it's copied anyway whether obj pining is supported or not, so it's fine to unlock gc locker after GetStringCritical.
> _Mailing list message from [David Holmes](mailto:david.holmes at oracle.com) on [hotspot-dev](mailto:hotspot-dev at mail.openjdk.java.net):_
>
> On 30/06/2021 10:35 pm, Thomas Schatzl wrote:
>
> > On Wed, 30 Jun 2021 11:55:49 GMT, Hamlin Li <mli at openjdk.org> wrote:
> > > Currently, JNI GetStringCritical locks gc locker for all strings including latin and non-latin until ReleaseStringCritical.
> > > But for latin, it's not necessary to still lock gc locker after GetStringCritical, as it's copied anyway whether obj pining is supported or not, so it's fine to unlock gc locker after GetStringCritical.
> >
> >
> > Actually I think the *String* object can be unlocked regardless of `is_latin1` or not. The code returns the *char array* that the native code is going to process after all - which is not locked *at all* but probably should be. I filed [JDK-8269661](https://bugs.openjdk.java.net/browse/JDK-8269661) for this.
>
> I admit I do not know how String objects are laid out since compact
> strings came along but IIRC before that the char* pointed to an actual
> array embedded in the String's value, and so the String (and its value
> array) had to be pinned/locked.
>
> David
I don’t see how that embedding of the char array could work (without bespoke GC support or something like Valhalla).
I also don’t see any sign of that in the code history.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4637
More information about the hotspot-dev
mailing list