mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
GH-104580: Don't cache eval breaker in interpreter (GH-104581)
Move eval-breaker to the front of the interpreter state.
This commit is contained in:
parent
662aede68b
commit
68b5f08b72
6 changed files with 260 additions and 262 deletions
|
@ -81,14 +81,14 @@ struct _pending_calls {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ceval_state {
|
struct _ceval_state {
|
||||||
int recursion_limit;
|
|
||||||
struct _gil_runtime_state *gil;
|
|
||||||
int own_gil;
|
|
||||||
/* This single variable consolidates all requests to break out of
|
/* This single variable consolidates all requests to break out of
|
||||||
the fast path in the eval loop. */
|
the fast path in the eval loop. */
|
||||||
_Py_atomic_int eval_breaker;
|
_Py_atomic_int eval_breaker;
|
||||||
/* Request for dropping the GIL */
|
/* Request for dropping the GIL */
|
||||||
_Py_atomic_int gil_drop_request;
|
_Py_atomic_int gil_drop_request;
|
||||||
|
int recursion_limit;
|
||||||
|
struct _gil_runtime_state *gil;
|
||||||
|
int own_gil;
|
||||||
/* The GC is ready to be executed */
|
/* The GC is ready to be executed */
|
||||||
_Py_atomic_int gc_scheduled;
|
_Py_atomic_int gc_scheduled;
|
||||||
struct _pending_calls pending;
|
struct _pending_calls pending;
|
||||||
|
|
|
@ -48,6 +48,7 @@ struct _Py_long_state {
|
||||||
*/
|
*/
|
||||||
struct _is {
|
struct _is {
|
||||||
|
|
||||||
|
struct _ceval_state ceval;
|
||||||
PyInterpreterState *next;
|
PyInterpreterState *next;
|
||||||
|
|
||||||
uint64_t monitoring_version;
|
uint64_t monitoring_version;
|
||||||
|
@ -92,7 +93,6 @@ struct _is {
|
||||||
|
|
||||||
struct _obmalloc_state obmalloc;
|
struct _obmalloc_state obmalloc;
|
||||||
|
|
||||||
struct _ceval_state ceval;
|
|
||||||
struct _gc_runtime_state gc;
|
struct _gc_runtime_state gc;
|
||||||
|
|
||||||
struct _import_state imports;
|
struct _import_state imports;
|
||||||
|
|
|
@ -70,7 +70,6 @@ dummy_func(
|
||||||
_PyInterpreterFrame *frame,
|
_PyInterpreterFrame *frame,
|
||||||
unsigned char opcode,
|
unsigned char opcode,
|
||||||
unsigned int oparg,
|
unsigned int oparg,
|
||||||
_Py_atomic_int * const eval_breaker,
|
|
||||||
_PyCFrame cframe,
|
_PyCFrame cframe,
|
||||||
_Py_CODEUNIT *next_instr,
|
_Py_CODEUNIT *next_instr,
|
||||||
PyObject **stack_pointer,
|
PyObject **stack_pointer,
|
||||||
|
@ -143,7 +142,7 @@ dummy_func(
|
||||||
ERROR_IF(err, error);
|
ERROR_IF(err, error);
|
||||||
next_instr--;
|
next_instr--;
|
||||||
}
|
}
|
||||||
else if (_Py_atomic_load_relaxed_int32(eval_breaker) && oparg < 2) {
|
else if (_Py_atomic_load_relaxed_int32(&tstate->interp->ceval.eval_breaker) && oparg < 2) {
|
||||||
goto handle_eval_breaker;
|
goto handle_eval_breaker;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +169,7 @@ dummy_func(
|
||||||
next_instr = frame->prev_instr;
|
next_instr = frame->prev_instr;
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
}
|
}
|
||||||
if (_Py_atomic_load_relaxed_int32(eval_breaker) && oparg < 2) {
|
if (_Py_atomic_load_relaxed_int32(&tstate->interp->ceval.eval_breaker) && oparg < 2) {
|
||||||
goto handle_eval_breaker;
|
goto handle_eval_breaker;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -652,7 +652,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
|
||||||
// for the big switch below (in combination with the EXTRA_CASES macro).
|
// for the big switch below (in combination with the EXTRA_CASES macro).
|
||||||
uint8_t opcode; /* Current opcode */
|
uint8_t opcode; /* Current opcode */
|
||||||
int oparg; /* Current opcode argument, if any */
|
int oparg; /* Current opcode argument, if any */
|
||||||
_Py_atomic_int * const eval_breaker = &tstate->interp->ceval.eval_breaker;
|
|
||||||
#ifdef LLTRACE
|
#ifdef LLTRACE
|
||||||
int lltrace = 0;
|
int lltrace = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
|
|
||||||
#define CHECK_EVAL_BREAKER() \
|
#define CHECK_EVAL_BREAKER() \
|
||||||
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY(); \
|
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY(); \
|
||||||
if (_Py_atomic_load_relaxed_int32(eval_breaker)) { \
|
if (_Py_atomic_load_relaxed_int32(&tstate->interp->ceval.eval_breaker)) { \
|
||||||
goto handle_eval_breaker; \
|
goto handle_eval_breaker; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
506
Python/generated_cases.c.h
generated
506
Python/generated_cases.c.h
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue