Skip to content

bpo-46836: Rename InterpreterFrame to _PyInterpreterFrame #31583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/cpython/ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ PyAPI_FUNC(PyObject *) _PyEval_GetBuiltinId(_Py_Identifier *);
flag was set, else return 0. */
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(unsigned long) _PyEval_GetSwitchInterval(void);
Expand Down
4 changes: 2 additions & 2 deletions Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ typedef struct _cframe {
*/
int use_tracing;
/* Pointer to the currently executing frame (it can be NULL) */
struct _interpreter_frame *current_frame;
struct _PyInterpreterFrame *current_frame;
struct _cframe *previous;
} CFrame;

Expand Down Expand Up @@ -258,7 +258,7 @@ PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);

/* 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(
PyInterpreterState *interp);
Expand Down
4 changes: 2 additions & 2 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern PyObject *_PyEval_BuiltinsFromGlobals(


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) {
return _PyEval_EvalFrameDefault(tstate, frame, throwflag);
Expand Down Expand Up @@ -116,7 +116,7 @@ static inline void _Py_LeaveRecursiveCall_inline(void) {

#define Py_LeaveRecursiveCall() _Py_LeaveRecursiveCall_inline()

struct _interpreter_frame *_PyEval_GetFrame(void);
struct _PyInterpreterFrame *_PyEval_GetFrame(void);

PyObject *_Py_MakeCoro(PyFunctionObject *func);

Expand Down
58 changes: 29 additions & 29 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern "C" {
struct _frame {
PyObject_HEAD
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 */
int f_lineno; /* Current line number. Only valid if non-zero */
char f_trace_lines; /* Emit per-line trace events? */
Expand Down Expand Up @@ -46,63 +46,63 @@ typedef signed char PyFrameState;
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 */
PyObject *f_globals; /* Borrowed reference */
PyObject *f_builtins; /* Borrowed reference */
PyObject *f_locals; /* Strong reference, may be NULL */
PyCodeObject *f_code; /* Strong reference */
PyFrameObject *frame_obj; /* Strong reference, may be NULL */
struct _interpreter_frame *previous;
struct _PyInterpreterFrame *previous;
int f_lasti; /* Last instruction if called */
int stacktop; /* Offset of TOS from localsplus */
PyFrameState f_state; /* What state the frame is in */
bool is_entry; // Whether this is the "root" frame for the current CFrame.
bool is_generator;
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;
}

