8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
authoreosterlund
Mon, 30 Apr 2018 21:17:37 +0200
changeset 49929 f38329fe8055
parent 49928 ae58e24ce81a
child 49930 3aaaa5370999
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224 Reviewed-by: kbarrett, dcubed
src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp
src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp
src/hotspot/cpu/aarch64/jniFastGetField_aarch64.cpp
src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.cpp
src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.hpp
src/hotspot/cpu/sparc/jniFastGetField_sparc.cpp
src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp
src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp
src/hotspot/cpu/x86/jniFastGetField_x86_64.cpp
--- a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp	Mon Apr 30 09:49:08 2018 -0700
+++ b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp	Mon Apr 30 21:17:37 2018 +0200
@@ -66,9 +66,10 @@
   }
 }
 
-void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register robj, Register tmp, Label& slowpath) {
+void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
+                                                        Register obj, Register tmp, Label& slowpath) {
   // If mask changes we need to ensure that the inverse is still encodable as an immediate
   STATIC_ASSERT(JNIHandles::weak_tag_mask == 1);
-  __ andr(robj, robj, ~JNIHandles::weak_tag_mask);
-  __ ldr(robj, Address(robj, 0));             // *obj
+  __ andr(obj, obj, ~JNIHandles::weak_tag_mask);
+  __ ldr(obj, Address(obj, 0));             // *obj
 }
--- a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp	Mon Apr 30 09:49:08 2018 -0700
+++ b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp	Mon Apr 30 21:17:37 2018 +0200
@@ -40,7 +40,8 @@
   virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
                         Address dst, Register val, Register tmp1, Register tmp2);
 
-  virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register robj, Register tmp, Label& slowpath);
+  virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
+                                             Register obj, Register tmp, Label& slowpath);
 
   virtual void barrier_stubs_init() {}
 };
--- a/src/hotspot/cpu/aarch64/jniFastGetField_aarch64.cpp	Mon Apr 30 09:49:08 2018 -0700
+++ b/src/hotspot/cpu/aarch64/jniFastGetField_aarch64.cpp	Mon Apr 30 21:17:37 2018 +0200
@@ -85,7 +85,7 @@
                                               // robj is address dependent on rcounter.
 
   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
-  bs->try_resolve_jobject_in_native(masm, robj, rscratch1, slow);
+  bs->try_resolve_jobject_in_native(masm, c_rarg0, robj, rscratch1, slow);
 
   __ lsr(roffset, c_rarg2, 2);                // offset
 
--- a/src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.cpp	Mon Apr 30 09:49:08 2018 -0700
+++ b/src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.cpp	Mon Apr 30 21:17:37 2018 +0200
@@ -100,7 +100,8 @@
   }
 }
 
-void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register robj, Register tmp, Label& slowpath) {
-  __ andn (robj, JNIHandles::weak_tag_mask, robj);
-  __ ld_ptr(robj, 0, robj);
+void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
+                                                        Register obj, Register tmp, Label& slowpath) {
+  __ andn(obj, JNIHandles::weak_tag_mask, obj);
+  __ ld_ptr(obj, 0, obj);
 }
--- a/src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.hpp	Mon Apr 30 09:49:08 2018 -0700
+++ b/src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.hpp	Mon Apr 30 21:17:37 2018 +0200
@@ -45,7 +45,8 @@
                        Address src, Register dst, Register tmp);
 
   // Support for jniFastGetField to try resolving a jobject/jweak in native
-  virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register robj, Register tmp, Label& slowpath);
+  virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
+                                             Register obj, Register tmp, Label& slowpath);
 
   virtual void barrier_stubs_init() {}
 };
--- a/src/hotspot/cpu/sparc/jniFastGetField_sparc.cpp	Mon Apr 30 09:49:08 2018 -0700
+++ b/src/hotspot/cpu/sparc/jniFastGetField_sparc.cpp	Mon Apr 30 21:17:37 2018 +0200
@@ -70,18 +70,20 @@
   __ andcc (G4, 1, G0);
   __ br (Assembler::notZero, false, Assembler::pn, label1);
   __ delayed()->srl (O2, 2, O4);
+  __ mov(O1, O5);
 
+  // Both O5 and G3 are clobbered by try_resolve_jobject_in_native.
   BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
-  bs->try_resolve_jobject_in_native(masm, O1, G3_scratch, label1);
+  bs->try_resolve_jobject_in_native(masm, /* jni_env */ O0, /* obj */ O5, /* tmp */ G3, label1);
 
   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
   speculative_load_pclist[count] = __ pc();
   switch (type) {
-    case T_BOOLEAN: __ ldub (O1, O4, G3);  break;
-    case T_BYTE:    __ ldsb (O1, O4, G3);  break;
-    case T_CHAR:    __ lduh (O1, O4, G3);  break;
-    case T_SHORT:   __ ldsh (O1, O4, G3);  break;
-    case T_INT:     __ ld (O1, O4, G3);    break;
+    case T_BOOLEAN: __ ldub (O5, O4, G3);  break;
+    case T_BYTE:    __ ldsb (O5, O4, G3);  break;
+    case T_CHAR:    __ lduh (O5, O4, G3);  break;
+    case T_SHORT:   __ ldsh (O5, O4, G3);  break;
+    case T_INT:     __ ld (O5, O4, G3);    break;
     default:        ShouldNotReachHere();
   }
 
--- a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp	Mon Apr 30 09:49:08 2018 -0700
+++ b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp	Mon Apr 30 21:17:37 2018 +0200
@@ -110,7 +110,8 @@
   }
 }
 
-void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register robj, Register tmp, Label& slowpath) {
-  __ clear_jweak_tag(robj);
-  __ movptr(robj, Address(robj, 0));
+void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
+                                                        Register obj, Register tmp, Label& slowpath) {
+  __ clear_jweak_tag(obj);
+  __ movptr(obj, Address(obj, 0));
 }
--- a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp	Mon Apr 30 09:49:08 2018 -0700
+++ b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp	Mon Apr 30 21:17:37 2018 +0200
@@ -45,7 +45,8 @@
                         Address dst, Register val, Register tmp1, Register tmp2);
 
   // Support for jniFastGetField to try resolving a jobject/jweak in native
-  virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register robj, Register tmp, Label& slowpath);
+  virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
+                                             Register obj, Register tmp, Label& slowpath);
 
   virtual void barrier_stubs_init() {}
 };
--- a/src/hotspot/cpu/x86/jniFastGetField_x86_64.cpp	Mon Apr 30 09:49:08 2018 -0700
+++ b/src/hotspot/cpu/x86/jniFastGetField_x86_64.cpp	Mon Apr 30 21:17:37 2018 +0200
@@ -44,6 +44,7 @@
 // c_rarg1:    obj
 // c_rarg2:    jfield id
 
+static const Register rtmp          = r8;
 static const Register robj          = r9;
 static const Register rcounter      = r10;
 static const Register roffset       = r11;
@@ -86,8 +87,10 @@
   __ mov   (roffset, c_rarg2);
   __ shrptr(roffset, 2);                         // offset
 
+  // Both robj and rtmp are clobbered by try_resolve_jobject_in_native.
   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
-  bs->try_resolve_jobject_in_native(masm, robj, rscratch1, slow);
+  bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow);
+  DEBUG_ONLY(__ movl(rtmp, 0xDEADC0DE);)
 
   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
   speculative_load_pclist[count] = __ pc();