From c7b28de9f8bf407d91cff22de782d022492b45f7 Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Fri, 9 Mar 2018 17:05:28 -0800 Subject: Add reachabilityFence intrinsics Add intrinsics that generate no code or do nothing for all architectures and for the interpreter. The only impact is to keep the argument live at all suspend points preceding the call. We ensure that the code is not moved across other memory accesses by declaring it to have write side-effects. Add a minimal test. Modify 036-finalizer to use a reachabilityFence, hopefully making it more robust to dead refererence elimination. Bug: 72698200 Test: Build and boot AOSP. art/test.py --host -r -t 072-reachability-fence Look at generated code. Change-Id: I0f298bf5cc375d8ebc19bb791cc05a8490d55430 --- test/036-finalizer/src/Main.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/036-finalizer/src/Main.java') diff --git a/test/036-finalizer/src/Main.java b/test/036-finalizer/src/Main.java index 51d4a81150..be7ae4a8c2 100644 --- a/test/036-finalizer/src/Main.java +++ b/test/036-finalizer/src/Main.java @@ -14,6 +14,7 @@ * limitations under the License. */ +import java.lang.ref.Reference; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; @@ -80,6 +81,7 @@ public class Main { // the test fail (even when keeping the `null` assignment). b/76454261 FinalizerTest keepLive = wimp.get(); System.out.println("wimp: " + wimpString(wimp)); + Reference.reachabilityFence(keepLive); keepLive = null; // Clear the reference. /* this will try to collect and finalize ft */ -- cgit v1.2.3-59-g8ed1b