< prev index next >

src/hotspot/share/gc/shared/barrierSetNMethod.cpp

Print this page
@@ -26,30 +26,82 @@
  #include "code/codeCache.hpp"
  #include "code/nmethod.hpp"
  #include "gc/shared/barrierSet.hpp"
  #include "gc/shared/barrierSetNMethod.hpp"
  #include "logging/log.hpp"
+ #include "oops/access.inline.hpp"
  #include "runtime/thread.hpp"
  #include "runtime/threadWXSetters.inline.hpp"
  #include "utilities/debug.hpp"
  
+ class LoadPhantomOopClosure : public OopClosure {
+ public:
+   virtual void do_oop(oop* p) {
+     NativeAccess<ON_PHANTOM_OOP_REF>::oop_load(p);
+   }
+   virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
+ };
+ 
  int BarrierSetNMethod::disarmed_value() const {
    return *disarmed_value_address();
  }
  
  bool BarrierSetNMethod::supports_entry_barrier(nmethod* nm) {
    if (nm->method()->is_method_handle_intrinsic()) {
      return false;
    }
  
+   if (nm->method()->is_continuation_enter_intrinsic()) {
+     return false;
+   }
+ 
    if (!nm->is_native_method() && !nm->is_compiled_by_c2() && !nm->is_compiled_by_c1()) {
      return false;
    }
  
    return true;
  }
  
+ bool BarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
+   nm->mark_as_maybe_on_continuation();
+   LoadPhantomOopClosure cl;
+   nm->oops_do(&cl);
+   disarm(nm);
+ 
+   return true;
+ }
+ 
+ int* BarrierSetNMethod::disarmed_value_address() const {
+   return (int*) &_current_phase;
+ }
+ 
+ ByteSize BarrierSetNMethod::thread_disarmed_offset() const {
+   return Thread::nmethod_disarmed_offset();
+ }
+ 
+ class BarrierSetNMethodArmClosure : public ThreadClosure {
+ private:
+   int _disarm_value;
+ 
+ public:
+   BarrierSetNMethodArmClosure(int disarm_value) :
+     _disarm_value(disarm_value) { }
+ 
+   virtual void do_thread(Thread* thread) {
+     thread->set_nmethod_disarm_value(_disarm_value);
+   }
+ };
+ 
+ void BarrierSetNMethod::arm_all_nmethods() {
+   ++_current_phase;
+   if (_current_phase == 4) {
+     _current_phase = 1;
+   }
+   BarrierSetNMethodArmClosure cl(_current_phase);
+   Threads::threads_do(&cl);
+ }
+ 
  int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
    // Enable WXWrite: the function is called directly from nmethod_entry_barrier
    // stub.
    MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current()));
  
< prev index next >