< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahBarrierSetNMethod.cpp

Print this page
rev 59811 : 8247670: Shenandoah: deadlock during class unloading OOME


  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 
  27 #include "gc/shenandoah/shenandoahBarrierSetNMethod.hpp"
  28 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
  29 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  31 #include "gc/shenandoah/shenandoahLock.hpp"
  32 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
  33 #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
  34 #include "memory/iterator.hpp"
  35 #include "memory/resourceArea.hpp"
  36 
  37 bool ShenandoahBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
  38   ShenandoahReentrantLock* lock = ShenandoahNMethod::lock_for_nmethod(nm);
  39   assert(lock != NULL, "Must be");
  40   ShenandoahReentrantLocker locker(lock);
  41 
  42   if (!is_armed(nm)) {
  43     // Some other thread got here first and healed the oops
  44     // and disarmed the nmethod.
  45     return true;






  46   }
  47 
  48   if (nm->is_unloading()) {
  49     // We don't need to take the lock when unlinking nmethods from
  50     // the Method, because it is only concurrently unlinked by
  51     // the entry barrier, which acquires the per nmethod lock.
  52     nm->unlink_from_method();
  53 
  54     // We can end up calling nmethods that are unloading
  55     // since we clear compiled ICs lazily. Returning false
  56     // will re-resovle the call and update the compiled IC.
  57     return false;
  58   }
  59 
  60   // Heal oops and disarm
  61   ShenandoahNMethod::heal_nmethod(nm);
  62   ShenandoahNMethod::disarm_nmethod(nm);
  63   return true;
  64 }
  65 


  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 
  27 #include "gc/shenandoah/shenandoahBarrierSetNMethod.hpp"
  28 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
  29 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  31 #include "gc/shenandoah/shenandoahLock.hpp"
  32 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
  33 #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
  34 #include "memory/iterator.hpp"
  35 #include "memory/resourceArea.hpp"
  36 
  37 bool ShenandoahBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
  38   ShenandoahReentrantLock* lock = ShenandoahNMethod::lock_for_nmethod(nm);
  39   assert(lock != NULL, "Must be");
  40   ShenandoahAbortableNMethodLocker locker(lock);
  41 
  42   if (!is_armed(nm)) {
  43     // Some other thread got here first and healed the oops
  44     // and disarmed the nmethod.
  45     return true;
  46   }
  47 
  48   // We may not be able to acquire the lock without potential deadlock if
  49   // we run into evacuation OOM, just return false
  50   if (locker.aborted()) {
  51     return false;
  52   }
  53 
  54   if (nm->is_unloading()) {
  55     // We don't need to take the lock when unlinking nmethods from
  56     // the Method, because it is only concurrently unlinked by
  57     // the entry barrier, which acquires the per nmethod lock.
  58     nm->unlink_from_method();
  59 
  60     // We can end up calling nmethods that are unloading
  61     // since we clear compiled ICs lazily. Returning false
  62     // will re-resovle the call and update the compiled IC.
  63     return false;
  64   }
  65 
  66   // Heal oops and disarm
  67   ShenandoahNMethod::heal_nmethod(nm);
  68   ShenandoahNMethod::disarm_nmethod(nm);
  69   return true;
  70 }
  71 
< prev index next >