author | shade |
Thu, 30 Nov 2017 17:13:33 +0100 | |
branch | epsilon-gc-branch |
changeset 55934 | 912c55e702d6 |
parent 47765 | b7c7428eaab9 |
child 49020 | 6d61be5959e0 |
permissions | -rw-r--r-- |
18025 | 1 |
/* |
46795
623a5e42deb6
8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
35529
diff
changeset
|
2 |
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. |
18025 | 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 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_SHARED_GCTIMER_HPP |
26 |
#define SHARE_VM_GC_SHARED_GCTIMER_HPP |
|
18025 | 27 |
|
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "utilities/macros.hpp" |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
30 |
#include "utilities/ticks.hpp" |
18025 | 31 |
|
32 |
class ConcurrentPhase; |
|
33 |
class GCPhase; |
|
34 |
class PausePhase; |
|
35 |
||
36 |
template <class E> class GrowableArray; |
|
37 |
||
38 |
class PhaseVisitor { |
|
39 |
public: |
|
40 |
virtual void visit(GCPhase* phase) = 0; |
|
41 |
}; |
|
42 |
||
43 |
class GCPhase { |
|
35204 | 44 |
public: |
45 |
enum PhaseType { |
|
46 |
PausePhaseType = 0, |
|
47 |
ConcurrentPhaseType = 1 |
|
48 |
}; |
|
49 |
||
50 |
private: |
|
18025 | 51 |
const char* _name; |
52 |
int _level; |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
53 |
Ticks _start; |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
54 |
Ticks _end; |
35204 | 55 |
PhaseType _type; |
18025 | 56 |
|
57 |
public: |
|
58 |
void set_name(const char* name) { _name = name; } |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
59 |
const char* name() const { return _name; } |
18025 | 60 |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
61 |
int level() const { return _level; } |
18025 | 62 |
void set_level(int level) { _level = level; } |
63 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
64 |
const Ticks start() const { return _start; } |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
65 |
void set_start(const Ticks& time) { _start = time; } |
18025 | 66 |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
67 |
const Ticks end() const { return _end; } |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
68 |
void set_end(const Ticks& time) { _end = time; } |
18025 | 69 |
|
35204 | 70 |
PhaseType type() const { return _type; } |
71 |
void set_type(PhaseType type) { _type = type; } |
|
18025 | 72 |
|
73 |
void accept(PhaseVisitor* visitor) { |
|
74 |
visitor->visit(this); |
|
75 |
} |
|
76 |
}; |
|
77 |
||
78 |
class PhasesStack { |
|
79 |
public: |
|
46795
623a5e42deb6
8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
35529
diff
changeset
|
80 |
// Set to 6, since Reference processing needs it. |
623a5e42deb6
8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
35529
diff
changeset
|
81 |
static const int PHASE_LEVELS = 6; |
18025 | 82 |
|
83 |
private: |
|
84 |
int _phase_indices[PHASE_LEVELS]; |
|
85 |
int _next_phase_level; |
|
86 |
||
87 |
public: |
|
88 |
PhasesStack() { clear(); } |
|
89 |
void clear(); |
|
90 |
||
91 |
void push(int phase_index); |
|
92 |
int pop(); |
|
93 |
int count() const; |
|
94 |
}; |
|
95 |
||
96 |
class TimePartitions { |
|
97 |
static const int INITIAL_CAPACITY = 10; |
|
98 |
||
35204 | 99 |
GrowableArray<GCPhase>* _phases; |
18025 | 100 |
PhasesStack _active_phases; |
101 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
102 |
Tickspan _sum_of_pauses; |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
103 |
Tickspan _longest_pause; |
18025 | 104 |
|
105 |
public: |
|
106 |
TimePartitions(); |
|
107 |
~TimePartitions(); |
|
108 |
void clear(); |
|
109 |
||
35204 | 110 |
void report_gc_phase_start(const char* name, const Ticks& time, GCPhase::PhaseType type=GCPhase::PausePhaseType); |
111 |
void report_gc_phase_end(const Ticks& time, GCPhase::PhaseType type=GCPhase::PausePhaseType); |
|
18025 | 112 |
|
113 |
int num_phases() const; |
|
114 |
GCPhase* phase_at(int index) const; |
|
115 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
116 |
const Tickspan sum_of_pauses() const { return _sum_of_pauses; } |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
117 |
const Tickspan longest_pause() const { return _longest_pause; } |
18025 | 118 |
|
119 |
bool has_active_phases(); |
|
35204 | 120 |
|
18025 | 121 |
private: |
122 |
void update_statistics(GCPhase* phase); |
|
123 |
}; |
|
124 |
||
125 |
class PhasesIterator { |
|
126 |
public: |
|
127 |
virtual bool has_next() = 0; |
|
128 |
virtual GCPhase* next() = 0; |
|
129 |
}; |
|
130 |
||
131 |
class GCTimer : public ResourceObj { |
|
132 |
NOT_PRODUCT(friend class GCTimerTest;) |
|
133 |
protected: |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
134 |
Ticks _gc_start; |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
135 |
Ticks _gc_end; |
18025 | 136 |
TimePartitions _time_partitions; |
137 |
||
138 |
public: |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
139 |
virtual void register_gc_start(const Ticks& time = Ticks::now()); |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
140 |
virtual void register_gc_end(const Ticks& time = Ticks::now()); |
18025 | 141 |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
142 |
void register_gc_phase_start(const char* name, const Ticks& time); |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
143 |
void register_gc_phase_end(const Ticks& time); |
18025 | 144 |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
145 |
const Ticks gc_start() const { return _gc_start; } |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
146 |
const Ticks gc_end() const { return _gc_end; } |
18025 | 147 |
|
148 |
TimePartitions* time_partitions() { return &_time_partitions; } |
|
149 |
||
150 |
protected: |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
151 |
void register_gc_pause_start(const char* name, const Ticks& time = Ticks::now()); |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
152 |
void register_gc_pause_end(const Ticks& time = Ticks::now()); |
18025 | 153 |
}; |
154 |
||
155 |
class STWGCTimer : public GCTimer { |
|
156 |
public: |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
157 |
virtual void register_gc_start(const Ticks& time = Ticks::now()); |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
158 |
virtual void register_gc_end(const Ticks& time = Ticks::now()); |
18025 | 159 |
}; |
160 |
||
161 |
class ConcurrentGCTimer : public GCTimer { |
|
35204 | 162 |
// ConcurrentGCTimer can't be used if there is an overlap between a pause phase and a concurrent phase. |
163 |
// _is_concurrent_phase_active is used to find above case. |
|
164 |
bool _is_concurrent_phase_active; |
|
165 |
||
18025 | 166 |
public: |
35204 | 167 |
ConcurrentGCTimer(): GCTimer(), _is_concurrent_phase_active(false) {}; |
168 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
169 |
void register_gc_pause_start(const char* name); |
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18025
diff
changeset
|
170 |
void register_gc_pause_end(); |
35204 | 171 |
|
172 |
void register_gc_concurrent_start(const char* name, const Ticks& time = Ticks::now()); |
|
173 |
void register_gc_concurrent_end(const Ticks& time = Ticks::now()); |
|
18025 | 174 |
}; |
175 |
||
176 |
class TimePartitionPhasesIterator { |
|
177 |
TimePartitions* _time_partitions; |
|
178 |
int _next; |
|
179 |
||
180 |
public: |
|
181 |
TimePartitionPhasesIterator(TimePartitions* time_partitions) : _time_partitions(time_partitions), _next(0) { } |
|
182 |
||
183 |
virtual bool has_next(); |
|
184 |
virtual GCPhase* next(); |
|
185 |
}; |
|
186 |
||
30764 | 187 |
#endif // SHARE_VM_GC_SHARED_GCTIMER_HPP |