bpo-33608: Revert "Factor out a private, per-interpreter _Py_AddPendi… · python/cpython@b75b1a3 (original) (raw)

11 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ PyAPI_FUNC(Py_ssize_t) _PyEval_RequestCodeExtraIndex(freefunc);
221 221 #ifndef Py_LIMITED_API
222 222 PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
223 223 PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
224 -PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyInterpreterState *);
224 +PyAPI_FUNC(void) _PyEval_SignalAsyncExc(void);
225 225 #endif
226 226
227 227 /* Masks and values used by FORMAT_VALUE opcode. */
Original file line number Diff line number Diff line change
@@ -11,11 +11,7 @@ extern "C" {
11 11 #include "pycore_atomic.h"
12 12 #include "pythread.h"
13 13
14 -struct _is; // See PyInterpreterState in cpython/pystate.h.
15 -
16 -PyAPI_FUNC(int) _Py_AddPendingCall(struct _is*, unsigned long, int (*)(void *), void *);
17 -PyAPI_FUNC(int) _Py_MakePendingCalls(struct _is*);
18 -PyAPI_FUNC(void) _Py_FinishPendingCalls(struct _is*);
14 +PyAPI_FUNC(void) _Py_FinishPendingCalls(void);
19 15
20 16 struct _pending_calls {
21 17 int finishing;
@@ -28,21 +24,13 @@ struct _pending_calls {
28 24 int async_exc;
29 25 #define NPENDINGCALLS 32
30 26 struct {
31 -unsigned long thread_id;
32 27 int (*func)(void *);
33 28 void *arg;
34 29 } calls[NPENDINGCALLS];
35 30 int first;
36 31 int last;
37 32 };
38 33
39 -struct _ceval_interpreter_state {
40 -/* This single variable consolidates all requests to break out of
41 - the fast path in the eval loop. */
42 -_Py_atomic_int eval_breaker;
43 -struct _pending_calls pending;
44 -};
45 -
46 34 #include "pycore_gil.h"
47 35
48 36 struct _ceval_runtime_state {
@@ -53,8 +41,12 @@ struct _ceval_runtime_state {
53 41 c_tracefunc. This speeds up the if statement in
54 42 PyEval_EvalFrameEx() after fast_next_opcode. */
55 43 int tracing_possible;
44 +/* This single variable consolidates all requests to break out of
45 + the fast path in the eval loop. */
46 +_Py_atomic_int eval_breaker;
56 47 /* Request for dropping the GIL */
57 48 _Py_atomic_int gil_drop_request;
49 +struct _pending_calls pending;
58 50 /* Request for checking signals. */
59 51 _Py_atomic_int signals_pending;
60 52 struct _gil_runtime_state gil;
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ extern "C" {
12 12 #include "pystate.h"
13 13 #include "pythread.h"
14 14
15 -#include "pycore_atomic.h"
16 15 #include "pycore_ceval.h"
17 16 #include "pycore_pathconfig.h"
18 17 #include "pycore_pymem.h"
@@ -84,8 +83,6 @@ struct _is {
84 83 PyObject *pyexitmodule;
85 84
86 85 uint64_t tstate_next_unique_id;
87 -
88 -struct _ceval_interpreter_state ceval;
89 86 };
90 87
91 88 PyAPI_FUNC(struct _is*) _PyInterpreterState_LookUpID(PY_INT64_T);
Original file line number Diff line number Diff line change
@@ -373,7 +373,7 @@ def pendingcalls_wait(self, l, n, context = None):
373 373 def test_pendingcalls_threaded(self):
374 374
375 375 #do every callback on a separate thread
376 -n = 32 #total callbacks (see NPENDINGCALLS in pycore_ceval.h)
376 +n = 32 #total callbacks
377 377 threads = []
378 378 class foo(object):pass
379 379 context = foo()
Original file line number Diff line number Diff line change
@@ -2445,7 +2445,6 @@ pending_threadfunc(PyObject *self, PyObject *arg)
2445 2445 Py_INCREF(callable);
2446 2446
2447 2447 Py_BEGIN_ALLOW_THREADS
2448 -/* XXX Use the internal _Py_AddPendingCall(). */
2449 2448 r = Py_AddPendingCall(&_pending_callback, callable);
2450 2449 Py_END_ALLOW_THREADS
2451 2450
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@
19 19 #include <process.h>
20 20 #endif
21 21 #endif
22 -#include "internal/pycore_pystate.h"
23 22
24 23 #ifdef HAVE_SIGNAL_H
25 24 #include <signal.h>
@@ -296,10 +295,8 @@ trip_signal(int sig_num)
296 295 {
297 296 /* Py_AddPendingCall() isn't signal-safe, but we
298 297 still use it for this exceptional case. */
299 -_Py_AddPendingCall(_PyRuntime.interpreters.main,
300 -main_thread,
301 -report_wakeup_send_error,
302 - (void *)(intptr_t) last_error);
298 +Py_AddPendingCall(report_wakeup_send_error,
299 + (void *)(intptr_t) last_error);
303 300 }
304 301 }
305 302 }
@@ -316,10 +313,8 @@ trip_signal(int sig_num)
316 313 {
317 314 /* Py_AddPendingCall() isn't signal-safe, but we
318 315 still use it for this exceptional case. */
319 -_Py_AddPendingCall(_PyRuntime.interpreters.main,
320 -main_thread,
321 -report_wakeup_write_error,
322 - (void *)(intptr_t)errno);
316 +Py_AddPendingCall(report_wakeup_write_error,
317 + (void *)(intptr_t)errno);
323 318 }
324 319 }
325 320 }