changeset 9105:2a07e209249a jdk8u222-b04-aarch32-190603

8176100: [aarch32] [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
author snazarki
date Fri, 31 May 2019 15:14:42 +0300
parents 608620359cc0
children ff3264647a3d
files src/cpu/aarch32/vm/jniFastGetField_aarch32.cpp src/cpu/aarch32/vm/macroAssembler_aarch32.cpp src/cpu/aarch32/vm/macroAssembler_aarch32.hpp src/cpu/aarch32/vm/sharedRuntime_aarch32.cpp src/cpu/aarch32/vm/templateInterpreter_aarch32.cpp
diffstat 5 files changed, 41 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/aarch32/vm/jniFastGetField_aarch32.cpp	Thu May 30 18:02:33 2019 +0300
+++ b/src/cpu/aarch32/vm/jniFastGetField_aarch32.cpp	Fri May 31 15:14:42 2019 +0300
@@ -84,6 +84,9 @@
   // performing __ ldr(robj, ...
   __ eor(robj, c_rarg1, rcounter);
   __ eor(robj, robj, rcounter);
+
+  __ clear_jweak_tag(robj);
+
   __ ldr(robj, Address(robj, 0)); // *obj
 
   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
--- a/src/cpu/aarch32/vm/macroAssembler_aarch32.cpp	Thu May 30 18:02:33 2019 +0300
+++ b/src/cpu/aarch32/vm/macroAssembler_aarch32.cpp	Fri May 31 15:14:42 2019 +0300
@@ -1834,36 +1834,39 @@
   str(rscratch1, dst);
 }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+void MacroAssembler::resolve_jobject(Register value,
+                                     Register thread,
+                                     Register tmp) {
+     Label done, not_weak;
+    cbz(value, done);           // Use NULL as-is.
+    STATIC_ASSERT(JNIHandles::weak_tag_mask == 1u);
+    tbz(value, 0, not_weak);    // Test for jweak tag.
+    // Resolve jweak.
+    ldr(value, Address(value, -JNIHandles::weak_tag_value));
+    verify_oop(value);
+#if INCLUDE_ALL_GCS
+    if (UseG1GC) {
+      g1_write_barrier_pre(noreg /* obj */,
+                              value /* pre_val */,
+                              thread /* thread */,
+                              tmp   /* tmp */,
+                              true /* tosca_live */,
+                              true /* expand_call */);
+    }
+#endif // INCLUDE_ALL_GCS
+    b(done);
+    bind(not_weak);
+    // Resolve (untagged) jobject.
+    ldr(value, Address(value, 0));
+    verify_oop(value);
+    bind(done);
+}
+
+void MacroAssembler::clear_jweak_tag(Register possibly_jweak) {
+  // If mask changes we need to ensure that the inverse is still encodable as an immediate
+  STATIC_ASSERT(JNIHandles::weak_tag_mask == 1);
+  bfc(possibly_jweak, 0, 1);
+}
 
 
 #if INCLUDE_ALL_GCS
--- a/src/cpu/aarch32/vm/macroAssembler_aarch32.hpp	Thu May 30 18:02:33 2019 +0300
+++ b/src/cpu/aarch32/vm/macroAssembler_aarch32.hpp	Fri May 31 15:14:42 2019 +0300
@@ -426,6 +426,9 @@
   void store_check(Register obj);                // store check for obj - register is destroyed afterwards
   void store_check(Register obj, Address dst);   // same as above, dst is exact store location (reg. is destroyed)
 
+  void resolve_jobject(Register value, Register thread, Register tmp);
+  void clear_jweak_tag(Register possibly_jweak);
+
 #if INCLUDE_ALL_GCS
 
   void g1_write_barrier_pre(Register obj,
--- a/src/cpu/aarch32/vm/sharedRuntime_aarch32.cpp	Thu May 30 18:02:33 2019 +0300
+++ b/src/cpu/aarch32/vm/sharedRuntime_aarch32.cpp	Fri May 31 15:14:42 2019 +0300
@@ -2076,11 +2076,7 @@
 
   // Unpack oop result
   if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
-      Label L;
-      __ cbz(r0, L);
-      __ ldr(r0, Address(r0, 0));
-      __ bind(L);
-      __ verify_oop(r0);
+    __ resolve_jobject(r0, rthread, rscratch1);
   }
 
   if (!is_critical_native) {
--- a/src/cpu/aarch32/vm/templateInterpreter_aarch32.cpp	Thu May 30 18:02:33 2019 +0300
+++ b/src/cpu/aarch32/vm/templateInterpreter_aarch32.cpp	Fri May 31 15:14:42 2019 +0300
@@ -1126,9 +1126,7 @@
     __ reg_printf("It's an oop.\n");
     // retrieve result
     __ pop(ltos);
-    __ cbz(r0, store_result);
-    __ ldr(r0, Address(r0));
-    __ bind(store_result);
+    __ resolve_jobject(r0, rthread, rscratch1);
     __ str(r0, Address(rfp, frame::interpreter_frame_oop_temp_offset*wordSize));
     // keep stack depth as expected by pushing oop which will eventually be discarded
     __ push(ltos);