Skip to content

Commit

Permalink
8271862: C2 intrinsic for Reference.refersTo() is often not used
Browse files Browse the repository at this point in the history
Reviewed-by: kbarrett, mchung
  • Loading branch information
pliden committed Aug 11, 2021
1 parent abebbe2 commit 3f723ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ public T get() {
* do reference processing concurrently.
*/
@Override
boolean refersToImpl(T obj) {
return refersTo0(obj);
}

@IntrinsicCandidate
native final boolean refersTo0(Object o);
private native boolean refersTo0(Object o);

/**
* Creates a new phantom reference that refers to the given object and
Expand Down
11 changes: 9 additions & 2 deletions src/java.base/share/classes/java/lang/ref/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,20 @@ public T get() {
* @since 16
*/
public final boolean refersTo(T obj) {
return refersTo0(obj);
return refersToImpl(obj);
}

/* Implementation of refersTo(), overridden for phantom references.
* This method exists only to avoid making refersTo0() virtual. Making
* refersTo0() virtual has the undesirable effect of C2 often preferring
* to call the native implementation over the intrinsic.
*/
boolean refersToImpl(T obj) {
return refersTo0(obj);
}

@IntrinsicCandidate
native boolean refersTo0(Object o);
private native boolean refersTo0(Object o);

/**
* Clears this reference object. Invoking this method will not cause this
Expand Down

1 comment on commit 3f723ca

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.