< prev index next >

src/hotspot/cpu/aarch64/gc/shared/barrierSetNMethod_aarch64.cpp

Print this page

 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "code/codeCache.hpp"
 27 #include "code/nativeInst.hpp"
 28 #include "gc/shared/barrierSetNMethod.hpp"
 29 #include "logging/log.hpp"
 30 #include "memory/resourceArea.hpp"

 31 #include "runtime/sharedRuntime.hpp"
 32 #include "runtime/registerMap.hpp"
 33 #include "runtime/thread.hpp"
 34 #include "utilities/align.hpp"
 35 #include "utilities/debug.hpp"
 36 
 37 class NativeNMethodBarrier: public NativeInstruction {
 38   address instruction_address() const { return addr_at(0); }
 39 
 40   int *guard_addr() {
 41     return reinterpret_cast<int*>(instruction_address() + 10 * 4);
 42   }
 43 
 44 public:
 45   int get_value() {
 46     return Atomic::load_acquire(guard_addr());
 47   }
 48 
 49   void set_value(int value) {
 50     Atomic::release_store(guard_addr(), value);

136 
137 static NativeNMethodBarrier* native_nmethod_barrier(nmethod* nm) {
138   address barrier_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset;
139   NativeNMethodBarrier* barrier = reinterpret_cast<NativeNMethodBarrier*>(barrier_address);
140   debug_only(barrier->verify());
141   return barrier;
142 }
143 
144 void BarrierSetNMethod::disarm(nmethod* nm) {
145   if (!supports_entry_barrier(nm)) {
146     return;
147   }
148 
149   // Disarms the nmethod guard emitted by BarrierSetAssembler::nmethod_entry_barrier.
150   // Symmetric "LDR; DMB ISHLD" is in the nmethod barrier.
151   NativeNMethodBarrier* barrier = native_nmethod_barrier(nm);
152 
153   barrier->set_value(disarmed_value());
154 }
155 









156 bool BarrierSetNMethod::is_armed(nmethod* nm) {
157   if (!supports_entry_barrier(nm)) {
158     return false;
159   }
160 
161   NativeNMethodBarrier* barrier = native_nmethod_barrier(nm);
162   return barrier->get_value() != disarmed_value();
163 }

 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "code/codeCache.hpp"
 27 #include "code/nativeInst.hpp"
 28 #include "gc/shared/barrierSetNMethod.hpp"
 29 #include "logging/log.hpp"
 30 #include "memory/resourceArea.hpp"
 31 #include "runtime/frame.inline.hpp"
 32 #include "runtime/sharedRuntime.hpp"
 33 #include "runtime/registerMap.hpp"
 34 #include "runtime/thread.hpp"
 35 #include "utilities/align.hpp"
 36 #include "utilities/debug.hpp"
 37 
 38 class NativeNMethodBarrier: public NativeInstruction {
 39   address instruction_address() const { return addr_at(0); }
 40 
 41   int *guard_addr() {
 42     return reinterpret_cast<int*>(instruction_address() + 10 * 4);
 43   }
 44 
 45 public:
 46   int get_value() {
 47     return Atomic::load_acquire(guard_addr());
 48   }
 49 
 50   void set_value(int value) {
 51     Atomic::release_store(guard_addr(), value);

137 
138 static NativeNMethodBarrier* native_nmethod_barrier(nmethod* nm) {
139   address barrier_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset;
140   NativeNMethodBarrier* barrier = reinterpret_cast<NativeNMethodBarrier*>(barrier_address);
141   debug_only(barrier->verify());
142   return barrier;
143 }
144 
145 void BarrierSetNMethod::disarm(nmethod* nm) {
146   if (!supports_entry_barrier(nm)) {
147     return;
148   }
149 
150   // Disarms the nmethod guard emitted by BarrierSetAssembler::nmethod_entry_barrier.
151   // Symmetric "LDR; DMB ISHLD" is in the nmethod barrier.
152   NativeNMethodBarrier* barrier = native_nmethod_barrier(nm);
153 
154   barrier->set_value(disarmed_value());
155 }
156 
157 void BarrierSetNMethod::arm(nmethod* nm, int arm_value) {
158   if (!supports_entry_barrier(nm)) {
159     return;
160   }
161 
162   NativeNMethodBarrier* barrier = native_nmethod_barrier(nm);
163   barrier->set_value(arm_value);
164 }
165 
166 bool BarrierSetNMethod::is_armed(nmethod* nm) {
167   if (!supports_entry_barrier(nm)) {
168     return false;
169   }
170 
171   NativeNMethodBarrier* barrier = native_nmethod_barrier(nm);
172   return barrier->get_value() != disarmed_value();
173 }
< prev index next >