< 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/shenandoahClosures.inline.hpp"
  31 #include "gc/shenandoah/shenandoahRootProcessor.hpp"
  32 #include "gc/shenandoah/shenandoahHeap.hpp"
  33 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
  34 #include "gc/shenandoah/shenandoahStringDedup.hpp"
  35 #include "gc/shenandoah/shenandoahTimingTracker.hpp"
  36 #include "gc/shenandoah/shenandoahUtils.hpp"
  37 #include "gc/shenandoah/shenandoahVMOperations.hpp"
  38 #include "gc/shared/weakProcessor.inline.hpp"
  39 #include "memory/allocation.inline.hpp"
  40 #include "memory/iterator.hpp"
  41 #include "memory/resourceArea.hpp"
  42 #include "runtime/thread.hpp"
  43 #include "services/management.hpp"
  44 
  45 struct PhaseMap {
  46   WeakProcessorPhases::Phase            _weak_processor_phase;
  47   ShenandoahPhaseTimings::GCParPhases   _shenandoah_phase;
  48 };
  49 
  50 static const struct PhaseMap phase_mapping[] = {
  51 #if INCLUDE_JVMTI
  52   {WeakProcessorPhases::jvmti,                 ShenandoahPhaseTimings::JVMTIWeakRoots},
  53 #endif
  54 #if INCLUDE_JFR
  55   {WeakProcessorPhases::jfr,                   ShenandoahPhaseTimings::JFRWeakRoots},
  56 #endif
  57   {WeakProcessorPhases::jni,                   ShenandoahPhaseTimings::JNIWeakRoots},
  58   {WeakProcessorPhases::stringtable,           ShenandoahPhaseTimings::StringTableRoots},
  59   {WeakProcessorPhases::resolved_method_table, ShenandoahPhaseTimings::ResolvedMethodTableRoots},
  60   {WeakProcessorPhases::vm,                    ShenandoahPhaseTimings::VMWeakRoots}
  61 };
  62 
  63 STATIC_ASSERT(sizeof(phase_mapping) / sizeof(PhaseMap) == WeakProcessorPhases::phase_count);
  64 
  65 ShenandoahRootProcessor::ShenandoahRootProcessor(ShenandoahHeap* heap, uint n_workers,
  66                                                  ShenandoahPhaseTimings::Phase phase) :
  67   _process_strong_tasks(new SubTasksDone(SHENANDOAH_RP_PS_NumElements)),
  68   _srs(n_workers),

  69   _phase(phase),
  70   _coderoots_all_iterator(ShenandoahCodeRoots::iterator()),
  71   _weak_processor_timings(n_workers),
  72   _weak_processor_task(&_weak_processor_timings, n_workers),
  73   _processed_weak_roots(false) {
  74   heap->phase_timings()->record_workers_start(_phase);
  75 
  76   if (ShenandoahStringDedup::is_enabled()) {
  77     StringDedup::gc_prologue(false);
  78   }
  79 }
  80 
  81 ShenandoahRootProcessor::~ShenandoahRootProcessor() {
  82   delete _process_strong_tasks;
  83   if (ShenandoahStringDedup::is_enabled()) {
  84     StringDedup::gc_epilogue();
  85   }
  86 
  87   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
  88 


 226     ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::SystemDictionaryRoots, worker_id);
 227     SystemDictionary::oops_do(strong_roots);
 228   }
 229 
 230   {
 231     ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::ObjectSynchronizerRoots, worker_id);
 232     if (_process_strong_tasks->try_claim_task(SHENANDOAH_RP_PS_ObjectSynchronizer_oops_do)) {
 233       ObjectSynchronizer::oops_do(strong_roots);
 234     }
 235   }
 236 }
 237 
 238 uint ShenandoahRootProcessor::n_workers() const {
 239   return _srs.n_threads();
 240 }
 241 
 242 ShenandoahRootEvacuator::ShenandoahRootEvacuator(ShenandoahHeap* heap, uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 243   _evacuation_tasks(new SubTasksDone(SHENANDOAH_EVAC_NumElements)),
 244   _srs(n_workers),
 245   _phase(phase),
 246   _coderoots_cset_iterator(ShenandoahCodeRoots::cset_iterator()) {



 247   heap->phase_timings()->record_workers_start(_phase);
 248   if (ShenandoahStringDedup::is_enabled()) {
 249     StringDedup::gc_prologue(false);
 250   }
 251 }
 252 
 253 ShenandoahRootEvacuator::~ShenandoahRootEvacuator() {
 254   delete _evacuation_tasks;
 255   if (ShenandoahStringDedup::is_enabled()) {
 256     StringDedup::gc_epilogue();
 257   }
 258   ShenandoahHeap::heap()->phase_timings()->record_workers_end(_phase);
 259 }
 260 
 261 void ShenandoahRootEvacuator::process_evacuate_roots(OopClosure* oops,
 262                                                      CodeBlobClosure* blobs,
 263                                                      uint worker_id) {
 264 
 265   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
 266   {




  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.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/shenandoahUtils.hpp"
  36 #include "gc/shenandoah/shenandoahVMOperations.hpp"
  37 #include "gc/shared/weakProcessor.inline.hpp"
  38 #include "memory/allocation.inline.hpp"
  39 #include "memory/iterator.hpp"
  40 #include "memory/resourceArea.hpp"
  41 #include "runtime/thread.hpp"
  42 #include "services/management.hpp"
  43 
  44 struct PhaseMap {
  45   WeakProcessorPhases::Phase            _weak_processor_phase;
  46   ShenandoahPhaseTimings::GCParPhases   _shenandoah_phase;
  47 };
  48 
  49 static const struct PhaseMap phase_mapping[] = {
  50 #if INCLUDE_JVMTI
  51   {WeakProcessorPhases::jvmti,       ShenandoahPhaseTimings::JVMTIWeakRoots},
  52 #endif
  53 #if INCLUDE_JFR
  54   {WeakProcessorPhases::jfr,         ShenandoahPhaseTimings::JFRWeakRoots},
  55 #endif
  56   {WeakProcessorPhases::jni,         ShenandoahPhaseTimings::JNIWeakRoots},
  57   {WeakProcessorPhases::stringtable, ShenandoahPhaseTimings::StringTableRoots},
  58   {WeakProcessorPhases::vm,          ShenandoahPhaseTimings::VMWeakRoots}

  59 };
  60 
  61 STATIC_ASSERT(sizeof(phase_mapping) / sizeof(PhaseMap) == WeakProcessorPhases::phase_count);
  62 
  63 ShenandoahRootProcessor::ShenandoahRootProcessor(ShenandoahHeap* heap, uint n_workers,
  64                                                  ShenandoahPhaseTimings::Phase phase) :
  65   _process_strong_tasks(new SubTasksDone(SHENANDOAH_RP_PS_NumElements)),
  66   _srs(n_workers),
  67   _par_state_string(StringTable::weak_storage()),
  68   _phase(phase),
  69   _coderoots_all_iterator(ShenandoahCodeRoots::iterator()),
  70   _weak_processor_timings(n_workers),
  71   _weak_processor_task(&_weak_processor_timings, n_workers),
  72   _processed_weak_roots(false) {
  73   heap->phase_timings()->record_workers_start(_phase);
  74 
  75   if (ShenandoahStringDedup::is_enabled()) {
  76     StringDedup::gc_prologue(false);
  77   }
  78 }
  79 
  80 ShenandoahRootProcessor::~ShenandoahRootProcessor() {
  81   delete _process_strong_tasks;
  82   if (ShenandoahStringDedup::is_enabled()) {
  83     StringDedup::gc_epilogue();
  84   }
  85 
  86   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
  87 


 225     ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::SystemDictionaryRoots, worker_id);
 226     SystemDictionary::oops_do(strong_roots);
 227   }
 228 
 229   {
 230     ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::ObjectSynchronizerRoots, worker_id);
 231     if (_process_strong_tasks->try_claim_task(SHENANDOAH_RP_PS_ObjectSynchronizer_oops_do)) {
 232       ObjectSynchronizer::oops_do(strong_roots);
 233     }
 234   }
 235 }
 236 
 237 uint ShenandoahRootProcessor::n_workers() const {
 238   return _srs.n_threads();
 239 }
 240 
 241 ShenandoahRootEvacuator::ShenandoahRootEvacuator(ShenandoahHeap* heap, uint n_workers, ShenandoahPhaseTimings::Phase phase) :
 242   _evacuation_tasks(new SubTasksDone(SHENANDOAH_EVAC_NumElements)),
 243   _srs(n_workers),
 244   _phase(phase),
 245   _coderoots_cset_iterator(ShenandoahCodeRoots::cset_iterator()),
 246   _par_state_string(StringTable::weak_storage())
 247 
 248 {
 249   heap->phase_timings()->record_workers_start(_phase);
 250   if (ShenandoahStringDedup::is_enabled()) {
 251     StringDedup::gc_prologue(false);
 252   }
 253 }
 254 
 255 ShenandoahRootEvacuator::~ShenandoahRootEvacuator() {
 256   delete _evacuation_tasks;
 257   if (ShenandoahStringDedup::is_enabled()) {
 258     StringDedup::gc_epilogue();
 259   }
 260   ShenandoahHeap::heap()->phase_timings()->record_workers_end(_phase);
 261 }
 262 
 263 void ShenandoahRootEvacuator::process_evacuate_roots(OopClosure* oops,
 264                                                      CodeBlobClosure* blobs,
 265                                                      uint worker_id) {
 266 
 267   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
 268   {


< prev index next >