Skip to content

Commit 470b150

Browse files
author
Ivan Walulya
committed
8143041: Unify G1CollectorPolicy::PauseKind and G1YCType
Reviewed-by: tschatzl, ayang
1 parent f6b4ba0 commit 470b150

File tree

10 files changed

+202
-169
lines changed

10 files changed

+202
-169
lines changed

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "gc/g1/g1FullCollector.hpp"
4444
#include "gc/g1/g1GCParPhaseTimesTracker.hpp"
4545
#include "gc/g1/g1GCPhaseTimes.hpp"
46+
#include "gc/g1/g1GCTypes.hpp"
4647
#include "gc/g1/g1HeapSizingPolicy.hpp"
4748
#include "gc/g1/g1HeapTransition.hpp"
4849
#include "gc/g1/g1HeapVerifier.hpp"
@@ -63,7 +64,6 @@
6364
#include "gc/g1/g1StringDedup.hpp"
6465
#include "gc/g1/g1ThreadLocalData.hpp"
6566
#include "gc/g1/g1Trace.hpp"
66-
#include "gc/g1/g1YCTypes.hpp"
6767
#include "gc/g1/g1ServiceThread.hpp"
6868
#include "gc/g1/g1UncommitRegionTask.hpp"
6969
#include "gc/g1/g1VMOperations.hpp"
@@ -2926,7 +2926,7 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
29262926
{
29272927
G1EvacuationInfo evacuation_info;
29282928

2929-
_gc_tracer_stw->report_yc_type(collector_state()->yc_type());
2929+
_gc_tracer_stw->report_yc_phase(collector_state()->young_gc_phase());
29302930

29312931
GCTraceCPUTime tcpu;
29322932

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

29412941
G1MonitoringScope ms(g1mm(),
29422942
false /* full_gc */,
2943-
collector_state()->yc_type() == Mixed /* all_memory_pools_affected */);
2943+
collector_state()->young_gc_phase() == Mixed /* all_memory_pools_affected */);
29442944

29452945
G1HeapTransition heap_transition(this);
29462946

src/hotspot/share/gc/g1/g1CollectedHeap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "gc/g1/g1EvacStats.hpp"
3737
#include "gc/g1/g1EvacuationInfo.hpp"
3838
#include "gc/g1/g1GCPhaseTimes.hpp"
39+
#include "gc/g1/g1GCTypes.hpp"
3940
#include "gc/g1/g1HeapTransition.hpp"
4041
#include "gc/g1/g1HeapVerifier.hpp"
4142
#include "gc/g1/g1HRPrinter.hpp"
@@ -44,7 +45,6 @@
4445
#include "gc/g1/g1NUMA.hpp"
4546
#include "gc/g1/g1RedirtyCardsQueue.hpp"
4647
#include "gc/g1/g1SurvivorRegions.hpp"
47-
#include "gc/g1/g1YCTypes.hpp"
4848
#include "gc/g1/heapRegionManager.hpp"
4949
#include "gc/g1/heapRegionSet.hpp"
5050
#include "gc/shared/barrierSet.hpp"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*
23+
*/
24+
25+
#include "precompiled.hpp"
26+
#include "gc/g1/g1CollectorState.hpp"
27+
#include "gc/g1/g1GCTypes.hpp"
28+
29+
G1GCPauseType G1CollectorState::young_gc_pause_type(bool concurrent_operation_is_full_mark) const {
30+
assert(!in_full_gc(), "must be");
31+
if (in_concurrent_start_gc()) {
32+
assert(!in_young_gc_before_mixed(), "must be");
33+
return concurrent_operation_is_full_mark ? ConcurrentStartMarkGC : ConcurrentStartUndoGC;
34+
} else if (in_young_gc_before_mixed()) {
35+
assert(!in_concurrent_start_gc(), "must be");
36+
return LastYoungGC;
37+
} else if (in_mixed_phase()) {
38+
assert(!in_concurrent_start_gc(), "must be");
39+
assert(!in_young_gc_before_mixed(), "must be");
40+
return MixedGC;
41+
} else {
42+
assert(!in_concurrent_start_gc(), "must be");
43+
assert(!in_young_gc_before_mixed(), "must be");
44+
return YoungGC;
45+
}
46+
}
47+
48+
G1GCYoungPhase G1CollectorState::young_gc_phase() const {
49+
assert(!in_full_gc(), "must be");
50+
51+
if (in_concurrent_start_gc()) {
52+
return ConcurrentStart;
53+
} else if (mark_or_rebuild_in_progress()) {
54+
return DuringMarkOrRebuild;
55+
} else if (in_young_only_phase()) {
56+
return Normal;
57+
} else {
58+
return Mixed;
59+
}
60+
}

