/home/mdboom/Work/builds/cpython/Include/internal/pycore_ceval.h
Line | Count | Source |
1 | #ifndef Py_INTERNAL_CEVAL_H |
2 | #define Py_INTERNAL_CEVAL_H |
3 | #ifdef __cplusplus |
4 | extern "C" { |
5 | #endif |
6 | |
7 | #ifndef Py_BUILD_CORE |
8 | # error "this header requires Py_BUILD_CORE define" |
9 | #endif |
10 | |
11 | /* Forward declarations */ |
12 | struct pyruntimestate; |
13 | struct _ceval_runtime_state; |
14 | |
15 | /* WASI has limited call stack. Python's recursion limit depends on code |
16 | layout, optimization, and WASI runtime. Wasmtime can handle about 700-750 |
17 | recursions, sometimes less. 600 is a more conservative limit. */ |
18 | #ifndef Py_DEFAULT_RECURSION_LIMIT |
19 | # ifdef __wasi__ |
20 | # define Py_DEFAULT_RECURSION_LIMIT 600 |
21 | # else |
22 | # define Py_DEFAULT_RECURSION_LIMIT 1000 |
23 | # endif |
24 | #endif |
25 | |
26 | #include "pycore_interp.h" // PyInterpreterState.eval_frame |
27 | #include "pycore_pystate.h" // _PyThreadState_GET() |
28 | |
29 | |
30 | extern void _Py_FinishPendingCalls(PyThreadState *tstate); |
31 | extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *); |
32 | extern void _PyEval_InitState(struct _ceval_state *, PyThread_type_lock); |
33 | extern void _PyEval_FiniState(struct _ceval_state *ceval); |
34 | PyAPI_FUNC(void) _PyEval_SignalReceived(PyInterpreterState *interp); |
35 | PyAPI_FUNC(int) _PyEval_AddPendingCall( |
36 | PyInterpreterState *interp, |
37 | int (*func)(void *), |
38 | void *arg); |
39 | PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyInterpreterState *interp); |
40 | #ifdef HAVE_FORK |
41 | extern PyStatus _PyEval_ReInitThreads(PyThreadState *tstate); |
42 | #endif |
43 | |
44 | // Used by sys.call_tracing() |
45 | extern PyObject* _PyEval_CallTracing(PyObject *func, PyObject *args); |
46 | |
47 | // Used by sys.get_asyncgen_hooks() |
48 | extern PyObject* _PyEval_GetAsyncGenFirstiter(void); |
49 | extern PyObject* _PyEval_GetAsyncGenFinalizer(void); |
50 | |
51 | // Used by sys.set_asyncgen_hooks() |
52 | extern int _PyEval_SetAsyncGenFirstiter(PyObject *); |
53 | extern int _PyEval_SetAsyncGenFinalizer(PyObject *); |
54 | |
55 | // Used by sys.get_coroutine_origin_tracking_depth() |
56 | // and sys.set_coroutine_origin_tracking_depth() |
57 | extern int _PyEval_GetCoroutineOriginTrackingDepth(void); |
58 | extern int _PyEval_SetCoroutineOriginTrackingDepth(int depth); |
59 | |
60 | extern void _PyEval_Fini(void); |
61 | |
62 | |
63 | extern PyObject* _PyEval_GetBuiltins(PyThreadState *tstate); |
64 | extern PyObject* _PyEval_BuiltinsFromGlobals( |
65 | PyThreadState *tstate, |
66 | PyObject *globals); |
67 | |
68 | |
69 | static inline PyObject* |
70 | _PyEval_EvalFrame(PyThreadState *tstate, struct _PyInterpreterFrame *frame, int throwflag) |
71 | { |
72 | EVAL_CALL_STAT_INC(EVAL_CALL_TOTAL); |
73 | if (tstate->interp->eval_frame == NULL) { Branch (73:9): [True: 30.0M, False: 0]
Branch (73:9): [True: 53.2M, False: 200]
|
74 | return _PyEval_EvalFrameDefault(tstate, frame, throwflag); |
75 | } |
76 | return tstate->interp->eval_frame(tstate, frame, throwflag); |
77 | } Unexecuted instantiation: abstract.c:_PyEval_EvalFrame Unexecuted instantiation: call.c:_PyEval_EvalFrame Unexecuted instantiation: descrobject.c:_PyEval_EvalFrame Unexecuted instantiation: exceptions.c:_PyEval_EvalFrame genobject.c:_PyEval_EvalFrame Line | Count | Source | 71 | { | 72 | EVAL_CALL_STAT_INC(EVAL_CALL_TOTAL); | 73 | if (tstate->interp->eval_frame == NULL) { Branch (73:9): [True: 30.0M, False: 0]
| 74 | return _PyEval_EvalFrameDefault(tstate, frame, throwflag); | 75 | } | 76 | return tstate->interp->eval_frame(tstate, frame, throwflag); | 77 | } |
Unexecuted instantiation: frameobject.c:_PyEval_EvalFrame Unexecuted instantiation: funcobject.c:_PyEval_EvalFrame Unexecuted instantiation: methodobject.c:_PyEval_EvalFrame Unexecuted instantiation: object.c:_PyEval_EvalFrame Unexecuted instantiation: Python-ast.c:_PyEval_EvalFrame Unexecuted instantiation: bltinmodule.c:_PyEval_EvalFrame ceval.c:_PyEval_EvalFrame Line | Count | Source | 71 | { | 72 | EVAL_CALL_STAT_INC(EVAL_CALL_TOTAL); | 73 | if (tstate->interp->eval_frame == NULL) { Branch (73:9): [True: 53.2M, False: 200]
| 74 | return _PyEval_EvalFrameDefault(tstate, frame, throwflag); | 75 | } | 76 | return tstate->interp->eval_frame(tstate, frame, throwflag); | 77 | } |
Unexecuted instantiation: pylifecycle.c:_PyEval_EvalFrame Unexecuted instantiation: pystate.c:_PyEval_EvalFrame Unexecuted instantiation: pythonrun.c:_PyEval_EvalFrame Unexecuted instantiation: sysmodule.c:_PyEval_EvalFrame Unexecuted instantiation: posixmodule.c:_PyEval_EvalFrame Unexecuted instantiation: signalmodule.c:_PyEval_EvalFrame |
78 | |
79 | extern PyObject* |
80 | _PyEval_Vector(PyThreadState *tstate, |
81 | PyFunctionObject *func, PyObject *locals, |
82 | PyObject* const* args, size_t argcount, |
83 | PyObject *kwnames); |
84 | |
85 | extern int _PyEval_ThreadsInitialized(struct pyruntimestate *runtime); |
86 | extern PyStatus _PyEval_InitGIL(PyThreadState *tstate); |
87 | extern void _PyEval_FiniGIL(PyInterpreterState *interp); |
88 | |
89 | extern void _PyEval_ReleaseLock(PyThreadState *tstate); |
90 | |
91 | extern void _PyEval_DeactivateOpCache(void); |
92 | |
93 | |
94 | /* --- _Py_EnterRecursiveCall() ----------------------------------------- */ |
95 | |
96 | #ifdef USE_STACKCHECK |
97 | /* With USE_STACKCHECK macro defined, trigger stack checks in |
98 | _Py_CheckRecursiveCall() on every 64th call to _Py_EnterRecursiveCall. */ |
99 | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { |
100 | return (tstate->recursion_remaining-- <= 0 |
101 | || (tstate->recursion_remaining & 63) == 0); |
102 | } |
103 | #else |
104 | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { |
105 | return tstate->recursion_remaining-- <= 0; |
106 | } abstract.c:_Py_MakeRecCheck Line | Count | Source | 104 | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { | 105 | return tstate->recursion_remaining-- <= 0; | 106 | } |
Line | Count | Source | 104 | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { | 105 | return tstate->recursion_remaining-- <= 0; | 106 | } |
descrobject.c:_Py_MakeRecCheck Line | Count | Source | 104 | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { | 105 | return tstate->recursion_remaining-- <= 0; | 106 | } |
exceptions.c:_Py_MakeRecCheck Line | Count | Source | 104 | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { | 105 | return tstate->recursion_remaining-- <= 0; | 106 | } |
Unexecuted instantiation: genobject.c:_Py_MakeRecCheck Unexecuted instantiation: frameobject.c:_Py_MakeRecCheck Unexecuted instantiation: funcobject.c:_Py_MakeRecCheck methodobject.c:_Py_MakeRecCheck Line | Count | Source | 104 | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { | 105 | return tstate->recursion_remaining-- <= 0; | 106 | } |
object.c:_Py_MakeRecCheck Line | Count | Source | 104 | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { | 105 | return tstate->recursion_remaining-- <= 0; | 106 | } |
Python-ast.c:_Py_MakeRecCheck Line | Count | Source | 104 | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { | 105 | return tstate->recursion_remaining-- <= 0; | 106 | } |
Unexecuted instantiation: bltinmodule.c:_Py_MakeRecCheck Line | Count | Source | 104 | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { | 105 | return tstate->recursion_remaining-- <= 0; | 106 | } |
Unexecuted instantiation: pylifecycle.c:_Py_MakeRecCheck Unexecuted instantiation: pystate.c:_Py_MakeRecCheck pythonrun.c:_Py_MakeRecCheck Line | Count | Source | 104 | static inline int _Py_MakeRecCheck(PyThreadState *tstate) { | 105 | return tstate->recursion_remaining-- <= 0; | 106 | } |
Unexecuted instantiation: sysmodule.c:_Py_MakeRecCheck Unexecuted instantiation: posixmodule.c:_Py_MakeRecCheck Unexecuted instantiation: signalmodule.c:_Py_MakeRecCheck |
107 | #endif |
108 | |
109 | PyAPI_FUNC(int) _Py_CheckRecursiveCall( |
110 | PyThreadState *tstate, |
111 | const char *where); |
112 | |
113 | static inline int _Py_EnterRecursiveCallTstate(PyThreadState *tstate, |
114 | const char *where) { |
115 | return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)16.5k ); Branch (115:13): [True: 3, False: 4.09M]
Branch (115:41): [True: 3, False: 0]
Branch (115:13): [True: 8.21k, False: 46.3M]
Branch (115:41): [True: 7, False: 8.20k]
Branch (115:13): [True: 1, False: 32.7M]
Branch (115:41): [True: 1, False: 0]
Branch (115:13): [True: 2, False: 2.87k]
Branch (115:41): [True: 2, False: 0]
Branch (115:13): [True: 28, False: 56.6M]
Branch (115:41): [True: 28, False: 0]
Branch (115:13): [True: 18, False: 104M]
Branch (115:41): [True: 18, False: 0]
Branch (115:13): [True: 2, False: 2.22M]
Branch (115:41): [True: 2, False: 0]
Branch (115:13): [True: 8.25k, False: 279M]
Branch (115:41): [True: 8.25k, False: 0]
Branch (115:13): [True: 0, False: 94]
Branch (115:41): [True: 0, False: 0]
|
116 | } abstract.c:_Py_EnterRecursiveCallTstate Line | Count | Source | 114 | const char *where) { | 115 | return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)3 ); Branch (115:13): [True: 3, False: 4.09M]
Branch (115:41): [True: 3, False: 0]
| 116 | } |
call.c:_Py_EnterRecursiveCallTstate Line | Count | Source | 114 | const char *where) { | 115 | return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)8.21k ); Branch (115:13): [True: 8.21k, False: 46.3M]
Branch (115:41): [True: 7, False: 8.20k]
| 116 | } |
descrobject.c:_Py_EnterRecursiveCallTstate Line | Count | Source | 114 | const char *where) { | 115 | return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)1 ); Branch (115:13): [True: 1, False: 32.7M]
Branch (115:41): [True: 1, False: 0]
| 116 | } |
exceptions.c:_Py_EnterRecursiveCallTstate Line | Count | Source | 114 | const char *where) { | 115 | return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)2 ); Branch (115:13): [True: 2, False: 2.87k]
Branch (115:41): [True: 2, False: 0]
| 116 | } |
Unexecuted instantiation: genobject.c:_Py_EnterRecursiveCallTstate Unexecuted instantiation: frameobject.c:_Py_EnterRecursiveCallTstate Unexecuted instantiation: funcobject.c:_Py_EnterRecursiveCallTstate methodobject.c:_Py_EnterRecursiveCallTstate Line | Count | Source | 114 | const char *where) { | 115 | return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)28 ); Branch (115:13): [True: 28, False: 56.6M]
Branch (115:41): [True: 28, False: 0]
| 116 | } |
object.c:_Py_EnterRecursiveCallTstate Line | Count | Source | 114 | const char *where) { | 115 | return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)18 ); Branch (115:13): [True: 18, False: 104M]
Branch (115:41): [True: 18, False: 0]
| 116 | } |
Python-ast.c:_Py_EnterRecursiveCallTstate Line | Count | Source | 114 | const char *where) { | 115 | return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)2 ); Branch (115:13): [True: 2, False: 2.22M]
Branch (115:41): [True: 2, False: 0]
| 116 | } |
Unexecuted instantiation: bltinmodule.c:_Py_EnterRecursiveCallTstate ceval.c:_Py_EnterRecursiveCallTstate Line | Count | Source | 114 | const char *where) { | 115 | return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)8.25k ); Branch (115:13): [True: 8.25k, False: 279M]
Branch (115:41): [True: 8.25k, False: 0]
| 116 | } |
Unexecuted instantiation: pylifecycle.c:_Py_EnterRecursiveCallTstate Unexecuted instantiation: pystate.c:_Py_EnterRecursiveCallTstate pythonrun.c:_Py_EnterRecursiveCallTstate Line | Count | Source | 114 | const char *where) { | 115 | return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where)0 ); Branch (115:13): [True: 0, False: 94]
Branch (115:41): [True: 0, False: 0]
| 116 | } |
Unexecuted instantiation: sysmodule.c:_Py_EnterRecursiveCallTstate Unexecuted instantiation: posixmodule.c:_Py_EnterRecursiveCallTstate Unexecuted instantiation: signalmodule.c:_Py_EnterRecursiveCallTstate |
117 | |
118 | static inline int _Py_EnterRecursiveCall(const char *where) { |
119 | PyThreadState *tstate = _PyThreadState_GET(); |
120 | return _Py_EnterRecursiveCallTstate(tstate, where); |
121 | } abstract.c:_Py_EnterRecursiveCall Line | Count | Source | 118 | static inline int _Py_EnterRecursiveCall(const char *where) { | 119 | PyThreadState *tstate = _PyThreadState_GET(); | 120 | return _Py_EnterRecursiveCallTstate(tstate, where); | 121 | } |
Unexecuted instantiation: call.c:_Py_EnterRecursiveCall Unexecuted instantiation: descrobject.c:_Py_EnterRecursiveCall exceptions.c:_Py_EnterRecursiveCall Line | Count | Source | 118 | static inline int _Py_EnterRecursiveCall(const char *where) { | 119 | PyThreadState *tstate = _PyThreadState_GET(); | 120 | return _Py_EnterRecursiveCallTstate(tstate, where); | 121 | } |
Unexecuted instantiation: genobject.c:_Py_EnterRecursiveCall Unexecuted instantiation: frameobject.c:_Py_EnterRecursiveCall Unexecuted instantiation: funcobject.c:_Py_EnterRecursiveCall Unexecuted instantiation: methodobject.c:_Py_EnterRecursiveCall Unexecuted instantiation: object.c:_Py_EnterRecursiveCall Python-ast.c:_Py_EnterRecursiveCall Line | Count | Source | 118 | static inline int _Py_EnterRecursiveCall(const char *where) { | 119 | PyThreadState *tstate = _PyThreadState_GET(); | 120 | return _Py_EnterRecursiveCallTstate(tstate, where); | 121 | } |
Unexecuted instantiation: bltinmodule.c:_Py_EnterRecursiveCall Unexecuted instantiation: ceval.c:_Py_EnterRecursiveCall Unexecuted instantiation: pylifecycle.c:_Py_EnterRecursiveCall Unexecuted instantiation: pystate.c:_Py_EnterRecursiveCall pythonrun.c:_Py_EnterRecursiveCall Line | Count | Source | 118 | static inline int _Py_EnterRecursiveCall(const char *where) { | 119 | PyThreadState *tstate = _PyThreadState_GET(); | 120 | return _Py_EnterRecursiveCallTstate(tstate, where); | 121 | } |
Unexecuted instantiation: sysmodule.c:_Py_EnterRecursiveCall Unexecuted instantiation: posixmodule.c:_Py_EnterRecursiveCall Unexecuted instantiation: signalmodule.c:_Py_EnterRecursiveCall |
122 | |
123 | static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { |
124 | tstate->recursion_remaining++; |
125 | } abstract.c:_Py_LeaveRecursiveCallTstate Line | Count | Source | 123 | static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { | 124 | tstate->recursion_remaining++; | 125 | } |
call.c:_Py_LeaveRecursiveCallTstate Line | Count | Source | 123 | static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { | 124 | tstate->recursion_remaining++; | 125 | } |
descrobject.c:_Py_LeaveRecursiveCallTstate Line | Count | Source | 123 | static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { | 124 | tstate->recursion_remaining++; | 125 | } |
exceptions.c:_Py_LeaveRecursiveCallTstate Line | Count | Source | 123 | static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { | 124 | tstate->recursion_remaining++; | 125 | } |
Unexecuted instantiation: genobject.c:_Py_LeaveRecursiveCallTstate Unexecuted instantiation: frameobject.c:_Py_LeaveRecursiveCallTstate Unexecuted instantiation: funcobject.c:_Py_LeaveRecursiveCallTstate methodobject.c:_Py_LeaveRecursiveCallTstate Line | Count | Source | 123 | static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { | 124 | tstate->recursion_remaining++; | 125 | } |
object.c:_Py_LeaveRecursiveCallTstate Line | Count | Source | 123 | static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { | 124 | tstate->recursion_remaining++; | 125 | } |
Python-ast.c:_Py_LeaveRecursiveCallTstate Line | Count | Source | 123 | static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { | 124 | tstate->recursion_remaining++; | 125 | } |
Unexecuted instantiation: bltinmodule.c:_Py_LeaveRecursiveCallTstate ceval.c:_Py_LeaveRecursiveCallTstate Line | Count | Source | 123 | static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { | 124 | tstate->recursion_remaining++; | 125 | } |
Unexecuted instantiation: pylifecycle.c:_Py_LeaveRecursiveCallTstate Unexecuted instantiation: pystate.c:_Py_LeaveRecursiveCallTstate pythonrun.c:_Py_LeaveRecursiveCallTstate Line | Count | Source | 123 | static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { | 124 | tstate->recursion_remaining++; | 125 | } |
Unexecuted instantiation: sysmodule.c:_Py_LeaveRecursiveCallTstate Unexecuted instantiation: posixmodule.c:_Py_LeaveRecursiveCallTstate Unexecuted instantiation: signalmodule.c:_Py_LeaveRecursiveCallTstate |
126 | |
127 | static inline void _Py_LeaveRecursiveCall(void) { |
128 | PyThreadState *tstate = _PyThreadState_GET(); |
129 | _Py_LeaveRecursiveCallTstate(tstate); |
130 | } abstract.c:_Py_LeaveRecursiveCall Line | Count | Source | 127 | static inline void _Py_LeaveRecursiveCall(void) { | 128 | PyThreadState *tstate = _PyThreadState_GET(); | 129 | _Py_LeaveRecursiveCallTstate(tstate); | 130 | } |
Unexecuted instantiation: call.c:_Py_LeaveRecursiveCall descrobject.c:_Py_LeaveRecursiveCall Line | Count | Source | 127 | static inline void _Py_LeaveRecursiveCall(void) { | 128 | PyThreadState *tstate = _PyThreadState_GET(); | 129 | _Py_LeaveRecursiveCallTstate(tstate); | 130 | } |
exceptions.c:_Py_LeaveRecursiveCall Line | Count | Source | 127 | static inline void _Py_LeaveRecursiveCall(void) { | 128 | PyThreadState *tstate = _PyThreadState_GET(); | 129 | _Py_LeaveRecursiveCallTstate(tstate); | 130 | } |
Unexecuted instantiation: genobject.c:_Py_LeaveRecursiveCall Unexecuted instantiation: frameobject.c:_Py_LeaveRecursiveCall Unexecuted instantiation: funcobject.c:_Py_LeaveRecursiveCall Unexecuted instantiation: methodobject.c:_Py_LeaveRecursiveCall Unexecuted instantiation: object.c:_Py_LeaveRecursiveCall Python-ast.c:_Py_LeaveRecursiveCall Line | Count | Source | 127 | static inline void _Py_LeaveRecursiveCall(void) { | 128 | PyThreadState *tstate = _PyThreadState_GET(); | 129 | _Py_LeaveRecursiveCallTstate(tstate); | 130 | } |
Unexecuted instantiation: bltinmodule.c:_Py_LeaveRecursiveCall Unexecuted instantiation: ceval.c:_Py_LeaveRecursiveCall Unexecuted instantiation: pylifecycle.c:_Py_LeaveRecursiveCall Unexecuted instantiation: pystate.c:_Py_LeaveRecursiveCall pythonrun.c:_Py_LeaveRecursiveCall Line | Count | Source | 127 | static inline void _Py_LeaveRecursiveCall(void) { | 128 | PyThreadState *tstate = _PyThreadState_GET(); | 129 | _Py_LeaveRecursiveCallTstate(tstate); | 130 | } |
Unexecuted instantiation: sysmodule.c:_Py_LeaveRecursiveCall Unexecuted instantiation: posixmodule.c:_Py_LeaveRecursiveCall Unexecuted instantiation: signalmodule.c:_Py_LeaveRecursiveCall |
131 | |
132 | extern struct _PyInterpreterFrame* _PyEval_GetFrame(void); |
133 | |
134 | extern PyObject* _Py_MakeCoro(PyFunctionObject *func); |
135 | |
136 | #ifdef __cplusplus |
137 | } |
138 | #endif |
139 | #endif /* !Py_INTERNAL_CEVAL_H */ |