/home/mdboom/Work/builds/cpython/Include/internal/pycore_frame.h
Line | Count | Source |
1 | #ifndef Py_INTERNAL_FRAME_H |
2 | #define Py_INTERNAL_FRAME_H |
3 | #ifdef __cplusplus |
4 | extern "C" { |
5 | #endif |
6 | |
7 | #include <stdbool.h> |
8 | #include <stddef.h> |
9 | #include "pycore_code.h" // STATS |
10 | |
11 | /* See Objects/frame_layout.md for an explanation of the frame stack |
12 | * including explanation of the PyFrameObject and _PyInterpreterFrame |
13 | * structs. */ |
14 | |
15 | |
16 | struct _frame { |
17 | PyObject_HEAD |
18 | PyFrameObject *f_back; /* previous frame, or NULL */ |
19 | struct _PyInterpreterFrame *f_frame; /* points to the frame data */ |
20 | PyObject *f_trace; /* Trace function */ |
21 | int f_lineno; /* Current line number. Only valid if non-zero */ |
22 | char f_trace_lines; /* Emit per-line trace events? */ |
23 | char f_trace_opcodes; /* Emit per-opcode trace events? */ |
24 | char f_fast_as_locals; /* Have the fast locals of this frame been converted to a dict? */ |
25 | /* The frame data, if this frame object owns the frame */ |
26 | PyObject *_f_frame_data[1]; |
27 | }; |
28 | |
29 | extern PyFrameObject* _PyFrame_New_NoTrack(PyCodeObject *code); |
30 | |
31 | |
32 | /* other API */ |
33 | |
34 | typedef enum _framestate { |
35 | FRAME_CREATED = -2, |
36 | FRAME_SUSPENDED = -1, |
37 | FRAME_EXECUTING = 0, |
38 | FRAME_COMPLETED = 1, |
39 | FRAME_CLEARED = 4 |
40 | } PyFrameState; |
41 | |
42 | enum _frameowner { |
43 | FRAME_OWNED_BY_THREAD = 0, |
44 | FRAME_OWNED_BY_GENERATOR = 1, |
45 | FRAME_OWNED_BY_FRAME_OBJECT = 2 |
46 | }; |
47 | |
48 | typedef struct _PyInterpreterFrame { |
49 | /* "Specials" section */ |
50 | PyFunctionObject *f_func; /* Strong reference */ |
51 | PyObject *f_globals; /* Borrowed reference */ |
52 | PyObject *f_builtins; /* Borrowed reference */ |
53 | PyObject *f_locals; /* Strong reference, may be NULL */ |
54 | PyCodeObject *f_code; /* Strong reference */ |
55 | PyFrameObject *frame_obj; /* Strong reference, may be NULL */ |
56 | /* Linkage section */ |
57 | struct _PyInterpreterFrame *previous; |
58 | // NOTE: This is not necessarily the last instruction started in the given |
59 | // frame. Rather, it is the code unit *prior to* the *next* instruction. For |
60 | // example, it may be an inline CACHE entry, an instruction we just jumped |
61 | // over, or (in the case of a newly-created frame) a totally invalid value: |
62 | _Py_CODEUNIT *prev_instr; |
63 | int stacktop; /* Offset of TOS from localsplus */ |
64 | bool is_entry; // Whether this is the "root" frame for the current _PyCFrame. |
65 | char owner; |
66 | /* Locals and stack */ |
67 | PyObject *localsplus[1]; |
68 | } _PyInterpreterFrame; |
69 | |
70 | #define _PyInterpreterFrame_LASTI(IF) \ |
71 | ((int)((IF)->prev_instr - _PyCode_CODE((IF)->f_code))) |
72 | |
73 | static inline PyObject **_PyFrame_Stackbase(_PyInterpreterFrame *f) { |
74 | return f->localsplus + f->f_code->co_nlocalsplus; |
75 | } Unexecuted instantiation: codeobject.c:_PyFrame_Stackbase Unexecuted instantiation: genobject.c:_PyFrame_Stackbase Unexecuted instantiation: frameobject.c:_PyFrame_Stackbase Unexecuted instantiation: typeobject.c:_PyFrame_Stackbase Unexecuted instantiation: _warnings.c:_PyFrame_Stackbase ceval.c:_PyFrame_Stackbase Line | Count | Source | 73 | static inline PyObject **_PyFrame_Stackbase(_PyInterpreterFrame *f) { | 74 | return f->localsplus + f->f_code->co_nlocalsplus; | 75 | } |
Unexecuted instantiation: frame.c:_PyFrame_Stackbase Unexecuted instantiation: pystate.c:_PyFrame_Stackbase Unexecuted instantiation: sysmodule.c:_PyFrame_Stackbase Unexecuted instantiation: traceback.c:_PyFrame_Stackbase Unexecuted instantiation: suggestions.c:_PyFrame_Stackbase Unexecuted instantiation: signalmodule.c:_PyFrame_Stackbase Unexecuted instantiation: _tracemalloc.c:_PyFrame_Stackbase Unexecuted instantiation: deepfreeze.c:_PyFrame_Stackbase |
76 | |
77 | static inline PyObject *_PyFrame_StackPeek(_PyInterpreterFrame *f) { |
78 | assert(f->stacktop > f->f_code->co_nlocalsplus); |
79 | assert(f->localsplus[f->stacktop-1] != NULL); |
80 | return f->localsplus[f->stacktop-1]; |
81 | } Unexecuted instantiation: codeobject.c:_PyFrame_StackPeek genobject.c:_PyFrame_StackPeek Line | Count | Source | 77 | static inline PyObject *_PyFrame_StackPeek(_PyInterpreterFrame *f) { | 78 | assert(f->stacktop > f->f_code->co_nlocalsplus); | 79 | assert(f->localsplus[f->stacktop-1] != NULL); | 80 | return f->localsplus[f->stacktop-1]; | 81 | } |
Unexecuted instantiation: frameobject.c:_PyFrame_StackPeek Unexecuted instantiation: typeobject.c:_PyFrame_StackPeek Unexecuted instantiation: _warnings.c:_PyFrame_StackPeek Unexecuted instantiation: ceval.c:_PyFrame_StackPeek Unexecuted instantiation: frame.c:_PyFrame_StackPeek Unexecuted instantiation: pystate.c:_PyFrame_StackPeek Unexecuted instantiation: sysmodule.c:_PyFrame_StackPeek Unexecuted instantiation: traceback.c:_PyFrame_StackPeek Unexecuted instantiation: suggestions.c:_PyFrame_StackPeek Unexecuted instantiation: signalmodule.c:_PyFrame_StackPeek Unexecuted instantiation: _tracemalloc.c:_PyFrame_StackPeek Unexecuted instantiation: deepfreeze.c:_PyFrame_StackPeek |
82 | |
83 | static inline PyObject *_PyFrame_StackPop(_PyInterpreterFrame *f) { |
84 | assert(f->stacktop > f->f_code->co_nlocalsplus); |
85 | f->stacktop--; |
86 | return f->localsplus[f->stacktop]; |
87 | } Unexecuted instantiation: codeobject.c:_PyFrame_StackPop genobject.c:_PyFrame_StackPop Line | Count | Source | 83 | static inline PyObject *_PyFrame_StackPop(_PyInterpreterFrame *f) { | 84 | assert(f->stacktop > f->f_code->co_nlocalsplus); | 85 | f->stacktop--; | 86 | return f->localsplus[f->stacktop]; | 87 | } |
frameobject.c:_PyFrame_StackPop Line | Count | Source | 83 | static inline PyObject *_PyFrame_StackPop(_PyInterpreterFrame *f) { | 84 | assert(f->stacktop > f->f_code->co_nlocalsplus); | 85 | f->stacktop--; | 86 | return f->localsplus[f->stacktop]; | 87 | } |
Unexecuted instantiation: typeobject.c:_PyFrame_StackPop Unexecuted instantiation: _warnings.c:_PyFrame_StackPop Unexecuted instantiation: ceval.c:_PyFrame_StackPop Unexecuted instantiation: frame.c:_PyFrame_StackPop Unexecuted instantiation: pystate.c:_PyFrame_StackPop Unexecuted instantiation: sysmodule.c:_PyFrame_StackPop Unexecuted instantiation: traceback.c:_PyFrame_StackPop Unexecuted instantiation: suggestions.c:_PyFrame_StackPop Unexecuted instantiation: signalmodule.c:_PyFrame_StackPop Unexecuted instantiation: _tracemalloc.c:_PyFrame_StackPop Unexecuted instantiation: deepfreeze.c:_PyFrame_StackPop |
88 | |
89 | static inline void _PyFrame_StackPush(_PyInterpreterFrame *f, PyObject *value) { |
90 | f->localsplus[f->stacktop] = value; |
91 | f->stacktop++; |
92 | } Unexecuted instantiation: codeobject.c:_PyFrame_StackPush genobject.c:_PyFrame_StackPush Line | Count | Source | 89 | static inline void _PyFrame_StackPush(_PyInterpreterFrame *f, PyObject *value) { | 90 | f->localsplus[f->stacktop] = value; | 91 | f->stacktop++; | 92 | } |
Unexecuted instantiation: frameobject.c:_PyFrame_StackPush Unexecuted instantiation: typeobject.c:_PyFrame_StackPush Unexecuted instantiation: _warnings.c:_PyFrame_StackPush ceval.c:_PyFrame_StackPush Line | Count | Source | 89 | static inline void _PyFrame_StackPush(_PyInterpreterFrame *f, PyObject *value) { | 90 | f->localsplus[f->stacktop] = value; | 91 | f->stacktop++; | 92 | } |
Unexecuted instantiation: frame.c:_PyFrame_StackPush Unexecuted instantiation: pystate.c:_PyFrame_StackPush Unexecuted instantiation: sysmodule.c:_PyFrame_StackPush Unexecuted instantiation: traceback.c:_PyFrame_StackPush Unexecuted instantiation: suggestions.c:_PyFrame_StackPush Unexecuted instantiation: signalmodule.c:_PyFrame_StackPush Unexecuted instantiation: _tracemalloc.c:_PyFrame_StackPush Unexecuted instantiation: deepfreeze.c:_PyFrame_StackPush |
93 | |
94 | #define FRAME_SPECIALS_SIZE ((sizeof(_PyInterpreterFrame)-1)/sizeof(PyObject *)) |
95 | |
96 | void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest); |
97 | |
98 | /* Consumes reference to func and locals */ |
99 | static inline void |
100 | _PyFrame_InitializeSpecials( |
101 | _PyInterpreterFrame *frame, PyFunctionObject *func, |
102 | PyObject *locals, PyCodeObject *code) |
103 | { |
104 | frame->f_func = func; |
105 | frame->f_code = (PyCodeObject *)Py_NewRef(code); |
106 | frame->f_builtins = func->func_builtins; |
107 | frame->f_globals = func->func_globals; |
108 | frame->f_locals = locals; |
109 | frame->stacktop = code->co_nlocalsplus; |
110 | frame->frame_obj = NULL; |
111 | frame->prev_instr = _PyCode_CODE(code) - 1; |
112 | frame->is_entry = false; |
113 | frame->owner = FRAME_OWNED_BY_THREAD; |
114 | } Unexecuted instantiation: codeobject.c:_PyFrame_InitializeSpecials Unexecuted instantiation: genobject.c:_PyFrame_InitializeSpecials frameobject.c:_PyFrame_InitializeSpecials Line | Count | Source | 103 | { | 104 | frame->f_func = func; | 105 | frame->f_code = (PyCodeObject *)Py_NewRef(code); | 106 | frame->f_builtins = func->func_builtins; | 107 | frame->f_globals = func->func_globals; | 108 | frame->f_locals = locals; | 109 | frame->stacktop = code->co_nlocalsplus; | 110 | frame->frame_obj = NULL; | 111 | frame->prev_instr = _PyCode_CODE(code) - 1; | 112 | frame->is_entry = false; | 113 | frame->owner = FRAME_OWNED_BY_THREAD; | 114 | } |
Unexecuted instantiation: typeobject.c:_PyFrame_InitializeSpecials Unexecuted instantiation: _warnings.c:_PyFrame_InitializeSpecials ceval.c:_PyFrame_InitializeSpecials Line | Count | Source | 103 | { | 104 | frame->f_func = func; | 105 | frame->f_code = (PyCodeObject *)Py_NewRef(code); | 106 | frame->f_builtins = func->func_builtins; | 107 | frame->f_globals = func->func_globals; | 108 | frame->f_locals = locals; | 109 | frame->stacktop = code->co_nlocalsplus; | 110 | frame->frame_obj = NULL; | 111 | frame->prev_instr = _PyCode_CODE(code) - 1; | 112 | frame->is_entry = false; | 113 | frame->owner = FRAME_OWNED_BY_THREAD; | 114 | } |
Unexecuted instantiation: frame.c:_PyFrame_InitializeSpecials Unexecuted instantiation: pystate.c:_PyFrame_InitializeSpecials Unexecuted instantiation: sysmodule.c:_PyFrame_InitializeSpecials Unexecuted instantiation: traceback.c:_PyFrame_InitializeSpecials Unexecuted instantiation: suggestions.c:_PyFrame_InitializeSpecials Unexecuted instantiation: signalmodule.c:_PyFrame_InitializeSpecials Unexecuted instantiation: _tracemalloc.c:_PyFrame_InitializeSpecials Unexecuted instantiation: deepfreeze.c:_PyFrame_InitializeSpecials |
115 | |
116 | /* Gets the pointer to the locals array |
117 | * that precedes this frame. |
118 | */ |
119 | static inline PyObject** |
120 | _PyFrame_GetLocalsArray(_PyInterpreterFrame *frame) |
121 | { |
122 | return frame->localsplus; |
123 | } Unexecuted instantiation: codeobject.c:_PyFrame_GetLocalsArray Unexecuted instantiation: genobject.c:_PyFrame_GetLocalsArray frameobject.c:_PyFrame_GetLocalsArray Line | Count | Source | 121 | { | 122 | return frame->localsplus; | 123 | } |
typeobject.c:_PyFrame_GetLocalsArray Line | Count | Source | 121 | { | 122 | return frame->localsplus; | 123 | } |
Unexecuted instantiation: _warnings.c:_PyFrame_GetLocalsArray Unexecuted instantiation: ceval.c:_PyFrame_GetLocalsArray frame.c:_PyFrame_GetLocalsArray Line | Count | Source | 121 | { | 122 | return frame->localsplus; | 123 | } |
Unexecuted instantiation: pystate.c:_PyFrame_GetLocalsArray Unexecuted instantiation: sysmodule.c:_PyFrame_GetLocalsArray Unexecuted instantiation: traceback.c:_PyFrame_GetLocalsArray Unexecuted instantiation: suggestions.c:_PyFrame_GetLocalsArray Unexecuted instantiation: signalmodule.c:_PyFrame_GetLocalsArray Unexecuted instantiation: _tracemalloc.c:_PyFrame_GetLocalsArray Unexecuted instantiation: deepfreeze.c:_PyFrame_GetLocalsArray |
124 | |
125 | static inline PyObject** |
126 | _PyFrame_GetStackPointer(_PyInterpreterFrame *frame) |
127 | { |
128 | return frame->localsplus+frame->stacktop; |
129 | } Unexecuted instantiation: codeobject.c:_PyFrame_GetStackPointer Unexecuted instantiation: genobject.c:_PyFrame_GetStackPointer Unexecuted instantiation: frameobject.c:_PyFrame_GetStackPointer Unexecuted instantiation: typeobject.c:_PyFrame_GetStackPointer Unexecuted instantiation: _warnings.c:_PyFrame_GetStackPointer ceval.c:_PyFrame_GetStackPointer Line | Count | Source | 127 | { | 128 | return frame->localsplus+frame->stacktop; | 129 | } |
Unexecuted instantiation: frame.c:_PyFrame_GetStackPointer Unexecuted instantiation: pystate.c:_PyFrame_GetStackPointer Unexecuted instantiation: sysmodule.c:_PyFrame_GetStackPointer Unexecuted instantiation: traceback.c:_PyFrame_GetStackPointer Unexecuted instantiation: suggestions.c:_PyFrame_GetStackPointer Unexecuted instantiation: signalmodule.c:_PyFrame_GetStackPointer Unexecuted instantiation: _tracemalloc.c:_PyFrame_GetStackPointer Unexecuted instantiation: deepfreeze.c:_PyFrame_GetStackPointer |
130 | |
131 | static inline void |
132 | _PyFrame_SetStackPointer(_PyInterpreterFrame *frame, PyObject **stack_pointer) |
133 | { |
134 | frame->stacktop = (int)(stack_pointer - frame->localsplus); |
135 | } Unexecuted instantiation: codeobject.c:_PyFrame_SetStackPointer Unexecuted instantiation: genobject.c:_PyFrame_SetStackPointer Unexecuted instantiation: frameobject.c:_PyFrame_SetStackPointer Unexecuted instantiation: typeobject.c:_PyFrame_SetStackPointer Unexecuted instantiation: _warnings.c:_PyFrame_SetStackPointer ceval.c:_PyFrame_SetStackPointer Line | Count | Source | 133 | { | 134 | frame->stacktop = (int)(stack_pointer - frame->localsplus); | 135 | } |
Unexecuted instantiation: frame.c:_PyFrame_SetStackPointer Unexecuted instantiation: pystate.c:_PyFrame_SetStackPointer Unexecuted instantiation: sysmodule.c:_PyFrame_SetStackPointer Unexecuted instantiation: traceback.c:_PyFrame_SetStackPointer Unexecuted instantiation: suggestions.c:_PyFrame_SetStackPointer Unexecuted instantiation: signalmodule.c:_PyFrame_SetStackPointer Unexecuted instantiation: _tracemalloc.c:_PyFrame_SetStackPointer Unexecuted instantiation: deepfreeze.c:_PyFrame_SetStackPointer |
136 | |
137 | /* Determine whether a frame is incomplete. |
138 | * A frame is incomplete if it is part way through |
139 | * creating cell objects or a generator or coroutine. |
140 | * |
141 | * Frames on the frame stack are incomplete until the |
142 | * first RESUME instruction. |
143 | * Frames owned by a generator are always complete. |
144 | */ |
145 | static inline bool |
146 | _PyFrame_IsIncomplete(_PyInterpreterFrame *frame) |
147 | { |
148 | return frame->owner != FRAME_OWNED_BY_GENERATOR && Branch (148:12): [True: 131k, False: 4.21k]
Branch (148:12): [True: 507k, False: 6.80k]
Branch (148:12): [True: 9.51k, False: 3]
|
149 | frame->prev_instr < 648k _PyCode_CODE648k (frame->f_code) + frame->f_code->_co_firsttraceable; Branch (149:5): [True: 4, False: 131k]
Branch (149:5): [True: 0, False: 507k]
Branch (149:5): [True: 0, False: 9.51k]
|
150 | } Unexecuted instantiation: codeobject.c:_PyFrame_IsIncomplete Unexecuted instantiation: genobject.c:_PyFrame_IsIncomplete frameobject.c:_PyFrame_IsIncomplete Line | Count | Source | 147 | { | 148 | return frame->owner != FRAME_OWNED_BY_GENERATOR && Branch (148:12): [True: 131k, False: 4.21k]
| 149 | frame->prev_instr < 131k _PyCode_CODE131k (frame->f_code) + frame->f_code->_co_firsttraceable; Branch (149:5): [True: 4, False: 131k]
| 150 | } |
Unexecuted instantiation: typeobject.c:_PyFrame_IsIncomplete Unexecuted instantiation: _warnings.c:_PyFrame_IsIncomplete Unexecuted instantiation: ceval.c:_PyFrame_IsIncomplete frame.c:_PyFrame_IsIncomplete Line | Count | Source | 147 | { | 148 | return frame->owner != FRAME_OWNED_BY_GENERATOR && Branch (148:12): [True: 507k, False: 6.80k]
| 149 | frame->prev_instr < 507k _PyCode_CODE507k (frame->f_code) + frame->f_code->_co_firsttraceable; Branch (149:5): [True: 0, False: 507k]
| 150 | } |
Unexecuted instantiation: pystate.c:_PyFrame_IsIncomplete sysmodule.c:_PyFrame_IsIncomplete Line | Count | Source | 147 | { | 148 | return frame->owner != FRAME_OWNED_BY_GENERATOR && Branch (148:12): [True: 9.51k, False: 3]
| 149 | frame->prev_instr < 9.51k _PyCode_CODE9.51k (frame->f_code) + frame->f_code->_co_firsttraceable; Branch (149:5): [True: 0, False: 9.51k]
| 150 | } |
Unexecuted instantiation: traceback.c:_PyFrame_IsIncomplete Unexecuted instantiation: suggestions.c:_PyFrame_IsIncomplete Unexecuted instantiation: signalmodule.c:_PyFrame_IsIncomplete Unexecuted instantiation: _tracemalloc.c:_PyFrame_IsIncomplete Unexecuted instantiation: deepfreeze.c:_PyFrame_IsIncomplete |
151 | |
152 | /* For use by _PyFrame_GetFrameObject |
153 | Do not call directly. */ |
154 | PyFrameObject * |
155 | _PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame); |
156 | |
157 | /* Gets the PyFrameObject for this frame, lazily |
158 | * creating it if necessary. |
159 | * Returns a borrowed referennce */ |
160 | static inline PyFrameObject * |
161 | _PyFrame_GetFrameObject(_PyInterpreterFrame *frame) |
162 | { |
163 | |
164 | assert(!_PyFrame_IsIncomplete(frame)); |
165 | PyFrameObject *res = frame->frame_obj; |
166 | if (res != NULL) { Branch (166:9): [True: 324, False: 91]
Branch (166:9): [True: 107k, False: 27.5k]
Branch (166:9): [True: 8.31M, False: 3.01M]
Branch (166:9): [True: 112k, False: 402k]
Branch (166:9): [True: 216, False: 2.69k]
Branch (166:9): [True: 829, False: 9.68k]
Branch (166:9): [True: 27.2k, False: 3.26k]
|
167 | return res; |
168 | } |
169 | return _PyFrame_MakeAndSetFrameObject(frame); |
170 | } Unexecuted instantiation: codeobject.c:_PyFrame_GetFrameObject genobject.c:_PyFrame_GetFrameObject Line | Count | Source | 162 | { | 163 | | 164 | assert(!_PyFrame_IsIncomplete(frame)); | 165 | PyFrameObject *res = frame->frame_obj; | 166 | if (res != NULL) { Branch (166:9): [True: 324, False: 91]
| 167 | return res; | 168 | } | 169 | return _PyFrame_MakeAndSetFrameObject(frame); | 170 | } |
frameobject.c:_PyFrame_GetFrameObject Line | Count | Source | 162 | { | 163 | | 164 | assert(!_PyFrame_IsIncomplete(frame)); | 165 | PyFrameObject *res = frame->frame_obj; | 166 | if (res != NULL) { Branch (166:9): [True: 107k, False: 27.5k]
| 167 | return res; | 168 | } | 169 | return _PyFrame_MakeAndSetFrameObject(frame); | 170 | } |
Unexecuted instantiation: typeobject.c:_PyFrame_GetFrameObject Unexecuted instantiation: _warnings.c:_PyFrame_GetFrameObject ceval.c:_PyFrame_GetFrameObject Line | Count | Source | 162 | { | 163 | | 164 | assert(!_PyFrame_IsIncomplete(frame)); | 165 | PyFrameObject *res = frame->frame_obj; | 166 | if (res != NULL) { Branch (166:9): [True: 8.31M, False: 3.01M]
| 167 | return res; | 168 | } | 169 | return _PyFrame_MakeAndSetFrameObject(frame); | 170 | } |
frame.c:_PyFrame_GetFrameObject Line | Count | Source | 162 | { | 163 | | 164 | assert(!_PyFrame_IsIncomplete(frame)); | 165 | PyFrameObject *res = frame->frame_obj; | 166 | if (res != NULL) { Branch (166:9): [True: 112k, False: 402k]
| 167 | return res; | 168 | } | 169 | return _PyFrame_MakeAndSetFrameObject(frame); | 170 | } |
pystate.c:_PyFrame_GetFrameObject Line | Count | Source | 162 | { | 163 | | 164 | assert(!_PyFrame_IsIncomplete(frame)); | 165 | PyFrameObject *res = frame->frame_obj; | 166 | if (res != NULL) { Branch (166:9): [True: 216, False: 2.69k]
| 167 | return res; | 168 | } | 169 | return _PyFrame_MakeAndSetFrameObject(frame); | 170 | } |
sysmodule.c:_PyFrame_GetFrameObject Line | Count | Source | 162 | { | 163 | | 164 | assert(!_PyFrame_IsIncomplete(frame)); | 165 | PyFrameObject *res = frame->frame_obj; | 166 | if (res != NULL) { Branch (166:9): [True: 829, False: 9.68k]
| 167 | return res; | 168 | } | 169 | return _PyFrame_MakeAndSetFrameObject(frame); | 170 | } |
Unexecuted instantiation: traceback.c:_PyFrame_GetFrameObject Unexecuted instantiation: suggestions.c:_PyFrame_GetFrameObject signalmodule.c:_PyFrame_GetFrameObject Line | Count | Source | 162 | { | 163 | | 164 | assert(!_PyFrame_IsIncomplete(frame)); | 165 | PyFrameObject *res = frame->frame_obj; | 166 | if (res != NULL) { Branch (166:9): [True: 27.2k, False: 3.26k]
| 167 | return res; | 168 | } | 169 | return _PyFrame_MakeAndSetFrameObject(frame); | 170 | } |
Unexecuted instantiation: _tracemalloc.c:_PyFrame_GetFrameObject Unexecuted instantiation: deepfreeze.c:_PyFrame_GetFrameObject |
171 | |
172 | /* Clears all references in the frame. |
173 | * If take is non-zero, then the _PyInterpreterFrame frame |
174 | * may be transferred to the frame object it references |
175 | * instead of being cleared. Either way |
176 | * the caller no longer owns the references |
177 | * in the frame. |
178 | * take should be set to 1 for heap allocated |
179 | * frames like the ones in generators and coroutines. |
180 | */ |
181 | void |
182 | _PyFrame_Clear(_PyInterpreterFrame * frame); |
183 | |
184 | int |
185 | _PyFrame_Traverse(_PyInterpreterFrame *frame, visitproc visit, void *arg); |
186 | |
187 | int |
188 | _PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame); |
189 | |
190 | void |
191 | _PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear); |
192 | |
193 | |
194 | static inline bool |
195 | _PyThreadState_HasStackSpace(PyThreadState *tstate, int size) |
196 | { |
197 | return tstate->datastack_top + size < tstate->datastack_limit; |
198 | } Unexecuted instantiation: codeobject.c:_PyThreadState_HasStackSpace Unexecuted instantiation: genobject.c:_PyThreadState_HasStackSpace Unexecuted instantiation: frameobject.c:_PyThreadState_HasStackSpace Unexecuted instantiation: typeobject.c:_PyThreadState_HasStackSpace Unexecuted instantiation: _warnings.c:_PyThreadState_HasStackSpace ceval.c:_PyThreadState_HasStackSpace Line | Count | Source | 196 | { | 197 | return tstate->datastack_top + size < tstate->datastack_limit; | 198 | } |
Unexecuted instantiation: frame.c:_PyThreadState_HasStackSpace Unexecuted instantiation: pystate.c:_PyThreadState_HasStackSpace Unexecuted instantiation: sysmodule.c:_PyThreadState_HasStackSpace Unexecuted instantiation: traceback.c:_PyThreadState_HasStackSpace Unexecuted instantiation: suggestions.c:_PyThreadState_HasStackSpace Unexecuted instantiation: signalmodule.c:_PyThreadState_HasStackSpace Unexecuted instantiation: _tracemalloc.c:_PyThreadState_HasStackSpace Unexecuted instantiation: deepfreeze.c:_PyThreadState_HasStackSpace |
199 | |
200 | extern _PyInterpreterFrame * |
201 | _PyThreadState_PushFrame(PyThreadState *tstate, size_t size); |
202 | |
203 | void _PyThreadState_PopFrame(PyThreadState *tstate, _PyInterpreterFrame *frame); |
204 | |
205 | /* Pushes a frame without checking for space. |
206 | * Must be guarded by _PyThreadState_HasStackSpace() |
207 | * Consumes reference to func. */ |
208 | static inline _PyInterpreterFrame * |
209 | _PyFrame_PushUnchecked(PyThreadState *tstate, PyFunctionObject *func) |
210 | { |
211 | CALL_STAT_INC(frames_pushed); |
212 | PyCodeObject *code = (PyCodeObject *)func->func_code; |
213 | _PyInterpreterFrame *new_frame = (_PyInterpreterFrame *)tstate->datastack_top; |
214 | tstate->datastack_top += code->co_framesize; |
215 | assert(tstate->datastack_top < tstate->datastack_limit); |
216 | _PyFrame_InitializeSpecials(new_frame, func, NULL, code); |
217 | return new_frame; |
218 | } Unexecuted instantiation: codeobject.c:_PyFrame_PushUnchecked Unexecuted instantiation: genobject.c:_PyFrame_PushUnchecked Unexecuted instantiation: frameobject.c:_PyFrame_PushUnchecked Unexecuted instantiation: typeobject.c:_PyFrame_PushUnchecked Unexecuted instantiation: _warnings.c:_PyFrame_PushUnchecked ceval.c:_PyFrame_PushUnchecked Line | Count | Source | 210 | { | 211 | CALL_STAT_INC(frames_pushed); | 212 | PyCodeObject *code = (PyCodeObject *)func->func_code; | 213 | _PyInterpreterFrame *new_frame = (_PyInterpreterFrame *)tstate->datastack_top; | 214 | tstate->datastack_top += code->co_framesize; | 215 | assert(tstate->datastack_top < tstate->datastack_limit); | 216 | _PyFrame_InitializeSpecials(new_frame, func, NULL, code); | 217 | return new_frame; | 218 | } |
Unexecuted instantiation: frame.c:_PyFrame_PushUnchecked Unexecuted instantiation: pystate.c:_PyFrame_PushUnchecked Unexecuted instantiation: sysmodule.c:_PyFrame_PushUnchecked Unexecuted instantiation: traceback.c:_PyFrame_PushUnchecked Unexecuted instantiation: suggestions.c:_PyFrame_PushUnchecked Unexecuted instantiation: signalmodule.c:_PyFrame_PushUnchecked Unexecuted instantiation: _tracemalloc.c:_PyFrame_PushUnchecked Unexecuted instantiation: deepfreeze.c:_PyFrame_PushUnchecked |
219 | |
220 | int _PyInterpreterFrame_GetLine(_PyInterpreterFrame *frame); |
221 | |
222 | static inline |
223 | PyGenObject *_PyFrame_GetGenerator(_PyInterpreterFrame *frame) |
224 | { |
225 | assert(frame->owner == FRAME_OWNED_BY_GENERATOR); |
226 | size_t offset_in_gen = offsetof(PyGenObject, gi_iframe); |
227 | return (PyGenObject *)(((char *)frame) - offset_in_gen); |
228 | } Unexecuted instantiation: codeobject.c:_PyFrame_GetGenerator Unexecuted instantiation: genobject.c:_PyFrame_GetGenerator frameobject.c:_PyFrame_GetGenerator Line | Count | Source | 224 | { | 225 | assert(frame->owner == FRAME_OWNED_BY_GENERATOR); | 226 | size_t offset_in_gen = offsetof(PyGenObject, gi_iframe); | 227 | return (PyGenObject *)(((char *)frame) - offset_in_gen); | 228 | } |
Unexecuted instantiation: typeobject.c:_PyFrame_GetGenerator Unexecuted instantiation: _warnings.c:_PyFrame_GetGenerator ceval.c:_PyFrame_GetGenerator Line | Count | Source | 224 | { | 225 | assert(frame->owner == FRAME_OWNED_BY_GENERATOR); | 226 | size_t offset_in_gen = offsetof(PyGenObject, gi_iframe); | 227 | return (PyGenObject *)(((char *)frame) - offset_in_gen); | 228 | } |
Unexecuted instantiation: frame.c:_PyFrame_GetGenerator Unexecuted instantiation: pystate.c:_PyFrame_GetGenerator Unexecuted instantiation: sysmodule.c:_PyFrame_GetGenerator Unexecuted instantiation: traceback.c:_PyFrame_GetGenerator Unexecuted instantiation: suggestions.c:_PyFrame_GetGenerator Unexecuted instantiation: signalmodule.c:_PyFrame_GetGenerator Unexecuted instantiation: _tracemalloc.c:_PyFrame_GetGenerator Unexecuted instantiation: deepfreeze.c:_PyFrame_GetGenerator |
229 | |
230 | #ifdef __cplusplus |
231 | } |
232 | #endif |
233 | #endif /* !Py_INTERNAL_FRAME_H */ |