RFR: JDK-8199620: Support for JNI object pinning (original) (raw)

Roman Kennke rkennke at redhat.com
Thu Mar 15 13:13:24 UTC 2018


Am 15.03.2018 um 13:50 schrieb Per Liden:

Hi Roman,

On 03/14/2018 07:51 PM, Roman Kennke wrote: Am 14.03.2018 um 19:13 schrieb Roman Kennke:

Currently, the Get/Release*Critical() family of functions use the GCLocker protocol to ensure that no JNI critical arrays are in use when a GC pause is entered.

Some GCs may instead want to use object pinning and guarantee that the object does not move. For example, this is easy to do with region-based GCs (G1, Shenandoah, ZGC) by simply not including regions with pinned objects in the collection set. The implementation/API that I'm proposing is fairly simple: add two methods oop pinobject(oop) and void unpinobject(oop) to CollectedHeap, and call them from JNI's Get/Release*Critical methods. This approach has been working perfectly fine since a long time in Shenandoah. Bug: https://bugs.openjdk.java.net/browse/JDK-8199620 Webrev: http://cr.openjdk.java.net/~rkennke/8199620/webrev.00/ And here is the correct patch: http://cr.openjdk.java.net/~rkennke/8199620/webrev.01/ It seems your patch both grabs the GCLocker and pins the object? I would have assumed that the default implementation of pinobjct() would be the one calling the GCLocker if pinning isn't supported by the GC.

As I explained to Derek, this is kindof intentional. Calling into GCLocker::lock_critical() and GCLocker::unlock_critical() does nothing in the way of waiting or blocking or otherwise harmful, as long as the GC does not participate in the protocol. This way a GC could infact use both mechanisms, e.g. using pinning and ignore GCLocker for the pauses around concurrent phases, and ignore pinning and use GCLocker for full-GC pauses.

Also, it seems that this patch doesn't take "critical native" functions into account, i.e. those special functions which grabs the GCLocker "lazily" when a safepoint happens. See SafepointSynchronize::checkforlazycriticalnative().

I am not sure that I'd have to do anything there? What's this supposed to do? Prevent to reach a GC safepoint as long as such a function is in progress? With what purpose? Can you give me an example?

Thanks, Roman

-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: <https://mail.openjdk.org/pipermail/hotspot-gc-dev/attachments/20180315/637c0262/signature.asc>



More information about the hotspot-gc-dev mailing list