Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/shared/gcTimer.hpp @ 20501:c204e2044c29
8038624: interpretedVFrame::expressions() must respect InterpreterOopMap for liveness
Reviewed-by: coleenp, minqi
author | mgronlun |
---|---|
date | Mon, 29 Sep 2014 13:12:48 +0200 |
parents | 86e6d691f2e1 |
children |
rev | line source |
---|---|
10405 | 1 /* |
2 * Copyright (c) 2012, 2013, 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_VM_GC_IMPLEMENTATION_SHARED_GCTIMER_HPP | |
26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTIMER_HPP | |
27 | |
28 #include "memory/allocation.hpp" | |
29 #include "prims/jni_md.h" | |
30 #include "utilities/macros.hpp" | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
31 #include "utilities/ticks.hpp" |
10405 | 32 |
33 class ConcurrentPhase; | |
34 class GCPhase; | |
35 class PausePhase; | |
36 | |
37 template <class E> class GrowableArray; | |
38 | |
39 class PhaseVisitor { | |
40 public: | |
41 virtual void visit(GCPhase* phase) = 0; | |
42 virtual void visit(PausePhase* phase) { visit((GCPhase*)phase); } | |
43 virtual void visit(ConcurrentPhase* phase) { visit((GCPhase*)phase); } | |
44 }; | |
45 | |
46 class GCPhase { | |
47 const char* _name; | |
48 int _level; | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
49 Ticks _start; |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
50 Ticks _end; |
10405 | 51 |
52 public: | |
53 void set_name(const char* name) { _name = name; } | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
54 const char* name() const { return _name; } |
10405 | 55 |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
56 int level() const { return _level; } |
10405 | 57 void set_level(int level) { _level = level; } |
58 | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
59 const Ticks start() const { return _start; } |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
60 void set_start(const Ticks& time) { _start = time; } |
10405 | 61 |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
62 const Ticks end() const { return _end; } |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
63 void set_end(const Ticks& time) { _end = time; } |
10405 | 64 |
65 virtual void accept(PhaseVisitor* visitor) = 0; | |
66 }; | |
67 | |
68 class PausePhase : public GCPhase { | |
69 public: | |
70 void accept(PhaseVisitor* visitor) { | |
71 visitor->visit(this); | |
72 } | |
73 }; | |
74 | |
75 class ConcurrentPhase : public GCPhase { | |
76 void accept(PhaseVisitor* visitor) { | |
77 visitor->visit(this); | |
78 } | |
79 }; | |
80 | |
81 class PhasesStack { | |
82 public: | |
83 // FIXME: Temporary set to 5 (used to be 4), since Reference processing needs it. | |
84 static const int PHASE_LEVELS = 5; | |
85 | |
86 private: | |
87 int _phase_indices[PHASE_LEVELS]; | |
88 int _next_phase_level; | |
89 | |
90 public: | |
91 PhasesStack() { clear(); } | |
92 void clear(); | |
93 | |
94 void push(int phase_index); | |
95 int pop(); | |
96 int count() const; | |
97 }; | |
98 | |
99 class TimePartitions { | |
100 static const int INITIAL_CAPACITY = 10; | |
101 | |
102 // Currently we only support pause phases. | |
103 GrowableArray<PausePhase>* _phases; | |
104 PhasesStack _active_phases; | |
105 | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
106 Tickspan _sum_of_pauses; |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
107 Tickspan _longest_pause; |
10405 | 108 |
109 public: | |
110 TimePartitions(); | |
111 ~TimePartitions(); | |
112 void clear(); | |
113 | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
114 void report_gc_phase_start(const char* name, const Ticks& time); |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
115 void report_gc_phase_end(const Ticks& time); |
10405 | 116 |
117 int num_phases() const; | |
118 GCPhase* phase_at(int index) const; | |
119 | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
120 const Tickspan sum_of_pauses() const { return _sum_of_pauses; } |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
121 const Tickspan longest_pause() const { return _longest_pause; } |
10405 | 122 |
123 bool has_active_phases(); | |
124 private: | |
125 void update_statistics(GCPhase* phase); | |
126 }; | |
127 | |
128 class PhasesIterator { | |
129 public: | |
130 virtual bool has_next() = 0; | |
131 virtual GCPhase* next() = 0; | |
132 }; | |
133 | |
134 class GCTimer : public ResourceObj { | |
135 NOT_PRODUCT(friend class GCTimerTest;) | |
136 protected: | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
137 Ticks _gc_start; |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
138 Ticks _gc_end; |
10405 | 139 TimePartitions _time_partitions; |
140 | |
141 public: | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
142 virtual void register_gc_start(const Ticks& time = Ticks::now()); |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
143 virtual void register_gc_end(const Ticks& time = Ticks::now()); |
10405 | 144 |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
145 void register_gc_phase_start(const char* name, const Ticks& time); |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
146 void register_gc_phase_end(const Ticks& time); |
10405 | 147 |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
148 const Ticks gc_start() const { return _gc_start; } |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
149 const Ticks gc_end() const { return _gc_end; } |
10405 | 150 |
151 TimePartitions* time_partitions() { return &_time_partitions; } | |
152 | |
153 protected: | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
154 void register_gc_pause_start(const char* name, const Ticks& time = Ticks::now()); |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
155 void register_gc_pause_end(const Ticks& time = Ticks::now()); |
10405 | 156 }; |
157 | |
158 class STWGCTimer : public GCTimer { | |
159 public: | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
160 virtual void register_gc_start(const Ticks& time = Ticks::now()); |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
161 virtual void register_gc_end(const Ticks& time = Ticks::now()); |
10405 | 162 }; |
163 | |
164 class ConcurrentGCTimer : public GCTimer { | |
165 public: | |
13400
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
166 void register_gc_pause_start(const char* name); |
86e6d691f2e1
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
10405
diff
changeset
|
167 void register_gc_pause_end(); |
10405 | 168 }; |
169 | |
170 class TimePartitionPhasesIterator { | |
171 TimePartitions* _time_partitions; | |
172 int _next; | |
173 | |
174 public: | |
175 TimePartitionPhasesIterator(TimePartitions* time_partitions) : _time_partitions(time_partitions), _next(0) { } | |
176 | |
177 virtual bool has_next(); | |
178 virtual GCPhase* next(); | |
179 }; | |
180 | |
181 | |
182 /////////////// Unit tests /////////////// | |
183 | |
184 #ifndef PRODUCT | |
185 | |
186 class GCTimerAllTest { | |
187 public: | |
188 static void all(); | |
189 }; | |
190 | |
191 #endif | |
192 | |
193 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTIMER_HPP |