#include "pycore_pystate.h" /* PyInterpreterState.eval_frame */
-PyAPI_FUNC(void) _Py_FinishPendingCalls(PyThreadState *tstate);
-PyAPI_FUNC(void) _PyEval_Initialize(struct _ceval_runtime_state *);
-PyAPI_FUNC(void) _PyEval_FiniThreads(
+extern void _Py_FinishPendingCalls(PyThreadState *tstate);
+extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *);
+extern void _PyEval_InitState(struct _ceval_state *);
+extern void _PyEval_FiniThreads(
struct _ceval_runtime_state *ceval);
PyAPI_FUNC(void) _PyEval_SignalReceived(
struct _ceval_runtime_state *ceval);
struct _ceval_runtime_state {
int recursion_limit;
- /* Records whether tracing is on for any thread. Counts the number
- of threads for which tstate->c_tracefunc is non-NULL, so if the
- value is 0, we know we don't have to check this thread's
- c_tracefunc. This speeds up the if statement in
- PyEval_EvalFrameEx() after fast_next_opcode. */
- int tracing_possible;
/* This single variable consolidates all requests to break out of
the fast path in the eval loop. */
_Py_atomic_int eval_breaker;
struct _gil_runtime_state gil;
};
+struct _ceval_state {
+ /* Records whether tracing is on for any thread. Counts the number
+ of threads for which tstate->c_tracefunc is non-NULL, so if the
+ value is 0, we know we don't have to check this thread's
+ c_tracefunc. This speeds up the if statement in
+ _PyEval_EvalFrameDefault() after fast_next_opcode. */
+ int tracing_possible;
+};
+
/* interpreter state */
#define _PY_NSMALLPOSINTS 257
int finalizing;
+ struct _ceval_state ceval;
struct _gc_runtime_state gc;
PyObject *modules;
int _Py_CheckRecursionLimit = Py_DEFAULT_RECURSION_LIMIT;
void
-_PyEval_Initialize(struct _ceval_runtime_state *state)
+_PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval)
{
- state->recursion_limit = Py_DEFAULT_RECURSION_LIMIT;
+ ceval->recursion_limit = Py_DEFAULT_RECURSION_LIMIT;
_Py_CheckRecursionLimit = Py_DEFAULT_RECURSION_LIMIT;
- _gil_initialize(&state->gil);
+ _gil_initialize(&ceval->gil);
+}
+
+void
+_PyEval_InitState(struct _ceval_state *ceval)
+{
+ /* PyInterpreterState_New() initializes ceval to zero */
}
int
{
struct _ceval_runtime_state *ceval = &_PyRuntime.ceval;
ceval->recursion_limit = new_limit;
- _Py_CheckRecursionLimit = ceval->recursion_limit;
+ _Py_CheckRecursionLimit = new_limit;
}
/* The function _Py_EnterRecursiveCall() only calls _Py_CheckRecursiveCall()
PyObject *retval = NULL; /* Return value */
_PyRuntimeState * const runtime = &_PyRuntime;
struct _ceval_runtime_state * const ceval = &runtime->ceval;
+ struct _ceval_state * const ceval2 = &tstate->interp->ceval;
_Py_atomic_int * const eval_breaker = &ceval->eval_breaker;
PyCodeObject *co;
#ifdef LLTRACE
#define FAST_DISPATCH() \
{ \
- if (!lltrace && !_Py_TracingPossible(ceval) && !PyDTrace_LINE_ENABLED()) { \
+ if (!lltrace && !_Py_TracingPossible(ceval2) && !PyDTrace_LINE_ENABLED()) { \
f->f_lasti = INSTR_OFFSET(); \
NEXTOPARG(); \
goto *opcode_targets[opcode]; \
#else
#define FAST_DISPATCH() \
{ \
- if (!_Py_TracingPossible(ceval) && !PyDTrace_LINE_ENABLED()) { \
+ if (!_Py_TracingPossible(ceval2) && !PyDTrace_LINE_ENABLED()) { \
f->f_lasti = INSTR_OFFSET(); \
NEXTOPARG(); \
goto *opcode_targets[opcode]; \
/* line-by-line tracing support */
- if (_Py_TracingPossible(ceval) &&
+ if (_Py_TracingPossible(ceval2) &&
tstate->c_tracefunc != NULL && !tstate->tracing) {
int err;
/* see maybe_call_line_trace
PUSH(val);
PUSH(exc);
JUMPTO(handler);
- if (_Py_TracingPossible(ceval)) {
+ if (_Py_TracingPossible(ceval2)) {
int needs_new_execution_window = (f->f_lasti < instr_lb || f->f_lasti >= instr_ub);
int needs_line_update = (f->f_lasti == instr_lb || f->f_lasti < instr_prev);
/* Make sure that we trace line after exception if we are in a new execution
return -1;
}
- struct _ceval_runtime_state *ceval = &tstate->interp->runtime->ceval;
+ struct _ceval_state *ceval = &tstate->interp->ceval;
PyObject *traceobj = tstate->c_traceobj;
ceval->tracing_possible += (func != NULL) - (tstate->c_tracefunc != NULL);
runtime->open_code_userdata = open_code_userdata;
runtime->audit_hook_head = audit_hook_head;
- _PyEval_Initialize(&runtime->ceval);
+ _PyEval_InitRuntimeState(&runtime->ceval);
PyPreConfig_InitPythonConfig(&runtime->preconfig);
_PyRuntimeState *runtime = &_PyRuntime;
interp->runtime = runtime;
+ _PyEval_InitState(&interp->ceval);
_PyGC_InitState(&interp->gc);
PyConfig_InitPythonConfig(&interp->config);