Skip to content

Commit ca88a9a

Browse files
committed
Revert "Force inner contexts to have their own language instance"
This reverts commit d5ff071.
1 parent 3a358c6 commit ca88a9a

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
import com.oracle.truffle.api.object.Shape;
100100
import com.oracle.truffle.api.source.Source;
101101
import com.oracle.truffle.api.source.Source.SourceBuilder;
102+
import java.util.Map;
102103

103104
@TruffleLanguage.Registration(id = PythonLanguage.ID, //
104105
name = PythonLanguage.NAME, //
@@ -156,9 +157,6 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
156157

157158
public final Assumption singleContextAssumption = Truffle.getRuntime().createAssumption("Only a single context is active");
158159

159-
@CompilationFinal public boolean singleContext = true;
160-
private boolean firstContextInitialized;
161-
162160
/**
163161
* This assumption will be valid if all contexts are single-threaded. Hence, it will be
164162
* invalidated as soon as at least one context has been initialized for multi-threading.
@@ -271,16 +269,12 @@ protected void finalizeContext(PythonContext context) {
271269

272270
@Override
273271
protected boolean areOptionsCompatible(OptionValues firstOptions, OptionValues newOptions) {
274-
if (singleContext) {
275-
return false;
276-
}
277272
return PythonOptions.areOptionsCompatible(firstOptions, newOptions);
278273
}
279274

280275
@Override
281276
protected boolean patchContext(PythonContext context, Env newEnv) {
282-
// We intentionally bypass the singleContext check in PythonLanguage#areOptionsCompatible
283-
if (!PythonOptions.areOptionsCompatible(context.getEnv().getOptions(), newEnv.getOptions())) {
277+
if (!areOptionsCompatible(context.getEnv().getOptions(), newEnv.getOptions())) {
284278
Python3Core.writeInfo("Cannot use preinitialized context.");
285279
return false;
286280
}
@@ -309,7 +303,6 @@ protected PythonContext createContext(Env env) {
309303
} else {
310304
assert areOptionsCompatible(options, PythonOptions.createEngineOptions(env)) : "invalid engine options";
311305
}
312-
firstContextInitialized = true;
313306
return context;
314307
}
315308

@@ -709,14 +702,6 @@ private static Source newSource(PythonContext ctxt, SourceBuilder srcBuilder) th
709702
@Override
710703
protected void initializeMultipleContexts() {
711704
super.initializeMultipleContexts();
712-
// We want to make sure that initializeMultipleContexts is always called before the first
713-
// context is created.
714-
// This would not be the case with inner contexts, but we achieve that by returning false
715-
// from areOptionsCompatible when it is invoked for the first inner context, then Truffle
716-
// creates a new PythonLanguage instance, calls initializeMultipleContexts on it, and only
717-
// then uses it to create the inner contexts.
718-
assert !firstContextInitialized;
719-
singleContext = false;
720705
singleContextAssumption.invalidate();
721706
}
722707

0 commit comments

Comments
 (0)