static inline int _PyFrame_IsExecuting(InterpreterFrame *f) {
static inline int _PyFrame_IsExecuting(_PyInterpreterFrame *f) {
return f->f_state == FRAME_EXECUTING;
}

static inline int _PyFrameHasCompleted(InterpreterFrame *f) {
static inline int _PyFrameHasCompleted(_PyInterpreterFrame *f) {
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;
}

static inline PyObject *_PyFrame_StackPeek(InterpreterFrame *f) {
static inline PyObject *_PyFrame_StackPeek(_PyInterpreterFrame *f) {
assert(f->stacktop > f->f_code->co_nlocalsplus);
assert(f->localsplus[f->stacktop-1] != NULL);
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);
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->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 */
static inline void
_PyFrame_InitializeSpecials(
InterpreterFrame *frame, PyFunctionObject *func,
_PyInterpreterFrame *frame, PyFunctionObject *func,
PyObject *locals, int nlocalsplus)
{
frame->f_func = func;
Expand All @@ -122,33 +122,33 @@ _PyFrame_InitializeSpecials(
* that precedes this frame.
*/
static inline PyObject**
_PyFrame_GetLocalsArray(InterpreterFrame *frame)
_PyFrame_GetLocalsArray(_PyInterpreterFrame *frame)
{
return frame->localsplus;
}

static inline PyObject**
_PyFrame_GetStackPointer(InterpreterFrame *frame)
_PyFrame_GetStackPointer(_PyInterpreterFrame *frame)
{
return frame->localsplus+frame->stacktop;
}

static inline void
_PyFrame_SetStackPointer(InterpreterFrame *frame, PyObject **stack_pointer)
_PyFrame_SetStackPointer(_PyInterpreterFrame *frame, PyObject **stack_pointer)
{
frame->stacktop = (int)(stack_pointer - frame->localsplus);
}

/* For use by _PyFrame_GetFrameObject
Do not call directly. */
PyFrameObject *
_PyFrame_MakeAndSetFrameObject(InterpreterFrame *frame);
_PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame);

/* Gets the PyFrameObject for this frame, lazily
* creating it if necessary.
* Returns a borrowed referennce */
static inline PyFrameObject *
_PyFrame_GetFrameObject(InterpreterFrame *frame)
_PyFrame_GetFrameObject(_PyInterpreterFrame *frame)
{
PyFrameObject *res = frame->frame_obj;
if (res != NULL) {
Expand All @@ -158,7 +158,7 @@ _PyFrame_GetFrameObject(InterpreterFrame *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
* instead of being cleared. Either way
* the caller no longer owns the references
Expand All @@ -167,21 +167,21 @@ _PyFrame_GetFrameObject(InterpreterFrame *frame)
* frames like the ones in generators and coroutines.
*/
void
_PyFrame_Clear(InterpreterFrame * frame);
_PyFrame_Clear(_PyInterpreterFrame * frame);

int
_PyFrame_Traverse(InterpreterFrame *frame, visitproc visit, void *arg);
_PyFrame_Traverse(_PyInterpreterFrame *frame, visitproc visit, void *arg);

int
_PyFrame_FastToLocalsWithError(InterpreterFrame *frame);
_PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame);

void
_PyFrame_LocalsToFast(InterpreterFrame *frame, int clear);
_PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear);

extern InterpreterFrame *
extern _PyInterpreterFrame *
_PyThreadState_BumpFramePointerSlow(PyThreadState *tstate, size_t size);

static inline InterpreterFrame *
static inline _PyInterpreterFrame *
_PyThreadState_BumpFramePointer(PyThreadState *tstate, size_t size)
{
PyObject **base = tstate->datastack_top;
Expand All @@ -190,16 +190,16 @@ _PyThreadState_BumpFramePointer(PyThreadState *tstate, size_t size)
assert(tstate->datastack_limit);
if (top < tstate->datastack_limit) {
tstate->datastack_top = top;
return (InterpreterFrame *)base;
return (_PyInterpreterFrame *)base;
}
}
return _PyThreadState_BumpFramePointerSlow(tstate, size);
}

void _PyThreadState_PopFrame(PyThreadState *tstate, InterpreterFrame *frame);
void _PyThreadState_PopFrame(PyThreadState *tstate, _PyInterpreterFrame *frame);

/* Consume reference to func */
InterpreterFrame *
_PyInterpreterFrame *
_PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func);

#ifdef __cplusplus
Expand Down
6 changes: 3 additions & 3 deletions Modules/_tracemalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ hashtable_compare_traceback(const void *key1, const void *key2)


static void
tracemalloc_get_frame(InterpreterFrame *pyframe, frame_t *frame)
tracemalloc_get_frame(_PyInterpreterFrame *pyframe, frame_t *frame)
{
frame->filename = &_Py_STR(anon_unknown);
int lineno = PyCode_Addr2Line(pyframe->f_code, pyframe->f_lasti*sizeof(_Py_CODEUNIT));
Expand Down Expand Up @@ -399,7 +399,7 @@ traceback_get_frames(traceback_t *traceback)
return;
}

InterpreterFrame *pyframe = tstate->cframe->current_frame;
_PyInterpreterFrame *pyframe = tstate->cframe->current_frame;
for (; pyframe != NULL;) {
if (traceback->nframe < _Py_tracemalloc_config.max_nframe) {
tracemalloc_get_frame(pyframe, &traceback->frames[traceback->nframe]);
Expand All @@ -410,7 +410,7 @@ traceback_get_frames(traceback_t *traceback)
traceback->total_nframe++;
}

InterpreterFrame *back = pyframe->previous;
_PyInterpreterFrame *back = pyframe->previous;
pyframe = back;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/_xxsubinterpretersmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ _is_running(PyInterpreterState *interp)
}

assert(!PyErr_Occurred());
InterpreterFrame *frame = tstate->cframe->current_frame;
_PyInterpreterFrame *frame = tstate->cframe->current_frame;
if (frame == NULL) {
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/signalmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "pycore_call.h" // _PyObject_Call()
#include "pycore_ceval.h" // _PyEval_SignalReceived()
#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_pyerrors.h" // _PyErr_SetString()
#include "pycore_pylifecycle.h" // NSIG
Expand Down Expand Up @@ -1809,7 +1809,7 @@ _PyErr_CheckSignalsTstate(PyThreadState *tstate)
*/
_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;
for (int i = 1; i < NSIG; i++) {
if (!_Py_atomic_load_relaxed(&Handlers[i].tripped)) {
Expand Down
20 changes: 10 additions & 10 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,8 @@ frame_dealloc(PyFrameObject *f)
/* Kill all local variables including specials, if we own them */
if (f->f_owns_frame) {
f->f_owns_frame = 0;
assert(f->f_frame == (InterpreterFrame *)f->_f_frame_data);
InterpreterFrame *frame = (InterpreterFrame *)f->_f_frame_data;
assert(f->f_frame == (_PyInterpreterFrame *)f->_f_frame_data);
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)f->_f_frame_data;
/* Don't clear code object until the end */
co = frame->f_code;
frame->f_code = NULL;
Expand Down Expand Up @@ -707,7 +707,7 @@ static PyObject *
frame_sizeof(PyFrameObject *f, PyObject *Py_UNUSED(ignored))
{
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;
res += (code->co_nlocalsplus+code->co_stacksize) * sizeof(PyObject *);
return PyLong_FromSsize_t(res);
Expand Down Expand Up @@ -738,7 +738,7 @@ PyTypeObject PyFrame_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"frame",
offsetof(PyFrameObject, _f_frame_data) +
offsetof(InterpreterFrame, localsplus),
offsetof(_PyInterpreterFrame, localsplus),
sizeof(PyObject *),
(destructor)frame_dealloc, /* tp_dealloc */
0, /* tp_vectorcall_offset */
Expand Down Expand Up @@ -771,7 +771,7 @@ PyTypeObject PyFrame_Type = {
};

static void
init_frame(InterpreterFrame *frame, PyFunctionObject *func, PyObject *locals)
init_frame(_PyInterpreterFrame *frame, PyFunctionObject *func, PyObject *locals)
{
/* _PyFrame_InitializeSpecials consumes reference to func */
Py_INCREF(func);
Expand Down Expand Up @@ -827,16 +827,16 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code,
Py_DECREF(func);
return NULL;
}
init_frame((InterpreterFrame *)f->_f_frame_data, func, locals);
f->f_frame = (InterpreterFrame *)f->_f_frame_data;
init_frame((_PyInterpreterFrame *)f->_f_frame_data, func, locals);
f->f_frame = (_PyInterpreterFrame *)f->_f_frame_data;
f->f_owns_frame = 1;
Py_DECREF(func);
_PyObject_GC_TRACK(f);
return f;
}

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 *)PyBytes_AS_STRING(frame->f_code->co_code);
Expand All @@ -849,7 +849,7 @@ _PyFrame_OpAlreadyRan(InterpreterFrame *frame, int opcode, int oparg)
}

int
_PyFrame_FastToLocalsWithError(InterpreterFrame *frame) {
_PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame) {
/* Merge fast locals into f->f_locals */
PyObject *locals;
PyObject **fast;
Expand Down Expand Up @@ -960,7 +960,7 @@ PyFrame_FastToLocals(PyFrameObject *f)
}

void
_PyFrame_LocalsToFast(InterpreterFrame *frame, int clear)
_PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear)
{
/* Merge locals into fast locals */
PyObject *locals;
Expand Down
Loading