< prev index next >

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

Print this page
rev 58162 : 8239926: Shenandoah: Shenandoah needs to mark nmethod's metadata
   1 /*
   2  * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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 

  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 
  66 int ShenandoahBarrierSetNMethod::disarmed_value() const {
  67   return ShenandoahCodeRoots::disarmed_value();
   1 /*
   2  * Copyright (c) 2019, 2020, Red Hat, Inc. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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 
  27 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
  28 #include "gc/shenandoah/shenandoahBarrierSetNMethod.hpp"
  29 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
  30 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  31 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  32 #include "gc/shenandoah/shenandoahLock.hpp"
  33 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
  34 #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
  35 #include "memory/iterator.hpp"
  36 #include "memory/resourceArea.hpp"
  37 
  38 bool ShenandoahBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
  39   ShenandoahReentrantLock* lock = ShenandoahNMethod::lock_for_nmethod(nm);
  40   assert(lock != NULL, "Must be");
  41   ShenandoahReentrantLocker locker(lock);
  42 
  43   if (!is_armed(nm)) {
  44     // Some other thread got here first and healed the oops
  45     // and disarmed the nmethod.
  46     return true;
  47   }
  48 
  49   // Mark phase nmethod barrier, keep the nmethod metadata alive
  50   if (ShenandoahHeap::heap()->is_concurrent_mark_in_progress()) {
  51     ShenandoahNMethod::keep_metadata_alive(nm);
  52     ShenandoahNMethod::disarm_nmethod(nm);
  53     return true;
  54   }
  55 
  56   ShenandoahHeap* const heap = ShenandoahHeap::heap();
  57 
  58   assert(heap->is_concurrent_root_in_progress(), "What else?");
  59   if (nm->is_unloading()) {
  60     // We don't need to take the lock when unlinking nmethods from
  61     // the Method, because it is only concurrently unlinked by
  62     // the entry barrier, which acquires the per nmethod lock.
  63     nm->unlink_from_method();
  64 
  65     // We can end up calling nmethods that are unloading
  66     // since we clear compiled ICs lazily. Returning false
  67     // will re-resovle the call and update the compiled IC.
  68     return false;
  69   }
  70 
  71   // Heal oops and disarm
  72   ShenandoahNMethod::heal_nmethod(nm);
  73   ShenandoahNMethod::disarm_nmethod(nm);
  74   return true;
  75 }
  76 
  77 int ShenandoahBarrierSetNMethod::disarmed_value() const {
  78   return ShenandoahCodeRoots::disarmed_value();
< prev index next >