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