@@ -156,9 +156,6 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
156
156
157
157
public final Assumption singleContextAssumption = Truffle .getRuntime ().createAssumption ("Only a single context is active" );
158
158
159
- @ CompilationFinal public boolean singleContext = true ;
160
- private boolean firstContextInitialized ;
161
-
162
159
/**
163
160
* This assumption will be valid if all contexts are single-threaded. Hence, it will be
164
161
* invalidated as soon as at least one context has been initialized for multi-threading.
@@ -271,16 +268,12 @@ protected void finalizeContext(PythonContext context) {
271
268
272
269
@ Override
273
270
protected boolean areOptionsCompatible (OptionValues firstOptions , OptionValues newOptions ) {
274
- if (singleContext ) {
275
- return false ;
276
- }
277
271
return PythonOptions .areOptionsCompatible (firstOptions , newOptions );
278
272
}
279
273
280
274
@ Override
281
275
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 ())) {
276
+ if (!areOptionsCompatible (context .getEnv ().getOptions (), newEnv .getOptions ())) {
284
277
Python3Core .writeInfo ("Cannot use preinitialized context." );
285
278
return false ;
286
279
}
@@ -309,7 +302,6 @@ protected PythonContext createContext(Env env) {
309
302
} else {
310
303
assert areOptionsCompatible (options , PythonOptions .createEngineOptions (env )) : "invalid engine options" ;
311
304
}
312
- firstContextInitialized = true ;
313
305
return context ;
314
306
}
315
307
@@ -709,14 +701,6 @@ private static Source newSource(PythonContext ctxt, SourceBuilder srcBuilder) th
709
701
@ Override
710
702
protected void initializeMultipleContexts () {
711
703
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 ;
720
704
singleContextAssumption .invalidate ();
721
705
}
722
706
0 commit comments