diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-09-09 13:48:19 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2014-09-09 16:14:24 -0700 |
commit | 4722f3fc3107edb1b133b833277ce400222985a6 (patch) | |
tree | 73ffac2dd361c8cac6d677689d367c44d3d0f95f /libart/src | |
parent | d4bbc2208c1e951e8338b2fdf04b78f6352b9275 (diff) | |
download | libcore-4722f3fc3107edb1b133b833277ce400222985a6.zip libcore-4722f3fc3107edb1b133b833277ce400222985a6.tar.gz libcore-4722f3fc3107edb1b133b833277ce400222985a6.tar.bz2 |
Add Reference.getReferent for reference intrinsic.
Reference intrinsic was incorrectly inlining PhantomReference.get().
We get around this by adding a layer of indirection. Reference.get()
now calls getReferent() which is intrinsified and inlined.
Bug: 17429865
(cherry picked from commit ee1ba6114921065ff4629cdaee207e2960dadd63)
Change-Id: I305686d76e0e03856a46b85955622939718c8d85
Diffstat (limited to 'libart/src')
-rw-r--r-- | libart/src/main/java/java/lang/ref/Reference.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libart/src/main/java/java/lang/ref/Reference.java b/libart/src/main/java/java/lang/ref/Reference.java index 31ea588..70967b5 100644 --- a/libart/src/main/java/java/lang/ref/Reference.java +++ b/libart/src/main/java/java/lang/ref/Reference.java @@ -199,7 +199,19 @@ public abstract class Reference<T> { * @return the referent to which reference refers, or {@code null} if the * object has been cleared. */ - public native T get(); + public T get() { + return getReferent(); + } + + /** + * Returns the referent of the reference object. + * + * @return the referent to which reference refers, or {@code null} if the + * object has been cleared. Required since the compiler + * intrisifies getReferent() since we can't intrinsify Reference.get() + * due to incorrect devirtualization (and inlining) of PhantomReference.get(). + */ + private final native T getReferent(); /** * Checks whether the reference object has been enqueued. |