src/hotspot/share/gc/g1/g1CollectorState.hpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
2525
#ifndef SHARE_GC_G1_G1COLLECTORSTATE_HPP
2626
#define SHARE_GC_G1_G1COLLECTORSTATE_HPP
2727

28-
#include "gc/g1/g1YCTypes.hpp"
28+
#include "gc/g1/g1GCTypes.hpp"
2929
#include "utilities/globalDefinitions.hpp"
3030

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

113-
G1YCType yc_type() const {
114-
if (in_concurrent_start_gc()) {
115-
return ConcurrentStart;
116-
} else if (mark_or_rebuild_in_progress()) {
117-
return DuringMarkOrRebuild;
118-
} else if (in_young_only_phase()) {
119-
return Normal;
120-
} else {
121-
return Mixed;
122-
}
123-
}
113+
// Calculate GC Pause Type from internal state.
114+
G1GCPauseType young_gc_pause_type(bool concurrent_operation_is_full_mark) const;
115+
G1GCYoungPhase young_gc_phase() const;
116+
124117
};
125118

126119
#endif // SHARE_GC_G1_G1COLLECTORSTATE_HPP
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*
23+
*/
24+
25+
#ifndef SHARE_GC_G1_G1GCTYPES_HPP
26+
#define SHARE_GC_G1_G1GCTYPES_HPP
27+
28+
#include "utilities/debug.hpp"
29+
30+
// Enumarate the phases in which the collection cycle can be.
31+
enum G1GCYoungPhase {
32+
Normal,
33+
ConcurrentStart,
34+
DuringMarkOrRebuild,
35+
Mixed,
36+
G1GCYoungPhaseEndSentinel
37+
};
38+
39+
enum G1GCPauseType {
40+
YoungGC,
41+
LastYoungGC,
42+
ConcurrentStartMarkGC,
43+
ConcurrentStartUndoGC,
44+
Cleanup,
45+
Remark,
46+
MixedGC,
47+
FullGC,
48+
G1GCPauseTypeEndSentinel
49+
};
50+
51+
class G1GCTypeHelper {
52+
public:
53+
54+
static void assert_is_young_pause(G1GCPauseType type) {
55+
assert(type != FullGC, "must be");
56+
assert(type != Remark, "must be");
57+
assert(type != Cleanup, "must be");
58+
}
59+
60+
static bool is_young_only_pause(G1GCPauseType type) {
61+
assert_is_young_pause(type);
62+
return type == ConcurrentStartUndoGC ||
63+
type == ConcurrentStartMarkGC ||
64+
type == LastYoungGC ||
65+
type == YoungGC;
66+
}
67+
68+
static bool is_mixed_pause(G1GCPauseType type) {
69+
assert_is_young_pause(type);
70+
return type == MixedGC;
71+
}
72+
73+
static bool is_last_young_pause(G1GCPauseType type) {
74+
assert_is_young_pause(type);
75+
return type == LastYoungGC;
76+
}
77+
78+
static bool is_concurrent_start_pause(G1GCPauseType type) {
79+
assert_is_young_pause(type);
80+
return type == ConcurrentStartMarkGC || type == ConcurrentStartUndoGC;
81+
}
82+
83+
static const char* to_string(G1GCYoungPhase type) {
84+
switch(type) {
85+
case Normal: return "Normal";
86+
case ConcurrentStart: return "Concurrent Start";
87+
case DuringMarkOrRebuild: return "During Mark";
88+
case Mixed: return "Mixed";
89+
default: ShouldNotReachHere(); return NULL;
90+
}
91+
}
92+
};
93+
94+
#endif // SHARE_GC_G1_G1GCTYPES_HPP

0 commit comments

Comments
 (0)