@@ -250,21 +250,6 @@ ensure_tstate_not_null(const char *func, PyThreadState *tstate)
250
250
}
251
251
252
252
253
- #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
254
- int
255
- _PyEval_ThreadsInitialized (PyInterpreterState * interp )
256
- {
257
- return gil_created (& interp -> ceval .gil );
258
- }
259
-
260
- int
261
- PyEval_ThreadsInitialized (void )
262
- {
263
- // Fatal error if there is no current interpreter
264
- PyInterpreterState * interp = PyInterpreterState_Get ();
265
- return _PyEval_ThreadsInitialized (interp );
266
- }
267
- #else
268
253
int
269
254
_PyEval_ThreadsInitialized (_PyRuntimeState * runtime )
270
255
{
@@ -277,25 +262,18 @@ PyEval_ThreadsInitialized(void)
277
262
_PyRuntimeState * runtime = & _PyRuntime ;
278
263
return _PyEval_ThreadsInitialized (runtime );
279
264
}
280
- #endif
281
265
282
266
PyStatus
283
267
_PyEval_InitGIL (PyThreadState * tstate )
284
268
{
285
- #ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
286
269
if (!_Py_IsMainInterpreter (tstate )) {
287
270
/* Currently, the GIL is shared by all interpreters,
288
271
and only the main interpreter is responsible to create
289
272
and destroy it. */
290
273
return _PyStatus_OK ();
291
274
}
292
- #endif
293
275
294
- #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
295
- struct _gil_runtime_state * gil = & tstate -> interp -> ceval .gil ;
296
- #else
297
276
struct _gil_runtime_state * gil = & tstate -> interp -> runtime -> ceval .gil ;
298
- #endif
299
277
assert (!gil_created (gil ));
300
278
301
279
PyThread_init_thread ();
@@ -310,20 +288,14 @@ _PyEval_InitGIL(PyThreadState *tstate)
310
288
void
311
289
_PyEval_FiniGIL (PyThreadState * tstate )
312
290
{
313
- #ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
314
291
if (!_Py_IsMainInterpreter (tstate )) {
315
292
/* Currently, the GIL is shared by all interpreters,
316
293
and only the main interpreter is responsible to create
317
294
and destroy it. */
318
295
return ;
319
296
}
320
- #endif
321
297
322
- #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
323
- struct _gil_runtime_state * gil = & tstate -> interp -> ceval .gil ;
324
- #else
325
298
struct _gil_runtime_state * gil = & tstate -> interp -> runtime -> ceval .gil ;
326
- #endif
327
299
if (!gil_created (gil )) {
328
300
/* First Py_InitializeFromConfig() call: the GIL doesn't exist
329
301
yet: do nothing. */
@@ -408,13 +380,9 @@ PyEval_AcquireThread(PyThreadState *tstate)
408
380
take_gil (tstate );
409
381
410
382
struct _gilstate_runtime_state * gilstate = & tstate -> interp -> runtime -> gilstate ;
411
- #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
412
- (void )_PyThreadState_Swap (gilstate , tstate );
413
- #else
414
383
if (_PyThreadState_Swap (gilstate , tstate ) != NULL ) {
415
384
Py_FatalError ("non-NULL old thread state" );
416
385
}
417
- #endif
418
386
}
419
387
420
388
void
@@ -444,11 +412,7 @@ _PyEval_ReInitThreads(_PyRuntimeState *runtime)
444
412
PyThreadState * tstate = _PyRuntimeState_GetThreadState (runtime );
445
413
ensure_tstate_not_null (__func__ , tstate );
446
414
447
- #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
448
- struct _gil_runtime_state * gil = & tstate -> interp -> ceval .gil ;
449
- #else
450
415
struct _gil_runtime_state * gil = & runtime -> ceval .gil ;
451
- #endif
452
416
if (!gil_created (gil )) {
453
417
return ;
454
418
}
@@ -480,21 +444,12 @@ PyThreadState *
480
444
PyEval_SaveThread (void )
481
445
{
482
446
_PyRuntimeState * runtime = & _PyRuntime ;
483
- #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
484
- PyThreadState * old_tstate = _PyThreadState_GET ();
485
- PyThreadState * tstate = _PyThreadState_Swap (& runtime -> gilstate , old_tstate );
486
- #else
487
447
PyThreadState * tstate = _PyThreadState_Swap (& runtime -> gilstate , NULL );
488
- #endif
489
448
ensure_tstate_not_null (__func__ , tstate );
490
449
491
450
struct _ceval_runtime_state * ceval = & runtime -> ceval ;
492
451
struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
493
- #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
494
- assert (gil_created (& ceval2 -> gil ));
495
- #else
496
452
assert (gil_created (& ceval -> gil ));
497
- #endif
498
453
drop_gil (ceval , ceval2 , tstate );
499
454
return tstate ;
500
455
}
753
708
_PyEval_InitRuntimeState (struct _ceval_runtime_state * ceval )
754
709
{
755
710
_Py_CheckRecursionLimit = Py_DEFAULT_RECURSION_LIMIT ;
756
- #ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
757
711
_gil_initialize (& ceval -> gil );
758
- #endif
759
712
}
760
713
761
714
int
@@ -771,10 +724,6 @@ _PyEval_InitState(struct _ceval_state *ceval)
771
724
return -1 ;
772
725
}
773
726
774
- #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
775
- _gil_initialize (& ceval -> gil );
776
- #endif
777
-
778
727
return 0 ;
779
728
}
780
729
@@ -919,13 +868,9 @@ eval_frame_handle_pending(PyThreadState *tstate)
919
868
920
869
take_gil (tstate );
921
870
922
- #ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
923
- (void )_PyThreadState_Swap (& runtime -> gilstate , tstate );
924
- #else
925
871
if (_PyThreadState_Swap (& runtime -> gilstate , tstate ) != NULL ) {
926
872
Py_FatalError ("orphan tstate" );
927
873
}
928
- #endif
929
874
}
930
875
931
876
/* Check for asynchronous exception. */
0 commit comments