Skip to content

Commit df31acd

Browse files
committed
Initialize PythonContext#allocationReporter eagerly
1 parent 6402e5a commit df31acd

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ public Thread getOwner() {
475475
private final ThreadLocal<ArrayDeque<String>> currentImport = new ThreadLocal<>();
476476

477477
@CompilationFinal(dimensions = 1) private Object[] optionValues;
478-
private AllocationReporter allocationReporter;
478+
private final AllocationReporter allocationReporter;
479479

480480
/*
481481
* These maps are used to ensure that each "deserialization" of code in the parser gets a
@@ -798,6 +798,7 @@ public PythonContext(PythonLanguage language, TruffleLanguage.Env env, Python3Co
798798
this.language = language;
799799
this.core = core;
800800
this.env = env;
801+
this.allocationReporter = env.lookup(AllocationReporter.class);
801802
this.childContextData = (ChildContextData) env.getConfig().get(CHILD_CONTEXT_DATA);
802803
this.sharedMultiprocessingData = this.childContextData == null ? new SharedMultiprocessingData(language.namedSemaphores) : childContextData.parentCtx.sharedMultiprocessingData;
803804
this.handler = new AsyncHandler(this);
@@ -815,9 +816,6 @@ public static PythonContext get(Node node) {
815816
}
816817

817818
public AllocationReporter getAllocationReporter() {
818-
if (allocationReporter == null) {
819-
return allocationReporter = env.lookup(AllocationReporter.class);
820-
}
821819
return allocationReporter;
822820
}
823821

0 commit comments

Comments
 (0)