< prev index next > src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp
Print this page
/*
* Copyright (c) 2017, 2021, Red Hat, Inc. All rights reserved.
+ * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
#include "gc/shared/gcWhen.hpp"
#include "gc/shared/referenceProcessorStats.hpp"
#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp"
#include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
#include "gc/shenandoah/shenandoahReferenceProcessor.hpp"
#include "gc/shenandoah/shenandoahUtils.hpp"
#include "utilities/debug.hpp"
ShenandoahPhaseTimings::Phase ShenandoahTimingsTracker::_current_phase = ShenandoahPhaseTimings::_invalid_phase;
! ShenandoahGCSession::ShenandoahGCSession(GCCause::Cause cause) :
_heap(ShenandoahHeap::heap()),
_timer(_heap->gc_timer()),
_tracer(_heap->tracer()) {
assert(!ShenandoahGCPhase::is_current_phase_valid(), "No current GC phase");
! _heap->set_gc_cause(cause);
_timer->register_gc_start();
_tracer->report_gc_start(cause, _timer->gc_start());
_heap->trace_heap_before_gc(_tracer);
- _heap->shenandoah_policy()->record_cycle_start();
- _heap->heuristics()->record_cycle_start();
_trace_cycle.initialize(_heap->cycle_memory_manager(), cause,
"end of GC cycle",
/* allMemoryPoolsAffected */ true,
/* recordGCBeginTime = */ true,
/* recordPreGCUsage = */ true,
#include "gc/shared/gcWhen.hpp"
#include "gc/shared/referenceProcessorStats.hpp"
#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp"
#include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
+ #include "gc/shenandoah/shenandoahOldGeneration.hpp"
#include "gc/shenandoah/shenandoahReferenceProcessor.hpp"
#include "gc/shenandoah/shenandoahUtils.hpp"
+ #include "gc/shenandoah/shenandoahYoungGeneration.hpp"
#include "utilities/debug.hpp"
ShenandoahPhaseTimings::Phase ShenandoahTimingsTracker::_current_phase = ShenandoahPhaseTimings::_invalid_phase;
! ShenandoahGCSession::ShenandoahGCSession(GCCause::Cause cause, ShenandoahGeneration* generation) :
_heap(ShenandoahHeap::heap()),
+ _generation(generation),
_timer(_heap->gc_timer()),
_tracer(_heap->tracer()) {
assert(!ShenandoahGCPhase::is_current_phase_valid(), "No current GC phase");
! _heap->on_cycle_start(cause, _generation);
+
_timer->register_gc_start();
_tracer->report_gc_start(cause, _timer->gc_start());
_heap->trace_heap_before_gc(_tracer);
_trace_cycle.initialize(_heap->cycle_memory_manager(), cause,
"end of GC cycle",
/* allMemoryPoolsAffected */ true,
/* recordGCBeginTime = */ true,
/* recordPreGCUsage = */ true,
/* countCollection = */ true
);
}
ShenandoahGCSession::~ShenandoahGCSession() {
! _heap->heuristics()->record_cycle_end();
_timer->register_gc_end();
_heap->trace_heap_after_gc(_tracer);
! _tracer->report_gc_reference_stats(_heap->ref_processor()->reference_process_stats());
_tracer->report_gc_end(_timer->gc_end(), _timer->time_partitions());
assert(!ShenandoahGCPhase::is_current_phase_valid(), "No current GC phase");
- _heap->set_gc_cause(GCCause::_no_gc);
}
ShenandoahGCPauseMark::ShenandoahGCPauseMark(uint gc_id, const char* notification_message, SvcGCMarker::reason_type type) :
_heap(ShenandoahHeap::heap()), _gc_id_mark(gc_id), _svc_gc_mark(type), _is_gc_active_mark() {
_trace_pause.initialize(_heap->stw_memory_manager(), _heap->gc_cause(),
/* countCollection = */ true
);
}
ShenandoahGCSession::~ShenandoahGCSession() {
! _heap->on_cycle_end(_generation);
_timer->register_gc_end();
_heap->trace_heap_after_gc(_tracer);
! _tracer->report_gc_reference_stats(_generation->ref_processor()->reference_process_stats());
_tracer->report_gc_end(_timer->gc_end(), _timer->time_partitions());
assert(!ShenandoahGCPhase::is_current_phase_valid(), "No current GC phase");
}
ShenandoahGCPauseMark::ShenandoahGCPauseMark(uint gc_id, const char* notification_message, SvcGCMarker::reason_type type) :
_heap(ShenandoahHeap::heap()), _gc_id_mark(gc_id), _svc_gc_mark(type), _is_gc_active_mark() {
_trace_pause.initialize(_heap->stw_memory_manager(), _heap->gc_cause(),
ShenandoahConcurrentPhase::~ShenandoahConcurrentPhase() {
_timer->register_gc_concurrent_end();
}
! ShenandoahTimingsTracker::ShenandoahTimingsTracker(ShenandoahPhaseTimings::Phase phase) :
! _timings(ShenandoahHeap::heap()->phase_timings()), _phase(phase) {
assert(Thread::current()->is_VM_thread() || Thread::current()->is_ConcurrentGC_thread(),
"Must be set by these threads");
_parent_phase = _current_phase;
_current_phase = phase;
_start = os::elapsedTime();
}
ShenandoahTimingsTracker::~ShenandoahTimingsTracker() {
! _timings->record_phase_time(_phase, os::elapsedTime() - _start);
_current_phase = _parent_phase;
}
bool ShenandoahTimingsTracker::is_current_phase_valid() {
return _current_phase < ShenandoahPhaseTimings::_num_phases;
ShenandoahConcurrentPhase::~ShenandoahConcurrentPhase() {
_timer->register_gc_concurrent_end();
}
! ShenandoahTimingsTracker::ShenandoahTimingsTracker(ShenandoahPhaseTimings::Phase phase, bool should_aggregate) :
! _timings(ShenandoahHeap::heap()->phase_timings()), _phase(phase), _should_aggregate(should_aggregate) {
assert(Thread::current()->is_VM_thread() || Thread::current()->is_ConcurrentGC_thread(),
"Must be set by these threads");
_parent_phase = _current_phase;
_current_phase = phase;
_start = os::elapsedTime();
}
ShenandoahTimingsTracker::~ShenandoahTimingsTracker() {
! _timings->record_phase_time(_phase, os::elapsedTime() - _start, _should_aggregate);
_current_phase = _parent_phase;
}
bool ShenandoahTimingsTracker::is_current_phase_valid() {
return _current_phase < ShenandoahPhaseTimings::_num_phases;
< prev index next >