Lines Matching +full:code +full:- +full:frame
10 _PyFrame_Traverse(_PyInterpreterFrame *frame, visitproc visit, void *arg) in _PyFrame_Traverse() argument
12 Py_VISIT(frame->frame_obj); in _PyFrame_Traverse()
13 Py_VISIT(frame->f_locals); in _PyFrame_Traverse()
14 Py_VISIT(frame->f_func); in _PyFrame_Traverse()
15 Py_VISIT(frame->f_code); in _PyFrame_Traverse()
17 PyObject **locals = _PyFrame_GetLocalsArray(frame); in _PyFrame_Traverse()
20 for (; i <frame->stacktop; i++) { in _PyFrame_Traverse()
27 _PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame) in _PyFrame_MakeAndSetFrameObject() argument
29 assert(frame->frame_obj == NULL); in _PyFrame_MakeAndSetFrameObject()
33 PyFrameObject *f = _PyFrame_New_NoTrack(frame->f_code); in _PyFrame_MakeAndSetFrameObject()
41 if (frame->frame_obj) { in _PyFrame_MakeAndSetFrameObject()
42 // GH-97002: How did we get into this horrible situation? Most likely, in _PyFrame_MakeAndSetFrameObject()
43 // allocating f triggered a GC collection, which ran some code that in _PyFrame_MakeAndSetFrameObject()
44 // *also* created the same frame... while we were in the middle of in _PyFrame_MakeAndSetFrameObject()
48 // Regardless, just throw f away and use that frame instead, since it's in _PyFrame_MakeAndSetFrameObject()
49 // already been exposed to user code. It's actually a bit tricky to do in _PyFrame_MakeAndSetFrameObject()
51 // Just pretend that we have an owned, cleared frame so frame_dealloc in _PyFrame_MakeAndSetFrameObject()
53 f->f_frame = (_PyInterpreterFrame *)f->_f_frame_data; in _PyFrame_MakeAndSetFrameObject()
54 f->f_frame->owner = FRAME_CLEARED; in _PyFrame_MakeAndSetFrameObject()
55 f->f_frame->frame_obj = f; in _PyFrame_MakeAndSetFrameObject()
57 return frame->frame_obj; in _PyFrame_MakeAndSetFrameObject()
59 assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT); in _PyFrame_MakeAndSetFrameObject()
60 assert(frame->owner != FRAME_CLEARED); in _PyFrame_MakeAndSetFrameObject()
61 f->f_frame = frame; in _PyFrame_MakeAndSetFrameObject()
62 frame->frame_obj = f; in _PyFrame_MakeAndSetFrameObject()
69 assert(src->stacktop >= src->f_code->co_nlocalsplus); in _PyFrame_Copy()
70 Py_ssize_t size = ((char*)&src->localsplus[src->stacktop]) - (char *)src; in _PyFrame_Copy()
72 // Don't leave a dangling pointer to the old frame when creating generators in _PyFrame_Copy()
74 dest->previous = NULL; in _PyFrame_Copy()
79 take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame) in take_ownership() argument
81 assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT); in take_ownership()
82 assert(frame->owner != FRAME_CLEARED); in take_ownership()
83 Py_ssize_t size = ((char*)&frame->localsplus[frame->stacktop]) - (char *)frame; in take_ownership()
84 memcpy((_PyInterpreterFrame *)f->_f_frame_data, frame, size); in take_ownership()
85 frame = (_PyInterpreterFrame *)f->_f_frame_data; in take_ownership()
86 f->f_frame = frame; in take_ownership()
87 frame->owner = FRAME_OWNED_BY_FRAME_OBJECT; in take_ownership()
88 if (_PyFrame_IsIncomplete(frame)) { in take_ownership()
89 // This may be a newly-created generator or coroutine frame. Since it's in take_ownership()
91 PyCodeObject *code = frame->f_code; in take_ownership() local
92 frame->prev_instr = _PyCode_CODE(code) + code->_co_firsttraceable; in take_ownership()
94 assert(!_PyFrame_IsIncomplete(frame)); in take_ownership()
95 assert(f->f_back == NULL); in take_ownership()
96 _PyInterpreterFrame *prev = frame->previous; in take_ownership()
98 prev = prev->previous; in take_ownership()
110 f->f_back = (PyFrameObject *)Py_NewRef(back); in take_ownership()
112 frame->previous = NULL; in take_ownership()
120 _PyFrame_Clear(_PyInterpreterFrame *frame) in _PyFrame_Clear() argument
124 assert(frame->owner != FRAME_OWNED_BY_GENERATOR || in _PyFrame_Clear()
125 _PyFrame_GetGenerator(frame)->gi_frame_state == FRAME_CLEARED); in _PyFrame_Clear()
126 // GH-99729: Clearing this frame can expose the stack (via finalizers). It's in _PyFrame_Clear()
127 // crucial that this frame has been unlinked, and is no longer visible: in _PyFrame_Clear()
128 assert(_PyThreadState_GET()->cframe->current_frame != frame); in _PyFrame_Clear()
129 if (frame->frame_obj) { in _PyFrame_Clear()
130 PyFrameObject *f = frame->frame_obj; in _PyFrame_Clear()
131 frame->frame_obj = NULL; in _PyFrame_Clear()
133 take_ownership(f, frame); in _PyFrame_Clear()
139 assert(frame->stacktop >= 0); in _PyFrame_Clear()
140 for (int i = 0; i < frame->stacktop; i++) { in _PyFrame_Clear()
141 Py_XDECREF(frame->localsplus[i]); in _PyFrame_Clear()
143 Py_XDECREF(frame->frame_obj); in _PyFrame_Clear()
144 Py_XDECREF(frame->f_locals); in _PyFrame_Clear()
145 Py_DECREF(frame->f_func); in _PyFrame_Clear()
146 Py_DECREF(frame->f_code); in _PyFrame_Clear()
153 PyCodeObject *code = (PyCodeObject *)func->func_code; in _PyFrame_Push() local
154 size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE; in _PyFrame_Push()
161 _PyFrame_InitializeSpecials(new_frame, func, NULL, code->co_nlocalsplus); in _PyFrame_Push()
166 _PyInterpreterFrame_GetLine(_PyInterpreterFrame *frame) in _PyInterpreterFrame_GetLine() argument
168 int addr = _PyInterpreterFrame_LASTI(frame) * sizeof(_Py_CODEUNIT); in _PyInterpreterFrame_GetLine()
169 return PyCode_Addr2Line(frame->f_code, addr); in _PyInterpreterFrame_GetLine()