< prev index next >

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

Print this page
rev 59304 : 8245124: Shenandoah: optimize code root evacuation/update during concurrent class unloading


   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 #include "code/codeCache.hpp"
  27 #include "code/icBuffer.hpp"
  28 #include "code/nmethod.hpp"

  29 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  30 #include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"
  31 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  32 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
  33 #include "gc/shenandoah/shenandoahUtils.hpp"
  34 #include "memory/resourceArea.hpp"
  35 #include "memory/universe.hpp"
  36 #include "runtime/atomic.hpp"
  37 #include "utilities/powerOfTwo.hpp"
  38 
  39 ShenandoahParallelCodeCacheIterator::ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps) {
  40   _length = heaps->length();
  41   _iters = NEW_C_HEAP_ARRAY(ShenandoahParallelCodeHeapIterator, _length, mtGC);
  42   for (int h = 0; h < _length; h++) {
  43     _iters[h] = ShenandoahParallelCodeHeapIterator(heaps->at(h));
  44   }
  45 }
  46 
  47 ShenandoahParallelCodeCacheIterator::~ShenandoahParallelCodeCacheIterator() {
  48   FREE_C_HEAP_ARRAY(ParallelCodeHeapIterator, _iters);


 255       return;
 256     }
 257 
 258     ShenandoahNMethod* nm_data = ShenandoahNMethod::gc_data(nm);
 259     assert(!nm_data->is_unregistered(), "Should not see unregistered entry");
 260 
 261     if (!nm->is_alive()) {
 262       return;
 263     }
 264 
 265     if (nm->is_unloading()) {
 266       ShenandoahReentrantLocker locker(nm_data->lock());
 267       unlink(nm);
 268       return;
 269     }
 270 
 271     ShenandoahReentrantLocker locker(nm_data->lock());
 272 
 273     // Heal oops and disarm
 274     if (_bs->is_armed(nm)) {
 275       ShenandoahNMethod::heal_nmethod(nm);

 276       _bs->disarm(nm);
 277     }
 278 
 279     // Clear compiled ICs and exception caches
 280     if (!nm->unload_nmethod_caches(_unloading_occurred)) {
 281       set_failed();
 282     }
 283   }
 284 
 285   bool failed() const {
 286     return Atomic::load(&_failed);
 287   }
 288 };
 289 
 290 class ShenandoahUnlinkTask : public AbstractGangTask {
 291 private:
 292   ShenandoahNMethodUnlinkClosure      _cl;
 293   ICRefillVerifier*                   _verifier;
 294   ShenandoahConcurrentNMethodIterator _iterator;
 295 




   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 #include "code/codeCache.hpp"
  27 #include "code/icBuffer.hpp"
  28 #include "code/nmethod.hpp"
  29 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
  30 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  31 #include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"
  32 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  33 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
  34 #include "gc/shenandoah/shenandoahUtils.hpp"
  35 #include "memory/resourceArea.hpp"
  36 #include "memory/universe.hpp"
  37 #include "runtime/atomic.hpp"
  38 #include "utilities/powerOfTwo.hpp"
  39 
  40 ShenandoahParallelCodeCacheIterator::ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps) {
  41   _length = heaps->length();
  42   _iters = NEW_C_HEAP_ARRAY(ShenandoahParallelCodeHeapIterator, _length, mtGC);
  43   for (int h = 0; h < _length; h++) {
  44     _iters[h] = ShenandoahParallelCodeHeapIterator(heaps->at(h));
  45   }
  46 }
  47 
  48 ShenandoahParallelCodeCacheIterator::~ShenandoahParallelCodeCacheIterator() {
  49   FREE_C_HEAP_ARRAY(ParallelCodeHeapIterator, _iters);


 256       return;
 257     }
 258 
 259     ShenandoahNMethod* nm_data = ShenandoahNMethod::gc_data(nm);
 260     assert(!nm_data->is_unregistered(), "Should not see unregistered entry");
 261 
 262     if (!nm->is_alive()) {
 263       return;
 264     }
 265 
 266     if (nm->is_unloading()) {
 267       ShenandoahReentrantLocker locker(nm_data->lock());
 268       unlink(nm);
 269       return;
 270     }
 271 
 272     ShenandoahReentrantLocker locker(nm_data->lock());
 273 
 274     // Heal oops and disarm
 275     if (_bs->is_armed(nm)) {
 276       ShenandoahEvacOOMScope oom_evac_scope;
 277       ShenandoahNMethod::heal_nmethod_metadata(nm_data);
 278       _bs->disarm(nm);
 279     }
 280 
 281     // Clear compiled ICs and exception caches
 282     if (!nm->unload_nmethod_caches(_unloading_occurred)) {
 283       set_failed();
 284     }
 285   }
 286 
 287   bool failed() const {
 288     return Atomic::load(&_failed);
 289   }
 290 };
 291 
 292 class ShenandoahUnlinkTask : public AbstractGangTask {
 293 private:
 294   ShenandoahNMethodUnlinkClosure      _cl;
 295   ICRefillVerifier*                   _verifier;
 296   ShenandoahConcurrentNMethodIterator _iterator;
 297 


< prev index next >