Skip to content

Commit 579c737

Browse files
hicham-amazighelkorchi
authored andcommitted
Adapt fix
1 parent 92a598b commit 579c737

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/util/CompilationAlarm.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import jdk.graal.compiler.options.OptionType;
3939
import jdk.graal.compiler.options.OptionValues;
4040
import jdk.graal.compiler.serviceprovider.GraalServices;
41+
import jdk.graal.compiler.serviceprovider.JMXService;
4142
import jdk.vm.ci.meta.ResolvedJavaMethod;
4243

4344
/**
@@ -73,6 +74,11 @@ public static class Options {
7374
private CompilationAlarm(double period) {
7475
this.previous = currentAlarm.get();
7576
reset(period);
77+
JMXService.GCTimeStatistics timing = null;
78+
if (period != 0) {
79+
timing = GraalServices.getGCTimeStatistics();
80+
}
81+
this.gcTiming = timing;
7682
}
7783

7884
/**
@@ -216,6 +222,11 @@ public void close() {
216222
*/
217223
private long expirationNS;
218224

225+
/**
226+
* Time spent in the garbage collector if it's available.
227+
*/
228+
private final JMXService.GCTimeStatistics gcTiming;
229+
219230
/**
220231
* Signal the execution of the phase identified by {@code name} starts.
221232
*/

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/debug/BaseTimerKey.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public TimeUnit getTimeUnit() {
4848
return accm.getTimeUnit();
4949
}
5050

51+
@Override
52+
public void add(DebugContext debug, long value, TimeUnit units) {
53+
accm.add(debug, value, units);
54+
}
55+
5156
@Override
5257
public DebugCloseable start(DebugContext debug) {
5358
return accm.start(debug);
@@ -90,6 +95,13 @@ public DebugCloseable start(DebugContext debug) {
9095
}
9196
}
9297

98+
@Override
99+
public void add(DebugContext debug, long value, TimeUnit units) {
100+
if (debug.isTimerEnabled(this)) {
101+
addToCurrentValue(debug, getTimeUnit().convert(value, units));
102+
}
103+
}
104+
93105
@Override
94106
public TimerKey getFlat() {
95107
return (FlatTimer) flat;

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/debug/DebugContext.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ static final class Immutable {
203203

204204
final boolean listMetrics;
205205

206+
/**
207+
* Names of counters. A counter is active if this set is empty or contains the counter's
208+
* name.
209+
*/
210+
final EconomicSet<String> counters;
211+
212+
/**
213+
* Names of timers. A timer is active if this set is empty or contains the timer's name.
214+
*/
215+
final EconomicSet<String> timers;
216+
206217
/**
207218
* Names of unscoped counters. A counter is unscoped if this set is empty or contains the
208219
* counter's name.
@@ -221,6 +232,25 @@ static final class Immutable {
221232
*/
222233
final EconomicSet<String> unscopedMemUseTrackers;
223234

235+
private static EconomicSet<String> parseMetricSpec(String spec, boolean accumulatedKey) {
236+
if (spec == null) {
237+
return null;
238+
} else if (spec.isEmpty()) {
239+
return EconomicSet.emptySet();
240+
} else {
241+
EconomicSet<String> res = EconomicSet.create();
242+
if (!accumulatedKey) {
243+
res.addAll(Arrays.asList(spec.split(",")));
244+
} else {
245+
for (String n : spec.split(",")) {
246+
res.add(n + AccumulatedKey.ACCUMULATED_KEY_SUFFIX);
247+
res.add(n + AccumulatedKey.FLAT_KEY_SUFFIX);
248+
}
249+
}
250+
return res;
251+
}
252+
}
253+
224254
private static EconomicSet<String> parseUnscopedMetricSpec(String spec, boolean unconditional, boolean accumulatedKey) {
225255
EconomicSet<String> res;
226256
if (spec == null) {
@@ -271,6 +301,8 @@ private static boolean isNotEmpty(OptionKey<String> option, OptionValues options
271301

272302
private Immutable(OptionValues options) {
273303
this.options = options;
304+
this.counters = parseMetricSpec(DebugOptions.Counters.getValue(options), false);
305+
this.timers = parseMetricSpec(DebugOptions.Timers.getValue(options), true);
274306
String timeValue = DebugOptions.Time.getValue(options);
275307
String trackMemUseValue = DebugOptions.TrackMemUse.getValue(options);
276308
this.unscopedCounters = parseUnscopedMetricSpec(DebugOptions.Counters.getValue(options), "".equals(DebugOptions.Count.getValue(options)), false);
@@ -300,6 +332,8 @@ private Immutable() {
300332
this.unscopedMemUseTrackers = null;
301333
this.scopesEnabled = false;
302334
this.listMetrics = false;
335+
this.counters = null;
336+
this.timers = null;
303337
}
304338

305339
public boolean hasUnscopedMetrics() {
@@ -754,6 +788,14 @@ public boolean isDumpEnabled(int dumpLevel) {
754788
return currentScope != null && currentScope.isDumpEnabled(dumpLevel);
755789
}
756790

791+
public boolean areCountersEnabled() {
792+
return immutable.counters != null;
793+
}
794+
795+
public boolean areTimersEnabled() {
796+
return immutable.timers != null;
797+
}
798+
757799
/**
758800
* Determines if verification is enabled in the current scope.
759801
*

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/debug/TimerKey.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public interface TimerKey extends MetricKey {
5151
*/
5252
long getCurrentValue(DebugContext debug);
5353

54+
/**
55+
* Adds {@code value} to this timer.
56+
*/
57+
void add(DebugContext debug, long value, TimeUnit units);
58+
5459
/**
5560
* Gets the time unit of this timer.
5661
*/

0 commit comments

Comments
 (0)