RFR: 8230566: ZGC: Don't substitute klass pointer during array clearing

Per Liden per.liden at oracle.com
Wed Sep 4 12:02:52 UTC 2019


When allocating large object arrays, ZObjArrayAllocator instantiates a 
non-cleared array of longs and later installs the correct klass pointer 
once the array has been cleared. While this might work it's also error 
prone. For example, there are at least two asserts() that will re-loaded 
the klass pointer and fail. It's also easy for someone in the future to 
make the innocent mistake of re-loading the klass pointer in some 
sensitive path, which would lead to new problems. We can avoid all these 
problems by not substituting with the klass pointer, and instead have 
another mechanism to tell GC marker threads to not follow the elements 
in not-yet-cleared arrays.

This patch adds a new bit to ZMarkStackEntry, to signal to marking 
threads that the object array should not be followed, just mark it as 
live and visit its klass.

The patch is large-ish because of the need to propagate the "follow" 
flag down through a few of layers. We might want to think about 
converting the flags (follow/finalizable/publish) into a single 
ZBarrierFlags-thing (perhaps similar to DecoratorSet) to reduce the 
noise and make it easier to add/adjust/remove flags in the future. But 
such an enhancements could come later.

Bug: https://bugs.openjdk.java.net/browse/JDK-8230566
Webrev: http://cr.openjdk.java.net/~pliden/8230566/webrev.0

Testing: tier1-6 on linux + ad hoc runs of tests that provoked the problem

/Per



More information about the hotspot-gc-dev mailing list