Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8143041: Unify G1CollectorPolicy::PauseKind and G1YCType
Reviewed-by: tschatzl, ayang
  • Loading branch information
Ivan Walulya committed Mar 11, 2021
1 parent f6b4ba0 commit 470b15027bb70b3e13e1d37fbf1c27c58b1fe8d6
@@ -43,6 +43,7 @@
#include "gc/g1/g1FullCollector.hpp"
#include "gc/g1/g1GCParPhaseTimesTracker.hpp"
#include "gc/g1/g1GCPhaseTimes.hpp"
#include "gc/g1/g1GCTypes.hpp"
#include "gc/g1/g1HeapSizingPolicy.hpp"
#include "gc/g1/g1HeapTransition.hpp"
#include "gc/g1/g1HeapVerifier.hpp"
@@ -63,7 +64,6 @@
#include "gc/g1/g1StringDedup.hpp"
#include "gc/g1/g1ThreadLocalData.hpp"
#include "gc/g1/g1Trace.hpp"
#include "gc/g1/g1YCTypes.hpp"
#include "gc/g1/g1ServiceThread.hpp"
#include "gc/g1/g1UncommitRegionTask.hpp"
#include "gc/g1/g1VMOperations.hpp"
@@ -2926,7 +2926,7 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
{
G1EvacuationInfo evacuation_info;

_gc_tracer_stw->report_yc_type(collector_state()->yc_type());
_gc_tracer_stw->report_yc_phase(collector_state()->young_gc_phase());

GCTraceCPUTime tcpu;

@@ -2940,7 +2940,7 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus

G1MonitoringScope ms(g1mm(),
false /* full_gc */,
collector_state()->yc_type() == Mixed /* all_memory_pools_affected */);
collector_state()->young_gc_phase() == Mixed /* all_memory_pools_affected */);

G1HeapTransition heap_transition(this);

@@ -36,6 +36,7 @@
#include "gc/g1/g1EvacStats.hpp"
#include "gc/g1/g1EvacuationInfo.hpp"
#include "gc/g1/g1GCPhaseTimes.hpp"
#include "gc/g1/g1GCTypes.hpp"
#include "gc/g1/g1HeapTransition.hpp"
#include "gc/g1/g1HeapVerifier.hpp"
#include "gc/g1/g1HRPrinter.hpp"
@@ -44,7 +45,6 @@
#include "gc/g1/g1NUMA.hpp"
#include "gc/g1/g1RedirtyCardsQueue.hpp"
#include "gc/g1/g1SurvivorRegions.hpp"
#include "gc/g1/g1YCTypes.hpp"
#include "gc/g1/heapRegionManager.hpp"
#include "gc/g1/heapRegionSet.hpp"
#include "gc/shared/barrierSet.hpp"
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2021, Oracle and/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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

#include "precompiled.hpp"
#include "gc/g1/g1CollectorState.hpp"
#include "gc/g1/g1GCTypes.hpp"

G1GCPauseType G1CollectorState::young_gc_pause_type(bool concurrent_operation_is_full_mark) const {
assert(!in_full_gc(), "must be");
if (in_concurrent_start_gc()) {
assert(!in_young_gc_before_mixed(), "must be");
return concurrent_operation_is_full_mark ? ConcurrentStartMarkGC : ConcurrentStartUndoGC;
} else if (in_young_gc_before_mixed()) {
assert(!in_concurrent_start_gc(), "must be");
return LastYoungGC;
} else if (in_mixed_phase()) {
assert(!in_concurrent_start_gc(), "must be");
assert(!in_young_gc_before_mixed(), "must be");
return MixedGC;
} else {
assert(!in_concurrent_start_gc(), "must be");
assert(!in_young_gc_before_mixed(), "must be");
return YoungGC;
}
}

G1GCYoungPhase G1CollectorState::young_gc_phase() const {
assert(!in_full_gc(), "must be");

if (in_concurrent_start_gc()) {
return ConcurrentStart;
} else if (mark_or_rebuild_in_progress()) {
return DuringMarkOrRebuild;
} else if (in_young_only_phase()) {
return Normal;
} else {
return Mixed;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/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
@@ -25,7 +25,7 @@
#ifndef SHARE_GC_G1_G1COLLECTORSTATE_HPP
#define SHARE_GC_G1_G1COLLECTORSTATE_HPP

#include "gc/g1/g1YCTypes.hpp"
#include "gc/g1/g1GCTypes.hpp"
#include "utilities/globalDefinitions.hpp"

// State of the G1 collection.
@@ -110,17 +110,10 @@ class G1CollectorState {
bool mark_or_rebuild_in_progress() const { return _mark_or_rebuild_in_progress; }
bool clearing_next_bitmap() const { return _clearing_next_bitmap; }

G1YCType yc_type() const {
if (in_concurrent_start_gc()) {
return ConcurrentStart;
} else if (mark_or_rebuild_in_progress()) {
return DuringMarkOrRebuild;
} else if (in_young_only_phase()) {
return Normal;
} else {
return Mixed;
}
}
// Calculate GC Pause Type from internal state.
G1GCPauseType young_gc_pause_type(bool concurrent_operation_is_full_mark) const;
G1GCYoungPhase young_gc_phase() const;

};

#endif // SHARE_GC_G1_G1COLLECTORSTATE_HPP
@@ -0,0 +1,94 @@
/*
* Copyright (c) 2021, Oracle and/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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

#ifndef SHARE_GC_G1_G1GCTYPES_HPP
#define SHARE_GC_G1_G1GCTYPES_HPP

#include "utilities/debug.hpp"

// Enumarate the phases in which the collection cycle can be.
enum G1GCYoungPhase {
Normal,
ConcurrentStart,
DuringMarkOrRebuild,
Mixed,
G1GCYoungPhaseEndSentinel
};

enum G1GCPauseType {
YoungGC,
LastYoungGC,
ConcurrentStartMarkGC,
ConcurrentStartUndoGC,
Cleanup,
Remark,
MixedGC,
FullGC,
G1GCPauseTypeEndSentinel
};

class G1GCTypeHelper {
public:

static void assert_is_young_pause(G1GCPauseType type) {
assert(type != FullGC, "must be");
assert(type != Remark, "must be");
assert(type != Cleanup, "must be");
}

static bool is_young_only_pause(G1GCPauseType type) {
assert_is_young_pause(type);
return type == ConcurrentStartUndoGC ||
type == ConcurrentStartMarkGC ||
type == LastYoungGC ||
type == YoungGC;
}

static bool is_mixed_pause(G1GCPauseType type) {
assert_is_young_pause(type);
return type == MixedGC;
}

static bool is_last_young_pause(G1GCPauseType type) {
assert_is_young_pause(type);
return type == LastYoungGC;
}

static bool is_concurrent_start_pause(G1GCPauseType type) {
assert_is_young_pause(type);
return type == ConcurrentStartMarkGC || type == ConcurrentStartUndoGC;
}

static const char* to_string(G1GCYoungPhase type) {
switch(type) {
case Normal: return "Normal";
case ConcurrentStart: return "Concurrent Start";
case DuringMarkOrRebuild: return "During Mark";
case Mixed: return "Mixed";
default: ShouldNotReachHere(); return NULL;
}
}
};

#endif // SHARE_GC_G1_G1GCTYPES_HPP

0 comments on commit 470b150

Please sign in to comment.