src/hotspot/share/gc/shenandoah/shenandoahNMethod.inline.hpp
changeset 59296 9186be5c78ba
equal deleted inserted replaced
59295:8b6cc0bb93d0 59296:9186be5c78ba
       
     1 /*
       
     2  * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
       
     3  *
       
     4  * This code is free software; you can redistribute it and/or modify it
       
     5  * under the terms of the GNU General Public License version 2 only, as
       
     6  * published by the Free Software Foundation.
       
     7  *
       
     8  * This code is distributed in the hope that it will be useful, but WITHOUT
       
     9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    11  * version 2 for more details (a copy is included in the LICENSE file that
       
    12  * accompanied this code).
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License version
       
    15  * 2 along with this work; if not, write to the Free Software Foundation,
       
    16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    17  *
       
    18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    19  * or visit www.oracle.com if you need additional information or have any
       
    20  * questions.
       
    21  *
       
    22  */
       
    23 
       
    24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHNMETHOD_INLINE_HPP
       
    25 #define SHARE_GC_SHENANDOAH_SHENANDOAHNMETHOD_INLINE_HPP
       
    26 
       
    27 #include "gc/shared/barrierSet.hpp"
       
    28 #include "gc/shared/barrierSetNMethod.hpp"
       
    29 #include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
       
    30 #include "gc/shenandoah/shenandoahNMethod.hpp"
       
    31 
       
    32 nmethod* ShenandoahNMethod::nm() const {
       
    33   return _nm;
       
    34 }
       
    35 
       
    36 ShenandoahReentrantLock* ShenandoahNMethod::lock() {
       
    37   return &_lock;
       
    38 }
       
    39 
       
    40 int ShenandoahNMethod::oop_count() const {
       
    41   return _oops_count + static_cast<int>(nm()->oops_end() - nm()->oops_begin());
       
    42 }
       
    43 
       
    44 bool ShenandoahNMethod::has_oops() const {
       
    45   return oop_count() > 0;
       
    46 }
       
    47 
       
    48 void ShenandoahNMethod::mark_unregistered() {
       
    49   _unregistered = true;
       
    50 }
       
    51 
       
    52 bool ShenandoahNMethod::is_unregistered() const {
       
    53   return _unregistered;
       
    54 }
       
    55 
       
    56 void ShenandoahNMethod::disarm_nmethod(nmethod* nm) {
       
    57  if (!ShenandoahConcurrentRoots::can_do_concurrent_class_unloading()) {
       
    58    return;
       
    59  }
       
    60 
       
    61  BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod();
       
    62  assert(bs != NULL, "Sanity");
       
    63  bs->disarm(nm);
       
    64 }
       
    65 
       
    66 ShenandoahNMethod* ShenandoahNMethod::gc_data(nmethod* nm) {
       
    67   return nm->gc_data<ShenandoahNMethod>();
       
    68 }
       
    69 
       
    70 void ShenandoahNMethod::attach_gc_data(nmethod* nm, ShenandoahNMethod* gc_data) {
       
    71   nm->set_gc_data<ShenandoahNMethod>(gc_data);
       
    72 }
       
    73 
       
    74 ShenandoahReentrantLock* ShenandoahNMethod::lock_for_nmethod(nmethod* nm) {
       
    75   return gc_data(nm)->lock();
       
    76 }
       
    77 
       
    78 bool ShenandoahNMethodTable::iteration_in_progress() const {
       
    79   return _iteration_in_progress;
       
    80 }
       
    81 
       
    82 template<bool CSET_FILTER>
       
    83 void ShenandoahNMethodTableSnapshot::parallel_blobs_do(CodeBlobClosure *f) {
       
    84   size_t stride = 256; // educated guess
       
    85 
       
    86   ShenandoahNMethod** const list = _array;
       
    87 
       
    88   size_t max = (size_t)_length;
       
    89   while (_claimed < max) {
       
    90     size_t cur = Atomic::add(&_claimed, stride) - stride;
       
    91     size_t start = cur;
       
    92     size_t end = MIN2(cur + stride, max);
       
    93     if (start >= max) break;
       
    94 
       
    95     for (size_t idx = start; idx < end; idx++) {
       
    96       ShenandoahNMethod* nmr = list[idx];
       
    97       assert(nmr != NULL, "Sanity");
       
    98       if (nmr->is_unregistered()) {
       
    99         continue;
       
   100       }
       
   101 
       
   102       nmr->assert_alive_and_correct();
       
   103 
       
   104       if (CSET_FILTER && !nmr->has_cset_oops(_heap)) {
       
   105         continue;
       
   106       }
       
   107 
       
   108       f->do_code_blob(nmr->nm());
       
   109     }
       
   110   }
       
   111 }
       
   112 
       
   113 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHNMETHOD_INLINE_HPP