bpo-46836: Rename InterpreterFrame to _PyInterpreterFrame (GH-31583)

Rename also struct _interpreter_frame to struct _PyInterpreterFrame.

Reduce risk of name conflicts if a project includes pycore_frame.h.
This commit is contained in:
Victor Stinner 2022-02-25 16:22:00 +01:00 committed by GitHub
parent f780d9690f
commit 87af12bff3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 138 additions and 138 deletions

View File

@ -22,7 +22,7 @@ PyAPI_FUNC(PyObject *) _PyEval_GetBuiltinId(_Py_Identifier *);
flag was set, else return 0. */ flag was set, else return 0. */
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf); PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, struct _interpreter_frame *f, int exc); PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, struct _PyInterpreterFrame *f, int exc);
PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds); PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void); PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);

View File

@ -46,7 +46,7 @@ typedef struct _cframe {
*/ */
int use_tracing; int use_tracing;
/* Pointer to the currently executing frame (it can be NULL) */ /* Pointer to the currently executing frame (it can be NULL) */
struct _interpreter_frame *current_frame; struct _PyInterpreterFrame *current_frame;
struct _cframe *previous; struct _cframe *previous;
} CFrame; } CFrame;
@ -258,7 +258,7 @@ PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
/* Frame evaluation API */ /* Frame evaluation API */
typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, struct _interpreter_frame *, int); typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, struct _PyInterpreterFrame *, int);
PyAPI_FUNC(_PyFrameEvalFunction) _PyInterpreterState_GetEvalFrameFunc( PyAPI_FUNC(_PyFrameEvalFunction) _PyInterpreterState_GetEvalFrameFunc(
PyInterpreterState *interp); PyInterpreterState *interp);

View File

