Skip to content

Commit 9f8af33

Browse files
committed
Fix initialization of the Metrics class
1 parent df10d7a commit 9f8af33

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/main/java/org/truffleruby/RubyLanguage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class RubyLanguage extends TruffleLanguage<RubyContext> {
6767
@Override
6868
public RubyContext createContext(Env env) {
6969
// We need to initialize the Metrics class of the language classloader
70-
Metrics.begin();
70+
Metrics.initializeOption();
7171

7272
LOGGER.fine("createContext()");
7373
Metrics.printTime("before-create-context");
@@ -88,7 +88,7 @@ protected void initializeContext(RubyContext context) throws Exception {
8888
@Override
8989
protected boolean patchContext(RubyContext context, Env newEnv) {
9090
// We need to initialize the Metrics class of the language classloader
91-
Metrics.begin();
91+
Metrics.initializeOption();
9292

9393
LOGGER.fine("patchContext()");
9494
Metrics.printTime("before-patch-context");

src/shared/java/org/truffleruby/shared/Metrics.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,26 @@ private static void printMemory(boolean isAOT) {
4343
}
4444
}
4545

46-
public static void end(boolean isAOT) {
47-
printTime("after-main");
48-
printMemory(isAOT);
46+
/**
47+
* Assigned here so the property is read after processing the --native.D... options. It needs to
48+
* be called in each classloader using the Metrics class.
49+
*/
50+
public static void initializeOption() {
51+
METRICS_TIME = Boolean.getBoolean("truffleruby.metrics.time");
4952
}
5053

51-
public static void begin() {
52-
// Assigned here so the property is read after processing the --native.D... options
53-
METRICS_TIME = Boolean.getBoolean("truffleruby.metrics.time");
54+
public static boolean getMetricsTime() {
55+
return METRICS_TIME;
56+
}
5457

58+
public static void begin() {
59+
initializeOption();
5560
printTime("before-main");
5661
}
5762

58-
public static boolean getMetricsTime() {
59-
return METRICS_TIME;
63+
public static void end(boolean isAOT) {
64+
printTime("after-main");
65+
printMemory(isAOT);
6066
}
67+
6168
}

0 commit comments

Comments
 (0)