RFR: 8257189: Handle concurrent updates of MH.form better

Peter Levart plevart at openjdk.java.net
Tue Dec 1 09:36:00 UTC 2020


On Thu, 26 Nov 2020 21:23:16 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:

> Concurrent updates may lead to redundant LambdaForms created and unnecessary class loading when those are compiled. 
> 
> Most notably, it severely affects MethodHandle customization: when a MethodHandle is called from multiple threads, every thread starts customization which takes enough time for other threads to join, but only one of those customizations will be picked.
> 
> Coordination between threads requesting the updates and letting a single thread proceed avoids the aforementioned problem. Moreover, there's no need to wait until the update in-flight is over: all other threads (except the one performing the update) can just proceed with the invocation using the existing MH.form. 
> 
> Testing:
> - manually monitored the behavior on a stress test from [JDK-8252049](https://bugs.openjdk.java.net/browse/JDK-8252049)
> - tier1-4

src/java.base/share/classes/java/lang/invoke/MethodHandle.java line 1760:

> 1758: 
> 1759:     private volatile boolean updateInProgress = false;
> 1760: 

Hi (line 1759): redundant initialization of volatile field to default value is not needed or desired.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1472


More information about the hotspot-compiler-dev mailing list