@ -47,7 +47,7 @@ extern PyObject *_PyEval_BuiltinsFromGlobals(
static inline PyObject* static inline PyObject*
_PyEval_EvalFrame(PyThreadState *tstate, struct _interpreter_frame *frame, int throwflag) _PyEval_EvalFrame(PyThreadState *tstate, struct _PyInterpreterFrame *frame, int throwflag)
{ {
if (tstate->interp->eval_frame == NULL) { if (tstate->interp->eval_frame == NULL) {
return _PyEval_EvalFrameDefault(tstate, frame, throwflag); return _PyEval_EvalFrameDefault(tstate, frame, throwflag);
@ -116,7 +116,7 @@ static inline void _Py_LeaveRecursiveCall_inline(void) {
#define Py_LeaveRecursiveCall() _Py_LeaveRecursiveCall_inline() #define Py_LeaveRecursiveCall() _Py_LeaveRecursiveCall_inline()
struct _interpreter_frame *_PyEval_GetFrame(void); struct _PyInterpreterFrame *_PyEval_GetFrame(void);
PyObject *_Py_MakeCoro(PyFunctionObject *func); PyObject *_Py_MakeCoro(PyFunctionObject *func);

View File

@ -9,7 +9,7 @@ extern "C" {
struct _frame { struct _frame {
PyObject_HEAD PyObject_HEAD
PyFrameObject *f_back; /* previous frame, or NULL */ PyFrameObject *f_back; /* previous frame, or NULL */
struct _interpreter_frame *f_frame; /* points to the frame data */ struct _PyInterpreterFrame *f_frame; /* points to the frame data */
PyObject *f_trace; /* Trace function */ PyObject *f_trace; /* Trace function */
int f_lineno; /* Current line number. Only valid if non-zero */ int f_lineno; /* Current line number. Only valid if non-zero */
char f_trace_lines; /* Emit per-line trace events? */ char f_trace_lines; /* Emit per-line trace events? */
@ -48,63 +48,63 @@ typedef signed char PyFrameState;
unless it's -1 in which case next_instr should be first_instr. unless it's -1 in which case next_instr should be first_instr.
*/ */
typedef struct _interpreter_frame { typedef struct _PyInterpreterFrame {
PyFunctionObject *f_func; /* Strong reference */ PyFunctionObject *f_func; /* Strong reference */
PyObject *f_globals; /* Borrowed reference */ PyObject *f_globals; /* Borrowed reference */
PyObject *f_builtins; /* Borrowed reference */ PyObject *f_builtins; /* Borrowed reference */
PyObject *f_locals; /* Strong reference, may be NULL */ PyObject *f_locals; /* Strong reference, may be NULL */
PyCodeObject *f_code; /* Strong reference */ PyCodeObject *f_code; /* Strong reference */
PyFrameObject *frame_obj; /* Strong reference, may be NULL */ PyFrameObject *frame_obj; /* Strong reference, may be NULL */
struct _interpreter_frame *previous; struct _PyInterpreterFrame *previous;
int f_lasti; /* Last instruction if called */ int f_lasti; /* Last instruction if called */
int stacktop; /* Offset of TOS from localsplus */ int stacktop; /* Offset of TOS from localsplus */
PyFrameState f_state; /* What state the frame is in */ PyFrameState f_state; /* What state the frame is in */
bool is_entry; // Whether this is the "root" frame for the current CFrame. bool is_entry; // Whether this is the "root" frame for the current CFrame.
bool is_generator; bool is_generator;
PyObject *localsplus[1]; PyObject *localsplus[1];
} InterpreterFrame; } _PyInterpreterFrame;
static inline int _PyFrame_IsRunnable(InterpreterFrame *f) { static inline int _PyFrame_IsRunnable(_PyInterpreterFrame *f) {
return f->f_state < FRAME_EXECUTING; return f->f_state < FRAME_EXECUTING;
} }
static inline int _PyFrame_IsExecuting(InterpreterFrame *f) { static inline int _PyFrame_IsExecuting(_PyInterpreterFrame *f) {
return f->f_state == FRAME_EXECUTING; return f->f_state == FRAME_EXECUTING;
} }
static inline int _PyFrameHasCompleted(InterpreterFrame *f) { static inline int _PyFrameHasCompleted(_PyInterpreterFrame *f) {
return f->f_state > FRAME_EXECUTING; return f->f_state > FRAME_EXECUTING;
} }
static inline PyObject **_PyFrame_Stackbase(InterpreterFrame *f) { static inline PyObject **_PyFrame_Stackbase(_PyInterpreterFrame *f) {
return f->localsplus + f->f_code->co_nlocalsplus; return f->localsplus + f->f_code->co_nlocalsplus;
} }
static inline PyObject *_PyFrame_StackPeek(InterpreterFrame *f) { static inline PyObject *_PyFrame_StackPeek(_PyInterpreterFrame *f) {
assert(f->stacktop > f->f_code->co_nlocalsplus); assert(f->stacktop > f->f_code->co_nlocalsplus);
assert(f->localsplus[f->stacktop-1] != NULL); assert(f->localsplus[f->stacktop-1] != NULL);
return f->localsplus[f->stacktop-1]; return f->localsplus[f->stacktop-1];
} }
static inline PyObject *_PyFrame_StackPop(InterpreterFrame *f) { static inline PyObject *_PyFrame_StackPop(_PyInterpreterFrame *f) {
assert(f->stacktop > f->f_code->co_nlocalsplus); assert(f->stacktop > f->f_code->co_nlocalsplus);
f->stacktop--; f->stacktop--;
return f->localsplus[f->stacktop]; return f->localsplus[f->stacktop];
} }
static inline void _PyFrame_StackPush(InterpreterFrame *f, PyObject *value) { static inline void _PyFrame_StackPush(_PyInterpreterFrame *f, PyObject *value) {
f->localsplus[f->stacktop] = value; f->localsplus[f->stacktop] = value;
f->stacktop++; f->stacktop++;
} }
#define FRAME_SPECIALS_SIZE ((sizeof(InterpreterFrame)-1)/sizeof(PyObject *)) #define FRAME_SPECIALS_SIZE ((sizeof(_PyInterpreterFrame)-1)/sizeof(PyObject *))
void _PyFrame_Copy(InterpreterFrame *src, InterpreterFrame *dest); void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest);
/* Consumes reference to func */ /* Consumes reference to func */
static inline void static inline void
_PyFrame_InitializeSpecials( _PyFrame_InitializeSpecials(
InterpreterFrame *frame, PyFunctionObject *func, _PyInterpreterFrame *frame, PyFunctionObject *func,
PyObject *locals, int nlocalsplus) PyObject *locals, int nlocalsplus)
{ {
frame->f_func = func; frame->f_func = func;
@ -124,19 +124,19 @@ _PyFrame_InitializeSpecials(
* that precedes this frame. * that precedes this frame.
*/ */
static inline PyObject** static inline PyObject**
_PyFrame_GetLocalsArray(InterpreterFrame *frame) _PyFrame_GetLocalsArray(_PyInterpreterFrame *frame)
{ {
return frame->localsplus; return frame->localsplus;
} }
static inline PyObject** static inline PyObject**
_PyFrame_GetStackPointer(InterpreterFrame *frame) _PyFrame_GetStackPointer(_PyInterpreterFrame *frame)
{ {
return frame->localsplus+frame->stacktop; return frame->localsplus+frame->stacktop;
} }
static inline void static inline void
_PyFrame_SetStackPointer(InterpreterFrame *frame, PyObject **stack_pointer) _PyFrame_SetStackPointer(_PyInterpreterFrame *frame, PyObject **stack_pointer)
{ {
frame->stacktop = (int)(stack_pointer - frame->localsplus); frame->stacktop = (int)(stack_pointer - frame->localsplus);
} }
@ -144,13 +144,13 @@ _PyFrame_SetStackPointer(InterpreterFrame *frame, PyObject **stack_pointer)
/* For use by _PyFrame_GetFrameObject /* For use by _PyFrame_GetFrameObject
Do not call directly. */ Do not call directly. */
PyFrameObject * PyFrameObject *
_PyFrame_MakeAndSetFrameObject(InterpreterFrame *frame); _PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame);
/* Gets the PyFrameObject for this frame, lazily /* Gets the PyFrameObject for this frame, lazily
* creating it if necessary. * creating it if necessary.
* Returns a borrowed referennce */ * Returns a borrowed referennce */
static inline PyFrameObject * static inline PyFrameObject *
_PyFrame_GetFrameObject(InterpreterFrame *frame) _PyFrame_GetFrameObject(_PyInterpreterFrame *frame)
{ {
PyFrameObject *res = frame->frame_obj; PyFrameObject *res = frame->frame_obj;
if (res != NULL) { if (res != NULL) {
@ -160,7 +160,7 @@ _PyFrame_GetFrameObject(InterpreterFrame *frame)
} }
/* Clears all references in the frame. /* Clears all references in the frame.
* If take is non-zero, then the InterpreterFrame frame * If take is non-zero, then the _PyInterpreterFrame frame
* may be transferred to the frame object it references * may be transferred to the frame object it references
* instead of being cleared. Either way * instead of being cleared. Either way
* the caller no longer owns the references * the caller no longer owns the references
@ -169,21 +169,21 @@ _PyFrame_GetFrameObject(InterpreterFrame *frame)
* frames like the ones in generators and coroutines. * frames like the ones in generators and coroutines.
*/ */
void void
_PyFrame_Clear(InterpreterFrame * frame); _PyFrame_Clear(_PyInterpreterFrame * frame);
int int
_PyFrame_Traverse(InterpreterFrame *frame, visitproc visit, void *arg); _PyFrame_Traverse(_PyInterpreterFrame *frame, visitproc visit, void *arg);
int int
_PyFrame_FastToLocalsWithError(InterpreterFrame *frame); _PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame);
void void
_PyFrame_LocalsToFast(InterpreterFrame *frame, int clear); _PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear);
extern InterpreterFrame * extern _PyInterpreterFrame *
_PyThreadState_BumpFramePointerSlow(PyThreadState *tstate, size_t size); _PyThreadState_BumpFramePointerSlow(PyThreadState *tstate, size_t size);
static inline InterpreterFrame * static inline _PyInterpreterFrame *
_PyThreadState_BumpFramePointer(PyThreadState *tstate, size_t size) _PyThreadState_BumpFramePointer(PyThreadState *tstate, size_t size)
{ {
PyObject **base = tstate->datastack_top; PyObject **base = tstate->datastack_top;
@ -192,16 +192,16 @@ _PyThreadState_BumpFramePointer(PyThreadState *tstate, size_t size)
assert(tstate->datastack_limit); assert(tstate->datastack_limit);
if (top < tstate->datastack_limit) { if (top < tstate->datastack_limit) {
tstate->datastack_top = top; tstate->datastack_top = top;
return (InterpreterFrame *)base; return (_PyInterpreterFrame *)base;
} }
} }
return _PyThreadState_BumpFramePointerSlow(tstate, size); return _PyThreadState_BumpFramePointerSlow(tstate, size);
} }
void _PyThreadState_PopFrame(PyThreadState *tstate, InterpreterFrame *frame); void _PyThreadState_PopFrame(PyThreadState *tstate, _PyInterpreterFrame *frame);
/* Consume reference to func */ /* Consume reference to func */
InterpreterFrame * _PyInterpreterFrame *
_PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func); _PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -305,7 +305,7 @@ hashtable_compare_traceback(const void *key1, const void *key2)
static void static void
tracemalloc_get_frame(InterpreterFrame *pyframe, frame_t *frame) tracemalloc_get_frame(_PyInterpreterFrame *pyframe, frame_t *frame)
{ {
frame->filename = &_Py_STR(anon_unknown); frame->filename = &_Py_STR(anon_unknown);
int lineno = PyCode_Addr2Line(pyframe->f_code, pyframe->f_lasti*sizeof(_Py_CODEUNIT)); int lineno = PyCode_Addr2Line(pyframe->f_code, pyframe->f_lasti*sizeof(_Py_CODEUNIT));
@ -399,7 +399,7 @@ traceback_get_frames(traceback_t *traceback)
return; return;
} }
InterpreterFrame *pyframe = tstate->cframe->current_frame; _PyInterpreterFrame *pyframe = tstate->cframe->current_frame;
for (; pyframe != NULL;) { for (; pyframe != NULL;) {
if (traceback->nframe < _Py_tracemalloc_config.max_nframe) { if (traceback->nframe < _Py_tracemalloc_config.max_nframe) {
tracemalloc_get_frame(pyframe, &traceback->frames[traceback->nframe]); tracemalloc_get_frame(pyframe, &traceback->frames[traceback->nframe]);
@ -410,7 +410,7 @@ traceback_get_frames(traceback_t *traceback)
traceback->total_nframe++; traceback->total_nframe++;
} }
InterpreterFrame *back = pyframe->previous; _PyInterpreterFrame *back = pyframe->previous;
pyframe = back; pyframe = back;
} }
} }

View File

@ -1839,7 +1839,7 @@ _is_running(PyInterpreterState *interp)
} }
assert(!PyErr_Occurred()); assert(!PyErr_Occurred());
InterpreterFrame *frame = tstate->cframe->current_frame; _PyInterpreterFrame *frame = tstate->cframe->current_frame;
if (frame == NULL) { if (frame == NULL) {
return 0; return 0;
} }

View File

@ -8,7 +8,7 @@
#include "pycore_call.h" // _PyObject_Call() #include "pycore_call.h" // _PyObject_Call()
#include "pycore_ceval.h" // _PyEval_SignalReceived() #include "pycore_ceval.h" // _PyEval_SignalReceived()
#include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH #include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH
#include "pycore_frame.h" // InterpreterFrame #include "pycore_frame.h" // _PyInterpreterFrame
#include "pycore_moduleobject.h" // _PyModule_GetState() #include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_pyerrors.h" // _PyErr_SetString() #include "pycore_pyerrors.h" // _PyErr_SetString()
#include "pycore_pylifecycle.h" // NSIG #include "pycore_pylifecycle.h" // NSIG
@ -1809,7 +1809,7 @@ _PyErr_CheckSignalsTstate(PyThreadState *tstate)
*/ */
_Py_atomic_store(&is_tripped, 0); _Py_atomic_store(&is_tripped, 0);
InterpreterFrame *frame = tstate->cframe->current_frame; _PyInterpreterFrame *frame = tstate->cframe->current_frame;
signal_state_t *state = &signal_global_state; signal_state_t *state = &signal_global_state;
for (int i = 1; i < NSIG; i++) { for (int i = 1; i < NSIG; i++) {
if (!_Py_atomic_load_relaxed(&Handlers[i].tripped)) { if (!_Py_atomic_load_relaxed(&Handlers[i].tripped)) {

View File

@ -629,8 +629,8 @@ frame_dealloc(PyFrameObject *f)
/* Kill all local variables including specials, if we own them */ /* Kill all local variables including specials, if we own them */
if (f->f_owns_frame) { if (f->f_owns_frame) {
f->f_owns_frame = 0; f->f_owns_frame = 0;
assert(f->f_frame == (InterpreterFrame *)f->_f_frame_data); assert(f->f_frame == (_PyInterpreterFrame *)f->_f_frame_data);
InterpreterFrame *frame = (InterpreterFrame *)f->_f_frame_data; _PyInterpreterFrame *frame = (_PyInterpreterFrame *)f->_f_frame_data;
/* Don't clear code object until the end */ /* Don't clear code object until the end */
co = frame->f_code; co = frame->f_code;
frame->f_code = NULL; frame->f_code = NULL;
@ -707,7 +707,7 @@ static PyObject *
frame_sizeof(PyFrameObject *f, PyObject *Py_UNUSED(ignored)) frame_sizeof(PyFrameObject *f, PyObject *Py_UNUSED(ignored))
{ {
Py_ssize_t res; Py_ssize_t res;
res = offsetof(PyFrameObject, _f_frame_data) + offsetof(InterpreterFrame, localsplus); res = offsetof(PyFrameObject, _f_frame_data) + offsetof(_PyInterpreterFrame, localsplus);
PyCodeObject *code = f->f_frame->f_code; PyCodeObject *code = f->f_frame->f_code;
res += (code->co_nlocalsplus+code->co_stacksize) * sizeof(PyObject *); res += (code->co_nlocalsplus+code->co_stacksize) * sizeof(PyObject *);
return PyLong_FromSsize_t(res); return PyLong_FromSsize_t(res);
@ -738,7 +738,7 @@ PyTypeObject PyFrame_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) PyVarObject_HEAD_INIT(&PyType_Type, 0)
"frame", "frame",
offsetof(PyFrameObject, _f_frame_data) + offsetof(PyFrameObject, _f_frame_data) +
offsetof(InterpreterFrame, localsplus), offsetof(_PyInterpreterFrame, localsplus),
sizeof(PyObject *), sizeof(PyObject *),
(destructor)frame_dealloc, /* tp_dealloc */ (destructor)frame_dealloc, /* tp_dealloc */
0, /* tp_vectorcall_offset */ 0, /* tp_vectorcall_offset */
@ -771,7 +771,7 @@ PyTypeObject PyFrame_Type = {
}; };
static void static void
init_frame(InterpreterFrame *frame, PyFunctionObject *func, PyObject *locals) init_frame(_PyInterpreterFrame *frame, PyFunctionObject *func, PyObject *locals)
{ {
/* _PyFrame_InitializeSpecials consumes reference to func */ /* _PyFrame_InitializeSpecials consumes reference to func */
Py_INCREF(func); Py_INCREF(func);
@ -827,8 +827,8 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code,
Py_DECREF(func); Py_DECREF(func);
return NULL; return NULL;
} }
init_frame((InterpreterFrame *)f->_f_frame_data, func, locals); init_frame((_PyInterpreterFrame *)f->_f_frame_data, func, locals);
f->f_frame = (InterpreterFrame *)f->_f_frame_data; f->f_frame = (_PyInterpreterFrame *)f->_f_frame_data;
f->f_owns_frame = 1; f->f_owns_frame = 1;
Py_DECREF(func); Py_DECREF(func);
_PyObject_GC_TRACK(f); _PyObject_GC_TRACK(f);
@ -836,7 +836,7 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code,
} }
static int static int
_PyFrame_OpAlreadyRan(InterpreterFrame *frame, int opcode, int oparg) _PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg)
{ {
const _Py_CODEUNIT *code = const _Py_CODEUNIT *code =
(const _Py_CODEUNIT *)PyBytes_AS_STRING(frame->f_code->co_code); (const _Py_CODEUNIT *)PyBytes_AS_STRING(frame->f_code->co_code);
@ -849,7 +849,7 @@ _PyFrame_OpAlreadyRan(InterpreterFrame *frame, int opcode, int oparg)
} }
int int
_PyFrame_FastToLocalsWithError(InterpreterFrame *frame) { _PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame) {
/* Merge fast locals into f->f_locals */ /* Merge fast locals into f->f_locals */
PyObject *locals; PyObject *locals;
PyObject **fast; PyObject **fast;
@ -960,7 +960,7 @@ PyFrame_FastToLocals(PyFrameObject *f)
} }
void void
_PyFrame_LocalsToFast(InterpreterFrame *frame, int clear) _PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear)
{ {
/* Merge locals into fast locals */ /* Merge locals into fast locals */
PyObject *locals; PyObject *locals;

View File

@ -7,7 +7,7 @@
#include "pycore_object.h" // _PyObject_GC_UNTRACK() #include "pycore_object.h" // _PyObject_GC_UNTRACK()
#include "pycore_pyerrors.h" // _PyErr_ClearExcState() #include "pycore_pyerrors.h" // _PyErr_ClearExcState()
#include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_frame.h" // InterpreterFrame #include "pycore_frame.h" // _PyInterpreterFrame
#include "frameobject.h" // PyFrameObject #include "frameobject.h" // PyFrameObject
#include "structmember.h" // PyMemberDef #include "structmember.h" // PyMemberDef
#include "opcode.h" // SEND #include "opcode.h" // SEND
@ -36,7 +36,7 @@ gen_traverse(PyGenObject *gen, visitproc visit, void *arg)
Py_VISIT(gen->gi_name); Py_VISIT(gen->gi_name);
Py_VISIT(gen->gi_qualname); Py_VISIT(gen->gi_qualname);
if (gen->gi_frame_valid) { if (gen->gi_frame_valid) {
InterpreterFrame *frame = (InterpreterFrame *)(gen->gi_iframe); _PyInterpreterFrame *frame = (_PyInterpreterFrame *)(gen->gi_iframe);
assert(frame->frame_obj == NULL || frame->frame_obj->f_owns_frame == 0); assert(frame->frame_obj == NULL || frame->frame_obj->f_owns_frame == 0);
int err = _PyFrame_Traverse(frame, visit, arg); int err = _PyFrame_Traverse(frame, visit, arg);
if (err) { if (err) {
@ -55,7 +55,7 @@ _PyGen_Finalize(PyObject *self)
PyObject *res = NULL; PyObject *res = NULL;
PyObject *error_type, *error_value, *error_traceback; PyObject *error_type, *error_value, *error_traceback;
if (gen->gi_frame_valid == 0 || _PyFrameHasCompleted((InterpreterFrame *)gen->gi_iframe)) { if (gen->gi_frame_valid == 0 || _PyFrameHasCompleted((_PyInterpreterFrame *)gen->gi_iframe)) {
/* Generator isn't paused, so no need to close */ /* Generator isn't paused, so no need to close */
return; return;
} }
@ -87,7 +87,7 @@ _PyGen_Finalize(PyObject *self)
issue a RuntimeWarning. */ issue a RuntimeWarning. */
if (gen->gi_code != NULL && if (gen->gi_code != NULL &&
((PyCodeObject *)gen->gi_code)->co_flags & CO_COROUTINE && ((PyCodeObject *)gen->gi_code)->co_flags & CO_COROUTINE &&
((InterpreterFrame *)gen->gi_iframe)->f_state == FRAME_CREATED) ((_PyInterpreterFrame *)gen->gi_iframe)->f_state == FRAME_CREATED)
{ {
_PyErr_WarnUnawaitedCoroutine((PyObject *)gen); _PyErr_WarnUnawaitedCoroutine((PyObject *)gen);
} }
@ -131,7 +131,7 @@ gen_dealloc(PyGenObject *gen)
Py_CLEAR(((PyAsyncGenObject*)gen)->ag_origin_or_finalizer); Py_CLEAR(((PyAsyncGenObject*)gen)->ag_origin_or_finalizer);
} }
if (gen->gi_frame_valid) { if (gen->gi_frame_valid) {
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe; _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
gen->gi_frame_valid = 0; gen->gi_frame_valid = 0;
frame->is_generator = false; frame->is_generator = false;
frame->previous = NULL; frame->previous = NULL;
@ -152,7 +152,7 @@ gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult,
int exc, int closing) int exc, int closing)
{ {
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe; _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
PyObject *result; PyObject *result;
*presult = NULL; *presult = NULL;
@ -348,7 +348,7 @@ _PyGen_yf(PyGenObject *gen)
PyObject *yf = NULL; PyObject *yf = NULL;
if (gen->gi_frame_valid) { if (gen->gi_frame_valid) {
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe; _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
PyObject *bytecode = gen->gi_code->co_code; PyObject *bytecode = gen->gi_code->co_code;
unsigned char *code = (unsigned char *)PyBytes_AS_STRING(bytecode); unsigned char *code = (unsigned char *)PyBytes_AS_STRING(bytecode);
@ -377,7 +377,7 @@ gen_close(PyGenObject *gen, PyObject *args)
int err = 0; int err = 0;
if (yf) { if (yf) {
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe; _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
PyFrameState state = frame->f_state; PyFrameState state = frame->f_state;
frame->f_state = FRAME_EXECUTING; frame->f_state = FRAME_EXECUTING;
err = gen_close_iter(yf); err = gen_close_iter(yf);
@ -418,7 +418,7 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
PyObject *yf = _PyGen_yf(gen); PyObject *yf = _PyGen_yf(gen);
if (yf) { if (yf) {
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe; _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
PyObject *ret; PyObject *ret;
int err; int err;
if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) &&
@ -445,7 +445,7 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
will be reported correctly to the user. */ will be reported correctly to the user. */
/* XXX We should probably be updating the current frame /* XXX We should probably be updating the current frame
somewhere in ceval.c. */ somewhere in ceval.c. */
InterpreterFrame *prev = tstate->cframe->current_frame; _PyInterpreterFrame *prev = tstate->cframe->current_frame;
frame->previous = prev; frame->previous = prev;
tstate->cframe->current_frame = frame; tstate->cframe->current_frame = frame;
/* Close the generator that we are currently iterating with /* Close the generator that we are currently iterating with
@ -479,7 +479,7 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
PyObject *val; PyObject *val;
/* Pop subiterator from stack */ /* Pop subiterator from stack */
assert(gen->gi_frame_valid); assert(gen->gi_frame_valid);
ret = _PyFrame_StackPop((InterpreterFrame *)gen->gi_iframe); ret = _PyFrame_StackPop((_PyInterpreterFrame *)gen->gi_iframe);
assert(ret == yf); assert(ret == yf);
Py_DECREF(ret); Py_DECREF(ret);
/* Termination repetition of SEND loop */ /* Termination repetition of SEND loop */
@ -750,7 +750,7 @@ gen_getrunning(PyGenObject *gen, void *Py_UNUSED(ignored))
if (gen->gi_frame_valid == 0) { if (gen->gi_frame_valid == 0) {
Py_RETURN_FALSE; Py_RETURN_FALSE;
} }
return PyBool_FromLong(_PyFrame_IsExecuting((InterpreterFrame *)gen->gi_iframe)); return PyBool_FromLong(_PyFrame_IsExecuting((_PyInterpreterFrame *)gen->gi_iframe));
} }
static PyObject * static PyObject *
@ -759,7 +759,7 @@ gen_getsuspended(PyGenObject *gen, void *Py_UNUSED(ignored))
if (gen->gi_frame_valid == 0) { if (gen->gi_frame_valid == 0) {
Py_RETURN_FALSE; Py_RETURN_FALSE;
} }
return PyBool_FromLong(((InterpreterFrame *)gen->gi_iframe)->f_state == FRAME_SUSPENDED); return PyBool_FromLong(((_PyInterpreterFrame *)gen->gi_iframe)->f_state == FRAME_SUSPENDED);
} }
static PyObject * static PyObject *
@ -771,7 +771,7 @@ _gen_getframe(PyGenObject *gen, const char *const name)
if (gen->gi_frame_valid == 0) { if (gen->gi_frame_valid == 0) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
return _Py_XNewRef((PyObject *)_PyFrame_GetFrameObject((InterpreterFrame *)gen->gi_iframe)); return _Py_XNewRef((PyObject *)_PyFrame_GetFrameObject((_PyInterpreterFrame *)gen->gi_iframe));
} }
static PyObject * static PyObject *
@ -802,7 +802,7 @@ static PyObject *
gen_sizeof(PyGenObject *gen, PyObject *Py_UNUSED(ignored)) gen_sizeof(PyGenObject *gen, PyObject *Py_UNUSED(ignored))
{ {
Py_ssize_t res; Py_ssize_t res;
res = offsetof(PyGenObject, gi_iframe) + offsetof(InterpreterFrame, localsplus); res = offsetof(PyGenObject, gi_iframe) + offsetof(_PyInterpreterFrame, localsplus);
PyCodeObject *code = gen->gi_code; PyCodeObject *code = gen->gi_code;
res += (code->co_nlocalsplus+code->co_stacksize) * sizeof(PyObject *); res += (code->co_nlocalsplus+code->co_stacksize) * sizeof(PyObject *);
return PyLong_FromSsize_t(res); return PyLong_FromSsize_t(res);
@ -831,7 +831,7 @@ PyTypeObject PyGen_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) PyVarObject_HEAD_INIT(&PyType_Type, 0)
"generator", /* tp_name */ "generator", /* tp_name */
offsetof(PyGenObject, gi_iframe) + offsetof(PyGenObject, gi_iframe) +
offsetof(InterpreterFrame, localsplus), /* tp_basicsize */ offsetof(_PyInterpreterFrame, localsplus), /* tp_basicsize */
sizeof(PyObject *), /* tp_itemsize */ sizeof(PyObject *), /* tp_itemsize */
/* methods */ /* methods */
(destructor)gen_dealloc, /* tp_dealloc */ (destructor)gen_dealloc, /* tp_dealloc */
@ -905,7 +905,7 @@ make_gen(PyTypeObject *type, PyFunctionObject *func)
} }
static PyObject * static PyObject *
compute_cr_origin(int origin_depth, InterpreterFrame *current_frame); compute_cr_origin(int origin_depth, _PyInterpreterFrame *current_frame);
PyObject * PyObject *
_Py_MakeCoro(PyFunctionObject *func) _Py_MakeCoro(PyFunctionObject *func)
@ -964,8 +964,8 @@ gen_new_with_qualname(PyTypeObject *type, PyFrameObject *f,
/* Copy the frame */ /* Copy the frame */
assert(f->f_frame->frame_obj == NULL); assert(f->f_frame->frame_obj == NULL);
assert(f->f_owns_frame); assert(f->f_owns_frame);
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe; _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
_PyFrame_Copy((InterpreterFrame *)f->_f_frame_data, frame); _PyFrame_Copy((_PyInterpreterFrame *)f->_f_frame_data, frame);
gen->gi_frame_valid = 1; gen->gi_frame_valid = 1;
assert(frame->frame_obj == f); assert(frame->frame_obj == f);
f->f_owns_frame = 0; f->f_owns_frame = 0;
@ -1108,7 +1108,7 @@ cr_getsuspended(PyCoroObject *coro, void *Py_UNUSED(ignored))
if (coro->cr_frame_valid == 0) { if (coro->cr_frame_valid == 0) {
Py_RETURN_FALSE; Py_RETURN_FALSE;
} }
return PyBool_FromLong(((InterpreterFrame *)coro->cr_iframe)->f_state == FRAME_SUSPENDED); return PyBool_FromLong(((_PyInterpreterFrame *)coro->cr_iframe)->f_state == FRAME_SUSPENDED);
} }
static PyObject * static PyObject *
@ -1117,7 +1117,7 @@ cr_getrunning(PyCoroObject *coro, void *Py_UNUSED(ignored))
if (coro->cr_frame_valid == 0) { if (coro->cr_frame_valid == 0) {
Py_RETURN_FALSE; Py_RETURN_FALSE;
} }
return PyBool_FromLong(_PyFrame_IsExecuting((InterpreterFrame *)coro->cr_iframe)); return PyBool_FromLong(_PyFrame_IsExecuting((_PyInterpreterFrame *)coro->cr_iframe));
} }
static PyObject * static PyObject *
@ -1176,7 +1176,7 @@ PyTypeObject PyCoro_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) PyVarObject_HEAD_INIT(&PyType_Type, 0)
"coroutine", /* tp_name */ "coroutine", /* tp_name */
offsetof(PyCoroObject, cr_iframe) + offsetof(PyCoroObject, cr_iframe) +
offsetof(InterpreterFrame, localsplus), /* tp_basicsize */ offsetof(_PyInterpreterFrame, localsplus), /* tp_basicsize */
sizeof(PyObject *), /* tp_itemsize */ sizeof(PyObject *), /* tp_itemsize */
/* methods */ /* methods */
(destructor)gen_dealloc, /* tp_dealloc */ (destructor)gen_dealloc, /* tp_dealloc */
@ -1314,9 +1314,9 @@ PyTypeObject _PyCoroWrapper_Type = {
}; };
static PyObject * static PyObject *
compute_cr_origin(int origin_depth, InterpreterFrame *current_frame) compute_cr_origin(int origin_depth, _PyInterpreterFrame *current_frame)
{ {
InterpreterFrame *frame = current_frame; _PyInterpreterFrame *frame = current_frame;
/* First count how many frames we have */ /* First count how many frames we have */
int frame_count = 0; int frame_count = 0;
for (; frame && frame_count < origin_depth; ++frame_count) { for (; frame && frame_count < origin_depth; ++frame_count) {
@ -1567,7 +1567,7 @@ PyTypeObject PyAsyncGen_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) PyVarObject_HEAD_INIT(&PyType_Type, 0)
"async_generator", /* tp_name */ "async_generator", /* tp_name */
offsetof(PyAsyncGenObject, ag_iframe) + offsetof(PyAsyncGenObject, ag_iframe) +
offsetof(InterpreterFrame, localsplus), /* tp_basicsize */ offsetof(_PyInterpreterFrame, localsplus), /* tp_basicsize */
sizeof(PyObject *), /* tp_itemsize */ sizeof(PyObject *), /* tp_itemsize */
/* methods */ /* methods */
(destructor)gen_dealloc, /* tp_dealloc */ (destructor)gen_dealloc, /* tp_dealloc */
@ -2053,7 +2053,7 @@ static PyObject *
async_gen_athrow_send(PyAsyncGenAThrow *o, PyObject *arg) async_gen_athrow_send(PyAsyncGenAThrow *o, PyObject *arg)
{ {
PyGenObject *gen = (PyGenObject*)o->agt_gen; PyGenObject *gen = (PyGenObject*)o->agt_gen;
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe; _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
PyObject *retval; PyObject *retval;
if (o->agt_state == AWAITABLE_STATE_CLOSED) { if (o->agt_state == AWAITABLE_STATE_CLOSED) {

View File

@ -12,7 +12,7 @@
#include "pycore_typeobject.h" // struct type_cache #include "pycore_typeobject.h" // struct type_cache
#include "pycore_unionobject.h" // _Py_union_type_or #include "pycore_unionobject.h" // _Py_union_type_or
#include "frameobject.h" // PyFrameObject #include "frameobject.h" // PyFrameObject
#include "pycore_frame.h" // InterpreterFrame #include "pycore_frame.h" // _PyInterpreterFrame
#include "opcode.h" // MAKE_CELL #include "opcode.h" // MAKE_CELL
#include "structmember.h" // PyMemberDef #include "structmember.h" // PyMemberDef
@ -8933,7 +8933,7 @@ super_descr_get(PyObject *self, PyObject *obj, PyObject *type)
} }
static int static int
super_init_without_args(InterpreterFrame *cframe, PyCodeObject *co, super_init_without_args(_PyInterpreterFrame *cframe, PyCodeObject *co,
PyTypeObject **type_p, PyObject **obj_p) PyTypeObject **type_p, PyObject **obj_p)
{ {
if (co->co_argcount == 0) { if (co->co_argcount == 0) {
@ -9017,7 +9017,7 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
/* Call super(), without args -- fill in from __class__ /* Call super(), without args -- fill in from __class__
and first local variable on the stack. */ and first local variable on the stack. */
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
InterpreterFrame *cframe = tstate->cframe->current_frame; _PyInterpreterFrame *cframe = tstate->cframe->current_frame;
if (cframe == NULL) { if (cframe == NULL) {
PyErr_SetString(PyExc_RuntimeError, PyErr_SetString(PyExc_RuntimeError,
"super(): no current frame"); "super(): no current frame");

View File

@ -59,7 +59,7 @@ static PyObject * do_call_core(
#ifdef LLTRACE #ifdef LLTRACE
static int lltrace; static int lltrace;
static int prtrace(PyThreadState *, PyObject *, const char *); static int prtrace(PyThreadState *, PyObject *, const char *);
static void lltrace_instruction(InterpreterFrame *frame, int opcode, int oparg) static void lltrace_instruction(_PyInterpreterFrame *frame, int opcode, int oparg)
{ {
if (HAS_ARG(opcode)) { if (HAS_ARG(opcode)) {
printf("%d: %d, %d\n", printf("%d: %d, %d\n",
@ -72,20 +72,20 @@ static void lltrace_instruction(InterpreterFrame *frame, int opcode, int oparg)
} }
#endif #endif
static int call_trace(Py_tracefunc, PyObject *, static int call_trace(Py_tracefunc, PyObject *,
PyThreadState *, InterpreterFrame *, PyThreadState *, _PyInterpreterFrame *,
int, PyObject *); int, PyObject *);
static int call_trace_protected(Py_tracefunc, PyObject *, static int call_trace_protected(Py_tracefunc, PyObject *,
PyThreadState *, InterpreterFrame *, PyThreadState *, _PyInterpreterFrame *,
int, PyObject *); int, PyObject *);
static void call_exc_trace(Py_tracefunc, PyObject *, static void call_exc_trace(Py_tracefunc, PyObject *,
PyThreadState *, InterpreterFrame *); PyThreadState *, _PyInterpreterFrame *);
static int maybe_call_line_trace(Py_tracefunc, PyObject *, static int maybe_call_line_trace(Py_tracefunc, PyObject *,
PyThreadState *, InterpreterFrame *, int); PyThreadState *, _PyInterpreterFrame *, int);
static void maybe_dtrace_line(InterpreterFrame *, PyTraceInfo *, int); static void maybe_dtrace_line(_PyInterpreterFrame *, PyTraceInfo *, int);
static void dtrace_function_entry(InterpreterFrame *); static void dtrace_function_entry(_PyInterpreterFrame *);
static void dtrace_function_return(InterpreterFrame *); static void dtrace_function_return(_PyInterpreterFrame *);
static PyObject * import_name(PyThreadState *, InterpreterFrame *, static PyObject * import_name(PyThreadState *, _PyInterpreterFrame *,
PyObject *, PyObject *, PyObject *); PyObject *, PyObject *, PyObject *);
static PyObject * import_from(PyThreadState *, PyObject *, PyObject *); static PyObject * import_from(PyThreadState *, PyObject *, PyObject *);
static int import_all_from(PyThreadState *, PyObject *, PyObject *); static int import_all_from(PyThreadState *, PyObject *, PyObject *);
@ -97,12 +97,12 @@ static int check_except_star_type_valid(PyThreadState *tstate, PyObject* right);
static void format_kwargs_error(PyThreadState *, PyObject *func, PyObject *kwargs); static void format_kwargs_error(PyThreadState *, PyObject *func, PyObject *kwargs);
static void format_awaitable_error(PyThreadState *, PyTypeObject *, int, int); static void format_awaitable_error(PyThreadState *, PyTypeObject *, int, int);
static int get_exception_handler(PyCodeObject *, int, int*, int*, int*); static int get_exception_handler(PyCodeObject *, int, int*, int*, int*);
static InterpreterFrame * static _PyInterpreterFrame *
_PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func, _PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
PyObject *locals, PyObject* const* args, PyObject *locals, PyObject* const* args,
size_t argcount, PyObject *kwnames); size_t argcount, PyObject *kwnames);
static void static void
_PyEvalFrameClearAndPop(PyThreadState *tstate, InterpreterFrame *frame); _PyEvalFrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame *frame);
#define NAME_ERROR_MSG \ #define NAME_ERROR_MSG \
"name '%.200s' is not defined" "name '%.200s' is not defined"
@ -1509,7 +1509,7 @@ eval_frame_handle_pending(PyThreadState *tstate)
static int static int
trace_function_entry(PyThreadState *tstate, InterpreterFrame *frame) trace_function_entry(PyThreadState *tstate, _PyInterpreterFrame *frame)
{ {
if (tstate->c_tracefunc != NULL) { if (tstate->c_tracefunc != NULL) {
/* tstate->c_tracefunc, if defined, is a /* tstate->c_tracefunc, if defined, is a
@ -1548,7 +1548,7 @@ trace_function_entry(PyThreadState *tstate, InterpreterFrame *frame)
} }
static int static int
trace_function_exit(PyThreadState *tstate, InterpreterFrame *frame, PyObject *retval) trace_function_exit(PyThreadState *tstate, _PyInterpreterFrame *frame, PyObject *retval)
{ {
if (tstate->c_tracefunc) { if (tstate->c_tracefunc) {
if (call_trace_protected(tstate->c_tracefunc, tstate->c_traceobj, if (call_trace_protected(tstate->c_tracefunc, tstate->c_traceobj,
@ -1575,10 +1575,10 @@ skip_backwards_over_extended_args(PyCodeObject *code, int offset)
return offset; return offset;
} }
static InterpreterFrame * static _PyInterpreterFrame *
pop_frame(PyThreadState *tstate, InterpreterFrame *frame) pop_frame(PyThreadState *tstate, _PyInterpreterFrame *frame)
{ {
InterpreterFrame *prev_frame = frame->previous; _PyInterpreterFrame *prev_frame = frame->previous;
_PyEvalFrameClearAndPop(tstate, frame); _PyEvalFrameClearAndPop(tstate, frame);
return prev_frame; return prev_frame;
} }
@ -1599,7 +1599,7 @@ is_method(PyObject **stack_pointer, int args) {
(call_shape.kwnames == NULL ? 0 : ((int)PyTuple_GET_SIZE(call_shape.kwnames))) (call_shape.kwnames == NULL ? 0 : ((int)PyTuple_GET_SIZE(call_shape.kwnames)))
PyObject* _Py_HOT_FUNCTION PyObject* _Py_HOT_FUNCTION
_PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int throwflag) _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
{ {
_Py_EnsureTstateNotNULL(tstate); _Py_EnsureTstateNotNULL(tstate);
CALL_STAT_INC(pyeval_calls); CALL_STAT_INC(pyeval_calls);
@ -2203,7 +2203,7 @@ handle_eval_breaker:
PyCodeObject *code = (PyCodeObject *)getitem->func_code; PyCodeObject *code = (PyCodeObject *)getitem->func_code;
size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE; size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE;
assert(code->co_argcount == 2); assert(code->co_argcount == 2);
InterpreterFrame *new_frame = _PyThreadState_BumpFramePointer(tstate, size); _PyInterpreterFrame *new_frame = _PyThreadState_BumpFramePointer(tstate, size);
if (new_frame == NULL) { if (new_frame == NULL) {
goto error; goto error;
} }
@ -4644,7 +4644,7 @@ handle_eval_breaker:
int code_flags = ((PyCodeObject*)PyFunction_GET_CODE(function))->co_flags; int code_flags = ((PyCodeObject*)PyFunction_GET_CODE(function))->co_flags;
PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : PyFunction_GET_GLOBALS(function); PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : PyFunction_GET_GLOBALS(function);
STACK_SHRINK(total_args); STACK_SHRINK(total_args);
InterpreterFrame *new_frame = _PyEvalFramePushAndInit( _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit(
tstate, (PyFunctionObject *)function, locals, tstate, (PyFunctionObject *)function, locals,
stack_pointer, positional_args, call_shape.kwnames stack_pointer, positional_args, call_shape.kwnames
); );
@ -4753,7 +4753,7 @@ handle_eval_breaker:
PyCodeObject *code = (PyCodeObject *)func->func_code; PyCodeObject *code = (PyCodeObject *)func->func_code;
DEOPT_IF(code->co_argcount != argcount, CALL); DEOPT_IF(code->co_argcount != argcount, CALL);
STAT_INC(CALL, hit); STAT_INC(CALL, hit);
InterpreterFrame *new_frame = _PyFrame_Push(tstate, func); _PyInterpreterFrame *new_frame = _PyFrame_Push(tstate, func);
if (new_frame == NULL) { if (new_frame == NULL) {
goto error; goto error;
} }
@ -4788,7 +4788,7 @@ handle_eval_breaker:
int minargs = cache1->min_args; int minargs = cache1->min_args;
DEOPT_IF(argcount < minargs, CALL); DEOPT_IF(argcount < minargs, CALL);
STAT_INC(CALL, hit); STAT_INC(CALL, hit);
InterpreterFrame *new_frame = _PyFrame_Push(tstate, func); _PyInterpreterFrame *new_frame = _PyFrame_Push(tstate, func);
if (new_frame == NULL) { if (new_frame == NULL) {
goto error; goto error;
} }
@ -5306,7 +5306,7 @@ handle_eval_breaker:
} }
assert(EMPTY()); assert(EMPTY());
_PyFrame_SetStackPointer(frame, stack_pointer); _PyFrame_SetStackPointer(frame, stack_pointer);
InterpreterFrame *gen_frame = (InterpreterFrame *)gen->gi_iframe; _PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
_PyFrame_Copy(frame, gen_frame); _PyFrame_Copy(frame, gen_frame);
assert(frame->frame_obj == NULL); assert(frame->frame_obj == NULL);
gen->gi_frame_valid = 1; gen->gi_frame_valid = 1;
@ -5314,7 +5314,7 @@ handle_eval_breaker:
gen_frame->f_state = FRAME_CREATED; gen_frame->f_state = FRAME_CREATED;
_Py_LeaveRecursiveCall(tstate); _Py_LeaveRecursiveCall(tstate);
if (!frame->is_entry) { if (!frame->is_entry) {
InterpreterFrame *prev = frame->previous; _PyInterpreterFrame *prev = frame->previous;
_PyThreadState_PopFrame(tstate, frame); _PyThreadState_PopFrame(tstate, frame);
frame = cframe.current_frame = prev; frame = cframe.current_frame = prev;
_PyFrame_StackPush(frame, (PyObject *)gen); _PyFrame_StackPush(frame, (PyObject *)gen);
@ -6292,7 +6292,7 @@ fail_post_args:
} }
/* Consumes references to func and all the args */ /* Consumes references to func and all the args */
static InterpreterFrame * static _PyInterpreterFrame *
_PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func, _PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
PyObject *locals, PyObject* const* args, PyObject *locals, PyObject* const* args,
size_t argcount, PyObject *kwnames) size_t argcount, PyObject *kwnames)
@ -6300,7 +6300,7 @@ _PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
PyCodeObject * code = (PyCodeObject *)func->func_code; PyCodeObject * code = (PyCodeObject *)func->func_code;
size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE; size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE;
CALL_STAT_INC(frames_pushed); CALL_STAT_INC(frames_pushed);
InterpreterFrame *frame = _PyThreadState_BumpFramePointer(tstate, size); _PyInterpreterFrame *frame = _PyThreadState_BumpFramePointer(tstate, size);
if (frame == NULL) { if (frame == NULL) {
goto fail; goto fail;
} }
@ -6330,7 +6330,7 @@ fail:
} }
static void static void
_PyEvalFrameClearAndPop(PyThreadState *tstate, InterpreterFrame * frame) _PyEvalFrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame * frame)
{ {
tstate->recursion_remaining--; tstate->recursion_remaining--;
assert(frame->frame_obj == NULL || frame->frame_obj->f_owns_frame == 0); assert(frame->frame_obj == NULL || frame->frame_obj->f_owns_frame == 0);
@ -6357,7 +6357,7 @@ _PyEval_Vector(PyThreadState *tstate, PyFunctionObject *func,
Py_INCREF(args[i+argcount]); Py_INCREF(args[i+argcount]);
} }
} }
InterpreterFrame *frame = _PyEvalFramePushAndInit( _PyInterpreterFrame *frame = _PyEvalFramePushAndInit(
tstate, func, locals, args, argcount, kwnames); tstate, func, locals, args, argcount, kwnames);
if (frame == NULL) { if (frame == NULL) {
return NULL; return NULL;
@ -6726,7 +6726,7 @@ prtrace(PyThreadState *tstate, PyObject *v, const char *str)
static void static void
call_exc_trace(Py_tracefunc func, PyObject *self, call_exc_trace(Py_tracefunc func, PyObject *self,
PyThreadState *tstate, PyThreadState *tstate,
InterpreterFrame *f) _PyInterpreterFrame *f)
{ {
PyObject *type, *value, *traceback, *orig_traceback, *arg; PyObject *type, *value, *traceback, *orig_traceback, *arg;
int err; int err;
@ -6756,7 +6756,7 @@ call_exc_trace(Py_tracefunc func, PyObject *self,
static int static int
call_trace_protected(Py_tracefunc func, PyObject *obj, call_trace_protected(Py_tracefunc func, PyObject *obj,
PyThreadState *tstate, InterpreterFrame *frame, PyThreadState *tstate, _PyInterpreterFrame *frame,
int what, PyObject *arg) int what, PyObject *arg)
{ {
PyObject *type, *value, *traceback; PyObject *type, *value, *traceback;
@ -6777,7 +6777,7 @@ call_trace_protected(Py_tracefunc func, PyObject *obj,
} }
static void static void
initialize_trace_info(PyTraceInfo *trace_info, InterpreterFrame *frame) initialize_trace_info(PyTraceInfo *trace_info, _PyInterpreterFrame *frame)
{ {
PyCodeObject *code = frame->f_code; PyCodeObject *code = frame->f_code;
if (trace_info->code != code) { if (trace_info->code != code) {
@ -6788,7 +6788,7 @@ initialize_trace_info(PyTraceInfo *trace_info, InterpreterFrame *frame)
static int static int
call_trace(Py_tracefunc func, PyObject *obj, call_trace(Py_tracefunc func, PyObject *obj,
PyThreadState *tstate, InterpreterFrame *frame, PyThreadState *tstate, _PyInterpreterFrame *frame,
int what, PyObject *arg) int what, PyObject *arg)
{ {
int result; int result;
@ -6829,7 +6829,7 @@ _PyEval_CallTracing(PyObject *func, PyObject *args)
/* See Objects/lnotab_notes.txt for a description of how tracing works. */ /* See Objects/lnotab_notes.txt for a description of how tracing works. */
static int static int
maybe_call_line_trace(Py_tracefunc func, PyObject *obj, maybe_call_line_trace(Py_tracefunc func, PyObject *obj,
PyThreadState *tstate, InterpreterFrame *frame, int instr_prev) PyThreadState *tstate, _PyInterpreterFrame *frame, int instr_prev)
{ {
int result = 0; int result = 0;
@ -7007,7 +7007,7 @@ _PyEval_GetAsyncGenFinalizer(void)
return tstate->async_gen_finalizer; return tstate->async_gen_finalizer;
} }
InterpreterFrame * _PyInterpreterFrame *
_PyEval_GetFrame(void) _PyEval_GetFrame(void)
{ {
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
@ -7031,7 +7031,7 @@ PyEval_GetFrame(void)
PyObject * PyObject *
_PyEval_GetBuiltins(PyThreadState *tstate) _PyEval_GetBuiltins(PyThreadState *tstate)
{ {
InterpreterFrame *frame = tstate->cframe->current_frame; _PyInterpreterFrame *frame = tstate->cframe->current_frame;
if (frame != NULL) { if (frame != NULL) {
return frame->f_builtins; return frame->f_builtins;
} }
@ -7070,7 +7070,7 @@ PyObject *
PyEval_GetLocals(void) PyEval_GetLocals(void)
{ {
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
InterpreterFrame *current_frame = tstate->cframe->current_frame; _PyInterpreterFrame *current_frame = tstate->cframe->current_frame;
if (current_frame == NULL) { if (current_frame == NULL) {
_PyErr_SetString(tstate, PyExc_SystemError, "frame does not exist"); _PyErr_SetString(tstate, PyExc_SystemError, "frame does not exist");
return NULL; return NULL;
@ -7089,7 +7089,7 @@ PyObject *
PyEval_GetGlobals(void) PyEval_GetGlobals(void)
{ {
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
InterpreterFrame *current_frame = tstate->cframe->current_frame; _PyInterpreterFrame *current_frame = tstate->cframe->current_frame;
if (current_frame == NULL) { if (current_frame == NULL) {
return NULL; return NULL;
} }
@ -7100,7 +7100,7 @@ int
PyEval_MergeCompilerFlags(PyCompilerFlags *cf) PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
{ {
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
InterpreterFrame *current_frame = tstate->cframe->current_frame; _PyInterpreterFrame *current_frame = tstate->cframe->current_frame;
int result = cf->cf_flags != 0; int result = cf->cf_flags != 0;
if (current_frame != NULL) { if (current_frame != NULL) {
@ -7304,7 +7304,7 @@ _PyEval_SliceIndexNotNone(PyObject *v, Py_ssize_t *pi)
} }
static PyObject * static PyObject *
import_name(PyThreadState *tstate, InterpreterFrame *frame, import_name(PyThreadState *tstate, _PyInterpreterFrame *frame,
PyObject *name, PyObject *fromlist, PyObject *level) PyObject *name, PyObject *fromlist, PyObject *level)
{ {
PyObject *import_func, *res; PyObject *import_func, *res;
@ -7775,7 +7775,7 @@ _PyEval_RequestCodeExtraIndex(freefunc free)
} }
static void static void
dtrace_function_entry(InterpreterFrame *frame) dtrace_function_entry(_PyInterpreterFrame *frame)
{ {
const char *filename; const char *filename;
const char *funcname; const char *funcname;
@ -7790,7 +7790,7 @@ dtrace_function_entry(InterpreterFrame *frame)
} }
static void static void
dtrace_function_return(InterpreterFrame *frame) dtrace_function_return(_PyInterpreterFrame *frame)
{ {
const char *filename; const char *filename;
const char *funcname; const char *funcname;
@ -7806,7 +7806,7 @@ dtrace_function_return(InterpreterFrame *frame)
/* DTrace equivalent of maybe_call_line_trace. */ /* DTrace equivalent of maybe_call_line_trace. */
static void static void
maybe_dtrace_line(InterpreterFrame *frame, maybe_dtrace_line(_PyInterpreterFrame *frame,
PyTraceInfo *trace_info, PyTraceInfo *trace_info,
int instr_prev) int instr_prev)
{ {

View File

@ -7,7 +7,7 @@
#include "opcode.h" #include "opcode.h"
int int
_PyFrame_Traverse(InterpreterFrame *frame, visitproc visit, void *arg) _PyFrame_Traverse(_PyInterpreterFrame *frame, visitproc visit, void *arg)
{ {
Py_VISIT(frame->frame_obj); Py_VISIT(frame->frame_obj);
Py_VISIT(frame->f_locals); Py_VISIT(frame->f_locals);
@ -24,7 +24,7 @@ _PyFrame_Traverse(InterpreterFrame *frame, visitproc visit, void *arg)
} }
PyFrameObject * PyFrameObject *
_PyFrame_MakeAndSetFrameObject(InterpreterFrame *frame) _PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame)
{ {
assert(frame->frame_obj == NULL); assert(frame->frame_obj == NULL);
PyObject *error_type, *error_value, *error_traceback; PyObject *error_type, *error_value, *error_traceback;
@ -46,7 +46,7 @@ _PyFrame_MakeAndSetFrameObject(InterpreterFrame *frame)
} }
void void
_PyFrame_Copy(InterpreterFrame *src, InterpreterFrame *dest) _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest)
{ {
assert(src->stacktop >= src->f_code->co_nlocalsplus); assert(src->stacktop >= src->f_code->co_nlocalsplus);
Py_ssize_t size = ((char*)&src->localsplus[src->stacktop]) - (char *)src; Py_ssize_t size = ((char*)&src->localsplus[src->stacktop]) - (char *)src;
@ -55,17 +55,17 @@ _PyFrame_Copy(InterpreterFrame *src, InterpreterFrame *dest)
static void static void
take_ownership(PyFrameObject *f, InterpreterFrame *frame) take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
{ {
assert(f->f_owns_frame == 0); assert(f->f_owns_frame == 0);
Py_ssize_t size = ((char*)&frame->localsplus[frame->stacktop]) - (char *)frame; Py_ssize_t size = ((char*)&frame->localsplus[frame->stacktop]) - (char *)frame;
memcpy((InterpreterFrame *)f->_f_frame_data, frame, size); memcpy((_PyInterpreterFrame *)f->_f_frame_data, frame, size);
frame = (InterpreterFrame *)f->_f_frame_data; frame = (_PyInterpreterFrame *)f->_f_frame_data;
f->f_owns_frame = 1; f->f_owns_frame = 1;
f->f_frame = frame; f->f_frame = frame;
assert(f->f_back == NULL); assert(f->f_back == NULL);
if (frame->previous != NULL) { if (frame->previous != NULL) {
/* Link PyFrameObjects.f_back and remove link through InterpreterFrame.previous */ /* Link PyFrameObjects.f_back and remove link through _PyInterpreterFrame.previous */
PyFrameObject *back = _PyFrame_GetFrameObject(frame->previous); PyFrameObject *back = _PyFrame_GetFrameObject(frame->previous);
if (back == NULL) { if (back == NULL) {
/* Memory error here. */ /* Memory error here. */
@ -84,7 +84,7 @@ take_ownership(PyFrameObject *f, InterpreterFrame *frame)
} }
void void
_PyFrame_Clear(InterpreterFrame *frame) _PyFrame_Clear(_PyInterpreterFrame *frame)
{ {
/* It is the responsibility of the owning generator/coroutine /* It is the responsibility of the owning generator/coroutine
* to have cleared the enclosing generator, if any. */ * to have cleared the enclosing generator, if any. */
@ -110,13 +110,13 @@ _PyFrame_Clear(InterpreterFrame *frame)
} }
/* Consumes reference to func */ /* Consumes reference to func */
InterpreterFrame * _PyInterpreterFrame *
_PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func) _PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func)
{ {
PyCodeObject *code = (PyCodeObject *)func->func_code; PyCodeObject *code = (PyCodeObject *)func->func_code;
size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE; size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE;
CALL_STAT_INC(frames_pushed); CALL_STAT_INC(frames_pushed);
InterpreterFrame *new_frame = _PyThreadState_BumpFramePointer(tstate, size); _PyInterpreterFrame *new_frame = _PyThreadState_BumpFramePointer(tstate, size);
if (new_frame == NULL) { if (new_frame == NULL) {
Py_DECREF(func); Py_DECREF(func);
return NULL; return NULL;

View File

@ -1410,7 +1410,7 @@ _PyThread_CurrentFrames(void)
for (i = runtime->interpreters.head; i != NULL; i = i->next) { for (i = runtime->interpreters.head; i != NULL; i = i->next) {
PyThreadState *t; PyThreadState *t;
for (t = i->threads.head; t != NULL; t = t->next) { for (t = i->threads.head; t != NULL; t = t->next) {
InterpreterFrame *frame = t->cframe->current_frame; _PyInterpreterFrame *frame = t->cframe->current_frame;
if (frame == NULL) { if (frame == NULL) {
continue; continue;
} }
@ -2197,7 +2197,7 @@ push_chunk(PyThreadState *tstate, int size)
return res; return res;
} }
InterpreterFrame * _PyInterpreterFrame *
_PyThreadState_BumpFramePointerSlow(PyThreadState *tstate, size_t size) _PyThreadState_BumpFramePointerSlow(PyThreadState *tstate, size_t size)
{ {
assert(size < INT_MAX/sizeof(PyObject *)); assert(size < INT_MAX/sizeof(PyObject *));
@ -2209,11 +2209,11 @@ _PyThreadState_BumpFramePointerSlow(PyThreadState *tstate, size_t size)
else { else {
tstate->datastack_top = top; tstate->datastack_top = top;
} }
return (InterpreterFrame *)base; return (_PyInterpreterFrame *)base;
} }
void void
_PyThreadState_PopFrame(PyThreadState *tstate, InterpreterFrame * frame) _PyThreadState_PopFrame(PyThreadState *tstate, _PyInterpreterFrame * frame)
{ {
assert(tstate->datastack_chunk); assert(tstate->datastack_chunk);
PyObject **base = (PyObject **)frame; PyObject **base = (PyObject **)frame;

View File

@ -18,7 +18,7 @@ Data members:
#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_ceval.h" // _Py_RecursionLimitLowerWaterMark() #include "pycore_ceval.h" // _Py_RecursionLimitLowerWaterMark()
#include "pycore_code.h" // _Py_QuickenedCount #include "pycore_code.h" // _Py_QuickenedCount
#include "pycore_frame.h" // InterpreterFrame #include "pycore_frame.h" // _PyInterpreterFrame
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION() #include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
#include "pycore_namespace.h" // _PyNamespace_New() #include "pycore_namespace.h" // _PyNamespace_New()
#include "pycore_object.h" // _PyObject_IS_GC() #include "pycore_object.h" // _PyObject_IS_GC()
@ -1807,7 +1807,7 @@ sys__getframe_impl(PyObject *module, int depth)
/*[clinic end generated code: output=d438776c04d59804 input=c1be8a6464b11ee5]*/ /*[clinic end generated code: output=d438776c04d59804 input=c1be8a6464b11ee5]*/
{ {
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
InterpreterFrame *frame = tstate->cframe->current_frame; _PyInterpreterFrame *frame = tstate->cframe->current_frame;
if (_PySys_Audit(tstate, "sys._getframe", NULL) < 0) { if (_PySys_Audit(tstate, "sys._getframe", NULL) < 0) {
return NULL; return NULL;

View File

@ -1167,7 +1167,7 @@ done:
This function is signal safe. */ This function is signal safe. */
static void static void
dump_frame(int fd, InterpreterFrame *frame) dump_frame(int fd, _PyInterpreterFrame *frame)
{ {
PyCodeObject *code = frame->f_code; PyCodeObject *code = frame->f_code;
PUTS(fd, " File "); PUTS(fd, " File ");
@ -1205,7 +1205,7 @@ dump_frame(int fd, InterpreterFrame *frame)
static void static void
dump_traceback(int fd, PyThreadState *tstate, int write_header) dump_traceback(int fd, PyThreadState *tstate, int write_header)
{ {
InterpreterFrame *frame; _PyInterpreterFrame *frame;
unsigned int depth; unsigned int depth;
if (write_header) { if (write_header) {