8199462: Use Reference.reachabilityFence in direct ByteBuffer methods

Reviewed-by: psandoz, vlivanov, plevart
This commit is contained in:
Ben Walsh 2018-03-12 16:09:18 -07:00 committed by Paul Sandoz
parent f439f2166b
commit de3604ea0c
6 changed files with 113 additions and 67 deletions

View file

@ -25,7 +25,7 @@
package java.lang.ref;
import jdk.internal.vm.annotation.DontInline;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.JavaLangRefAccess;
import jdk.internal.misc.SharedSecrets;
@ -420,10 +420,12 @@ public abstract class Reference<T> {
* @param ref the reference. If {@code null}, this method has no effect.
* @since 9
*/
@DontInline
@ForceInline
public static void reachabilityFence(Object ref) {
// Does nothing, because this method is annotated with @DontInline
// HotSpot needs to retain the ref and not GC it before a call to this
// method
// Does nothing. This method is annotated with @ForceInline to eliminate
// most of the overhead that using @DontInline would cause with the
// HotSpot JVM, when this fence is used in a wide variety of situations.
// HotSpot JVM retains the ref and does not GC it before a call to
// this method, because the JIT-compilers do not have GC-only safepoints.
}
}