Lines Matching refs:frame
10 _PyFrame_Traverse(_PyInterpreterFrame *frame, visitproc visit, void *arg)
12 Py_VISIT(frame->frame_obj);
13 Py_VISIT(frame->f_locals);
14 Py_VISIT(frame->f_func);
15 Py_VISIT(frame->f_code);
17 PyObject **locals = _PyFrame_GetLocalsArray(frame);
20 for (; i <frame->stacktop; i++) {
27 _PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame)
29 assert(frame->frame_obj == NULL);
33 PyFrameObject *f = _PyFrame_New_NoTrack(frame->f_code);
41 if (frame->frame_obj) {
44 // *also* created the same frame... while we were in the middle of
48 // Regardless, just throw f away and use that frame instead, since it's
51 // Just pretend that we have an owned, cleared frame so frame_dealloc
57 return frame->frame_obj;
59 assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
60 assert(frame->owner != FRAME_CLEARED);
61 f->f_frame = frame;
62 frame->frame_obj = f;
72 // Don't leave a dangling pointer to the old frame when creating generators
79 take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
81 assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
82 assert(frame->owner != FRAME_CLEARED);
83 Py_ssize_t size = ((char*)&frame->localsplus[frame->stacktop]) - (char *)frame;
84 memcpy((_PyInterpreterFrame *)f->_f_frame_data, frame, size);
85 frame = (_PyInterpreterFrame *)f->_f_frame_data;
86 f->f_frame = frame;
87 frame->owner = FRAME_OWNED_BY_FRAME_OBJECT;
88 if (_PyFrame_IsIncomplete(frame)) {
89 // This may be a newly-created generator or coroutine frame. Since it's
91 PyCodeObject *code = frame->f_code;
92 frame->prev_instr = _PyCode_CODE(code) + code->_co_firsttraceable;
94 assert(!_PyFrame_IsIncomplete(frame));
96 _PyInterpreterFrame *prev = frame->previous;
112 frame->previous = NULL;
120 _PyFrame_Clear(_PyInterpreterFrame *frame)
124 assert(frame->owner != FRAME_OWNED_BY_GENERATOR ||
125 _PyFrame_GetGenerator(frame)->gi_frame_state == FRAME_CLEARED);
126 // GH-99729: Clearing this frame can expose the stack (via finalizers). It's
127 // crucial that this frame has been unlinked, and is no longer visible:
128 assert(_PyThreadState_GET()->cframe->current_frame != frame);
129 if (frame->frame_obj) {
130 PyFrameObject *f = frame->frame_obj;
131 frame->frame_obj = NULL;
133 take_ownership(f, frame);
139 assert(frame->stacktop >= 0);
140 for (int i = 0; i < frame->stacktop; i++) {
141 Py_XDECREF(frame->localsplus[i]);
143 Py_XDECREF(frame->frame_obj);
144 Py_XDECREF(frame->f_locals);
145 Py_DECREF(frame->f_func);
146 Py_DECREF(frame->f_code);
166 _PyInterpreterFrame_GetLine(_PyInterpreterFrame *frame)
168 int addr = _PyInterpreterFrame_LASTI(frame) * sizeof(_Py_CODEUNIT);
169 return PyCode_Addr2Line(frame->f_code, addr);