@@ -156,9 +156,6 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
156156
157157 public final Assumption singleContextAssumption = Truffle .getRuntime ().createAssumption ("Only a single context is active" );
158158
159- @ CompilationFinal public boolean singleContext = true ;
160- private boolean firstContextInitialized ;
161-
162159 /**
163160 * This assumption will be valid if all contexts are single-threaded. Hence, it will be
164161 * invalidated as soon as at least one context has been initialized for multi-threading.
@@ -271,16 +268,12 @@ protected void finalizeContext(PythonContext context) {
271268
272269 @ Override
273270 protected boolean areOptionsCompatible (OptionValues firstOptions , OptionValues newOptions ) {
274- if (singleContext ) {
275- return false ;
276- }
277271 return PythonOptions .areOptionsCompatible (firstOptions , newOptions );
278272 }
279273
280274 @ Override
281275 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 ())) {
284277 Python3Core .writeInfo ("Cannot use preinitialized context." );
285278 return false ;
286279 }
@@ -309,7 +302,6 @@ protected PythonContext createContext(Env env) {
309302 } else {
310303 assert areOptionsCompatible (options , PythonOptions .createEngineOptions (env )) : "invalid engine options" ;
311304 }
312- firstContextInitialized = true ;
313305 return context ;
314306 }
315307
@@ -709,14 +701,6 @@ private static Source newSource(PythonContext ctxt, SourceBuilder srcBuilder) th
709701 @ Override
710702 protected void initializeMultipleContexts () {
711703 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 ;
720704 singleContextAssumption .invalidate ();
721705 }
722706
0 commit comments