From 4d4175a132b944214ed7559beb9b6b91d2eb36e1 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 Merged-In: I0f298bf5cc375d8ebc19bb791cc05a8490d55430 (cherry picked from AOSP commit c7b28de9f8bf407d91cff22de782d022492b45f7) --- 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 ff6186b240..9bfd74f91b 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; @@ -74,6 +75,7 @@ public class Main { // Reference ft so we are sure the WeakReference cannot be cleared. FinalizerTest keepLive = wimp.get(); System.out.println("wimp: " + wimpString(wimp)); + Reference.reachabilityFence(keepLive); } public static void main(String[] args) { -- cgit v1.2.3-59-g8ed1b