[aarch64-port-dev ] Changes to JavaThread::_thread_state must use acquire and release

Andrew Haley aph at redhat.com
Thu Jan 15 13:29:59 UTC 2015


The GC threads interact with changes to thread_state such that all
accesses must be ordered.  In addition, we were incorrectly accessing
thread_state as a doubleword in a few places.

Andrew.


# HG changeset patch
# User aph
# Date 1421328403 18000
#      Thu Jan 15 08:26:43 2015 -0500
# Node ID 0b3590e22a843724aac9ed4a18947314a809f5cf
# Parent  99bde6a0f59372efd2a5f97eab4ad4b039815ae1
Accesses of JavaThread::_thread_state must use acquire and release.

diff -r 99bde6a0f593 -r 0b3590e22a84 src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp
--- a/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Fri Jan 09 13:22:02 2015 -0500
+++ b/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Thu Jan 15 08:26:43 2015 -0500
@@ -1846,7 +1846,8 @@

   // Now set thread in native
   __ mov(rscratch1, _thread_in_native);
-  __ str(rscratch1, Address(rthread, JavaThread::thread_state_offset()));
+  __ lea(rscratch2, Address(rthread, JavaThread::thread_state_offset()));
+  __ stlrw(rscratch1, rscratch2);

   {
     int return_type = 0;
@@ -1903,7 +1904,8 @@
   //     Thread A is resumed to finish this native method, but doesn't block here since it
   //     didn't see any synchronization is progress, and escapes.
   __ mov(rscratch1, _thread_in_native_trans);
-  __ str(rscratch1, Address(rthread, JavaThread::thread_state_offset()));
+  __ lea(rscratch2, Address(rthread, JavaThread::thread_state_offset()));
+  __ stlrw(rscratch1, rscratch2);

   if(os::is_MP()) {
     if (UseMembar) {
@@ -1967,7 +1969,8 @@

   // change thread state
   __ mov(rscratch1, _thread_in_Java);
-  __ str(rscratch1, Address(rthread, JavaThread::thread_state_offset()));
+  __ lea(rscratch2, Address(rthread, JavaThread::thread_state_offset()));
+  __ stlrw(rscratch1, rscratch2);
   __ bind(after_transition);

   Label reguard;
diff -r 99bde6a0f593 -r 0b3590e22a84 src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp
--- a/src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp	Fri Jan 09 13:22:02 2015 -0500
+++ b/src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp	Thu Jan 15 08:26:43 2015 -0500
@@ -1098,7 +1098,8 @@

   // Change state to native
   __ mov(rscratch1, _thread_in_native);
-  __ strw(rscratch1, Address(rthread, JavaThread::thread_state_offset()));
+  __ lea(rscratch2, Address(rthread, JavaThread::thread_state_offset()));
+  __ stlrw(rscratch1, rscratch2);

   // Call the native method.
   __ blrt(r10, rscratch1);
@@ -1119,7 +1120,8 @@

   // change thread state
   __ mov(rscratch1, _thread_in_native_trans);
-  __ strw(rscratch1, Address(rthread, JavaThread::thread_state_offset()));
+  __ lea(rscratch2, Address(rthread, JavaThread::thread_state_offset()));
+  __ stlrw(rscratch1, rscratch2);

   if (os::is_MP()) {
     if (UseMembar) {
@@ -1168,7 +1170,8 @@

   // change thread state
   __ mov(rscratch1, _thread_in_Java);
-  __ strw(rscratch1, Address(rthread, JavaThread::thread_state_offset()));
+  __ lea(rscratch2, Address(rthread, JavaThread::thread_state_offset()));
+  __ stlrw(rscratch1, rscratch2);

   // reset_last_Java_frame
   __ reset_last_Java_frame(true, true);
diff -r 99bde6a0f593 -r 0b3590e22a84 src/share/vm/runtime/thread.hpp
--- a/src/share/vm/runtime/thread.hpp	Fri Jan 09 13:22:02 2015 -0500
+++ b/src/share/vm/runtime/thread.hpp	Thu Jan 15 08:26:43 2015 -0500
@@ -1017,7 +1017,7 @@
   address last_Java_pc(void)                     { return _anchor.last_Java_pc(); }

   // Safepoint support
-#ifndef PPC64
+#if ! (defined(PPC64) || defined(AARCH64))
   JavaThreadState thread_state() const           { return _thread_state; }
   void set_thread_state(JavaThreadState s)       { _thread_state = s;    }
 #else
diff -r 99bde6a0f593 -r 0b3590e22a84 src/share/vm/runtime/thread.inline.hpp
--- a/src/share/vm/runtime/thread.inline.hpp	Fri Jan 09 13:22:02 2015 -0500
+++ b/src/share/vm/runtime/thread.inline.hpp	Thu Jan 15 08:26:43 2015 -0500
@@ -122,7 +122,7 @@
   set_has_async_exception();
 }

-#ifdef PPC64
+#if defined(PPC64) || defined (AARCH64)
 inline JavaThreadState JavaThread::thread_state() const    {
   return (JavaThreadState) OrderAccess::load_acquire((volatile jint*)&_thread_state);
 }


More information about the aarch64-port-dev mailing list