Preview: Concurrent JNIWeakHandles processing

Stefan Karlsson stefan.karlsson at
Wed Jan 24 12:45:59 UTC 2018

We need to turn off the global verification of JNIHandles::weak_oops_do, 
in JNIHandles::verify. Otherwise,  we end up verifying oops* that have 
not been fixed yet.

The following is an ugly workaround, and we probably want to overhaul 
the verification and move the responsibility to verify the roots to the 

diff --git a/src/hotspot/share/runtime/jniHandles.cpp 
--- a/src/hotspot/share/runtime/jniHandles.cpp
+++ b/src/hotspot/share/runtime/jniHandles.cpp
@@ -314,7 +314,9 @@
    VerifyJNIHandles verify_handle;

-  weak_oops_do(&verify_handle);
+  if (!UseZGC) {
+    weak_oops_do(&verify_handle);
+  }

  // This method is implemented here to avoid circular includes between


On 2018-01-24 11:16, Per Liden wrote:
> First of all, just want to mention that this patch is kind a major 
> milestone. With the recent introduction of OopStorage, we now have 
> enough infrastructure in place upstream to start moving the cleaning of 
> VM weak roots out from STW and in to a concurrent phase. The JNI weak 
> handles is the first step, StringTable is being worked on and will 
> follow later.
> In plain English, this means that an application can create as many 
> JNIWeakGlobalRefs as is wants to without affecting GC pause times.
> About the patch. Stefan and I discussed some minor cleanups, which I'll 
> push as a follow up to his patch. Here that are:
> cheers,
> Per
> On 01/22/2018 08:29 PM, Stefan Karlsson wrote:
>> I fixed the copyright header for the two new files, and fixed the 
>> incorrect usage of Atomic::cmpxchg.
>> StefanK
>> On 2018-01-19 16:21, Stefan Karlsson wrote:
>>> Hi all,
>>> Kim recently pushed a patch to jdk/hs, which contains the new 
>>> OopStorage class. This class is a container for oops, and helps 
>>> separating GC scanning/clearing from Runtime data structure 
>>> cleaning/unlinking. The OopStorage also provides the functionallity 
>>> to scan/clear the oop*s concurrently.
>>> The container of the JNIWeakHandles has been changed to the 
>>> OopStorage, but the clearing is currently done during pauses. The 
>>> following patch adds concurrent clearing to ZGC. The patch moves the 
>>> clearing out from the "mark end" pause into the "concurrent weak 
>>> processing" phase after mark end.
>>> I want to do further testing before this gets pushed, but here's the 
>>> current patch:
>>> Thanks,
>>> StefanK

More information about the zgc-dev mailing list