< prev index next >

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

Print this page




  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 #include "precompiled.hpp"
  25 
  26 #include "classfile/classLoaderDataGraph.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "code/codeCache.hpp"


  30 #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
  31 #include "gc/shenandoah/shenandoahHeap.hpp"
  32 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
  33 #include "gc/shenandoah/shenandoahStringDedup.hpp"
  34 #include "gc/shenandoah/shenandoahTimingTracker.hpp"
  35 #include "gc/shenandoah/shenandoahVMOperations.hpp"
  36 #include "jfr/jfr.hpp"
  37 #include "memory/iterator.hpp"
  38 #include "memory/resourceArea.hpp"
  39 #include "memory/universe.hpp"
  40 #include "runtime/thread.hpp"
  41 #include "services/management.hpp"
  42 
  43 ShenandoahSerialRoot::ShenandoahSerialRoot(ShenandoahSerialRoot::OopsDo oops_do, ShenandoahPhaseTimings::GCParPhases phase) :
  44   _oops_do(oops_do), _phase(phase) {
  45 }
  46 
  47 void ShenandoahSerialRoot::oops_do(OopClosure* cl, uint worker_id) {
  48   if (_claimed.try_set()) {
  49     ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();


 142 }
 143 
 144 void ShenandoahStringDedupRoots::oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive, uint worker_id) {
 145   if (ShenandoahStringDedup::is_enabled()) {
 146     ShenandoahStringDedup::parallel_oops_do(is_alive, keep_alive, worker_id);
 147   }
 148 }
 149 
 150 ShenandoahRootProcessor::ShenandoahRootProcessor(ShenandoahPhaseTimings::Phase phase) :
 151   _heap(ShenandoahHeap::heap()),
 152   _phase(phase) {
 153   assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
 154   _heap->phase_timings()->record_workers_start(_phase);
 155 }
 156 
 157 ShenandoahRootProcessor::~ShenandoahRootProcessor() {
 158   assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
 159   _heap->phase_timings()->record_workers_end(_phase);
 160 }
 161 
 162 ShenandoahRootEvacuator::ShenandoahRootEvacuator(uint n_workers, ShenandoahPhaseTimings::Phase phase, bool include_concurrent_roots) :



 163   ShenandoahRootProcessor(phase),
 164   _thread_roots(n_workers > 1),
 165   _include_concurrent_roots(include_concurrent_roots) {

 166 }
 167 
 168 void ShenandoahRootEvacuator::roots_do(uint worker_id, OopClosure* oops) {
 169   MarkingCodeBlobClosure blobsCl(oops, CodeBlobToOopClosure::FixRelocations);




 170   AlwaysTrueClosure always_true;
 171 
 172   _serial_roots.oops_do(oops, worker_id);
 173   _serial_weak_roots.weak_oops_do(oops, worker_id);
 174   if (_include_concurrent_roots) {
 175     CLDToOopClosure clds(oops, ClassLoaderData::_claim_strong);
 176     _vm_roots.oops_do<OopClosure>(oops, worker_id);
 177     _cld_roots.cld_do(&clds, worker_id);
 178     _weak_roots.oops_do<OopClosure>(oops, worker_id);
 179   }
 180 
 181   _thread_roots.oops_do(oops, NULL, worker_id);
 182   _code_roots.code_blobs_do(&blobsCl, worker_id);




 183 
 184   _dedup_roots.oops_do(&always_true, oops, worker_id);
 185 }
 186 
 187 ShenandoahRootUpdater::ShenandoahRootUpdater(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 188   ShenandoahRootProcessor(phase),
 189   _thread_roots(n_workers > 1) {
 190 }
 191 
 192 void ShenandoahRootUpdater::strong_roots_do(uint worker_id, OopClosure* oops_cl) {
 193   CodeBlobToOopClosure update_blobs(oops_cl, CodeBlobToOopClosure::FixRelocations);
 194   CLDToOopClosure clds(oops_cl, ClassLoaderData::_claim_strong);
 195 
 196   _serial_roots.oops_do(oops_cl, worker_id);
 197   _vm_roots.oops_do(oops_cl, worker_id);
 198 
 199   _thread_roots.oops_do(oops_cl, NULL, worker_id);
 200   _cld_roots.cld_do(&clds, worker_id);
 201   _code_roots.code_blobs_do(&update_blobs, worker_id);
 202 }
 203 
 204 ShenandoahRootAdjuster::ShenandoahRootAdjuster(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 205   ShenandoahRootProcessor(phase),
 206   _thread_roots(n_workers > 1) {
 207   assert(ShenandoahHeap::heap()->is_full_gc_in_progress(), "Full GC only");
 208 }
 209 
 210 void ShenandoahRootAdjuster::roots_do(uint worker_id, OopClosure* oops) {
 211   CodeBlobToOopClosure adjust_code_closure(oops, CodeBlobToOopClosure::FixRelocations);




 212   CLDToOopClosure adjust_cld_closure(oops, ClassLoaderData::_claim_strong);
 213   AlwaysTrueClosure always_true;
 214 
 215   _serial_roots.oops_do(oops, worker_id);
 216   _vm_roots.oops_do(oops, worker_id);
 217 
 218   _thread_roots.oops_do(oops, NULL, worker_id);
 219   _cld_roots.cld_do(&adjust_cld_closure, worker_id);
 220   _code_roots.code_blobs_do(&adjust_code_closure, worker_id);
 221 
 222   _serial_weak_roots.weak_oops_do(oops, worker_id);
 223   _weak_roots.oops_do<OopClosure>(oops, worker_id);
 224   _dedup_roots.oops_do(&always_true, oops, worker_id);
 225 }
 226 
 227  ShenandoahHeapIterationRootScanner::ShenandoahHeapIterationRootScanner() :
 228    ShenandoahRootProcessor(ShenandoahPhaseTimings::_num_phases),
 229    _thread_roots(false /*is par*/) {
 230  }
 231 
 232  void ShenandoahHeapIterationRootScanner::roots_do(OopClosure* oops) {
 233    assert(Thread::current()->is_VM_thread(), "Only by VM thread");
 234    // Must use _claim_none to avoid interfering with concurrent CLDG iteration
 235    CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
 236    MarkingCodeBlobClosure code(oops, !CodeBlobToOopClosure::FixRelocations);
 237    ShenandoahParallelOopsDoThreadClosure tc_cl(oops, &code, NULL);
 238    AlwaysTrueClosure always_true;
 239    ResourceMark rm;
 240 




  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 #include "precompiled.hpp"
  25 
  26 #include "classfile/classLoaderDataGraph.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "code/codeCache.hpp"
  30 #include "gc/shenandoah/shenandoahClosures.inline.hpp"
  31 #include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
  32 #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
  33 #include "gc/shenandoah/shenandoahHeap.hpp"
  34 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
  35 #include "gc/shenandoah/shenandoahStringDedup.hpp"
  36 #include "gc/shenandoah/shenandoahTimingTracker.hpp"
  37 #include "gc/shenandoah/shenandoahVMOperations.hpp"
  38 #include "jfr/jfr.hpp"
  39 #include "memory/iterator.hpp"
  40 #include "memory/resourceArea.hpp"
  41 #include "memory/universe.hpp"
  42 #include "runtime/thread.hpp"
  43 #include "services/management.hpp"
  44 
  45 ShenandoahSerialRoot::ShenandoahSerialRoot(ShenandoahSerialRoot::OopsDo oops_do, ShenandoahPhaseTimings::GCParPhases phase) :
  46   _oops_do(oops_do), _phase(phase) {
  47 }
  48 
  49 void ShenandoahSerialRoot::oops_do(OopClosure* cl, uint worker_id) {
  50   if (_claimed.try_set()) {
  51     ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();


 144 }
 145 
 146 void ShenandoahStringDedupRoots::oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive, uint worker_id) {
 147   if (ShenandoahStringDedup::is_enabled()) {
 148     ShenandoahStringDedup::parallel_oops_do(is_alive, keep_alive, worker_id);
 149   }
 150 }
 151 
 152 ShenandoahRootProcessor::ShenandoahRootProcessor(ShenandoahPhaseTimings::Phase phase) :
 153   _heap(ShenandoahHeap::heap()),
 154   _phase(phase) {
 155   assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
 156   _heap->phase_timings()->record_workers_start(_phase);
 157 }
 158 
 159 ShenandoahRootProcessor::~ShenandoahRootProcessor() {
 160   assert(SafepointSynchronize::is_at_safepoint(), "Must at safepoint");
 161   _heap->phase_timings()->record_workers_end(_phase);
 162 }
 163 
 164 ShenandoahRootEvacuator::ShenandoahRootEvacuator(uint n_workers,
 165                                                  ShenandoahPhaseTimings::Phase phase,
 166                                                  bool include_concurrent_roots,
 167                                                  bool include_concurrent_code_roots) :
 168   ShenandoahRootProcessor(phase),
 169   _thread_roots(n_workers > 1),
 170   _include_concurrent_roots(include_concurrent_roots),
 171   _include_concurrent_code_roots(include_concurrent_code_roots) {
 172 }
 173 
 174 void ShenandoahRootEvacuator::roots_do(uint worker_id, OopClosure* oops) {
 175   MarkingCodeBlobClosure blobsCl(oops, CodeBlobToOopClosure::FixRelocations);
 176   ShenandoahCodeBlobAndDisarmClosure blobs_and_disarm_Cl(oops);
 177   CodeBlobToOopClosure* codes_cl = ShenandoahConcurrentRoots::can_do_concurrent_class_unloading() ?
 178                                    static_cast<CodeBlobToOopClosure*>(&blobs_and_disarm_Cl) :
 179                                    static_cast<CodeBlobToOopClosure*>(&blobsCl);
 180   AlwaysTrueClosure always_true;
 181 
 182   _serial_roots.oops_do(oops, worker_id);
 183   _serial_weak_roots.weak_oops_do(oops, worker_id);
 184   if (_include_concurrent_roots) {
 185     CLDToOopClosure clds(oops, ClassLoaderData::_claim_strong);
 186     _vm_roots.oops_do<OopClosure>(oops, worker_id);
 187     _cld_roots.cld_do(&clds, worker_id);
 188     _weak_roots.oops_do<OopClosure>(oops, worker_id);
 189   }
 190 
 191   if (_include_concurrent_code_roots) {
 192     _code_roots.code_blobs_do(codes_cl, worker_id);
 193     _thread_roots.oops_do(oops, NULL, worker_id);
 194   } else {
 195     _thread_roots.oops_do(oops, codes_cl, worker_id);
 196   }
 197 
 198   _dedup_roots.oops_do(&always_true, oops, worker_id);
 199 }
 200 
 201 ShenandoahRootUpdater::ShenandoahRootUpdater(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 202   ShenandoahRootProcessor(phase),
 203   _thread_roots(n_workers > 1) {
 204 }
 205 
 206 void ShenandoahRootUpdater::strong_roots_do(uint worker_id, OopClosure* oops_cl) {
 207   CodeBlobToOopClosure update_blobs(oops_cl, CodeBlobToOopClosure::FixRelocations);
 208   CLDToOopClosure clds(oops_cl, ClassLoaderData::_claim_strong);
 209 
 210   _serial_roots.oops_do(oops_cl, worker_id);
 211   _vm_roots.oops_do(oops_cl, worker_id);
 212 
 213   _thread_roots.oops_do(oops_cl, NULL, worker_id);
 214   _cld_roots.cld_do(&clds, worker_id);
 215   _code_roots.code_blobs_do(&update_blobs, worker_id);
 216 }
 217 
 218 ShenandoahRootAdjuster::ShenandoahRootAdjuster(uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 219   ShenandoahRootProcessor(phase),
 220   _thread_roots(n_workers > 1) {
 221   assert(ShenandoahHeap::heap()->is_full_gc_in_progress(), "Full GC only");
 222 }
 223 
 224 void ShenandoahRootAdjuster::roots_do(uint worker_id, OopClosure* oops) {
 225   CodeBlobToOopClosure code_blob_cl(oops, CodeBlobToOopClosure::FixRelocations);
 226   ShenandoahCodeBlobAndDisarmClosure blobs_and_disarm_Cl(oops);
 227   CodeBlobToOopClosure* adjust_code_closure = ShenandoahConcurrentRoots::can_do_concurrent_class_unloading() ?
 228                                               static_cast<CodeBlobToOopClosure*>(&blobs_and_disarm_Cl) :
 229                                               static_cast<CodeBlobToOopClosure*>(&code_blob_cl);
 230   CLDToOopClosure adjust_cld_closure(oops, ClassLoaderData::_claim_strong);
 231   AlwaysTrueClosure always_true;
 232 
 233   _serial_roots.oops_do(oops, worker_id);
 234   _vm_roots.oops_do(oops, worker_id);
 235 
 236   _thread_roots.oops_do(oops, NULL, worker_id);
 237   _cld_roots.cld_do(&adjust_cld_closure, worker_id);
 238   _code_roots.code_blobs_do(adjust_code_closure, worker_id);
 239 
 240   _serial_weak_roots.weak_oops_do(oops, worker_id);
 241   _weak_roots.oops_do<OopClosure>(oops, worker_id);
 242   _dedup_roots.oops_do(&always_true, oops, worker_id);
 243 }
 244 
 245  ShenandoahHeapIterationRootScanner::ShenandoahHeapIterationRootScanner() :
 246    ShenandoahRootProcessor(ShenandoahPhaseTimings::_num_phases),
 247    _thread_roots(false /*is par*/) {
 248  }
 249 
 250  void ShenandoahHeapIterationRootScanner::roots_do(OopClosure* oops) {
 251    assert(Thread::current()->is_VM_thread(), "Only by VM thread");
 252    // Must use _claim_none to avoid interfering with concurrent CLDG iteration
 253    CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
 254    MarkingCodeBlobClosure code(oops, !CodeBlobToOopClosure::FixRelocations);
 255    ShenandoahParallelOopsDoThreadClosure tc_cl(oops, &code, NULL);
 256    AlwaysTrueClosure always_true;
 257    ResourceMark rm;
 258 


< prev index next >