8000 WIP bpo-44800: Rename `_PyInterpreterFrame` to `_Py_framedata` by ncoghlan · Pull Request #27525 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a133e0d
bpo-44800: Clearly distinguish execution & introspection frames
ncoghlan Aug 1, 2021
d8858aa
'frame' and 'frame data' replaces introspection and execution frames
ncoghlan Aug 14, 2021
cd340b0
Merge remote-tracking branch 'origin/main' into bpo-44800-rename-inte…
ncoghlan Aug 14, 2021
ccf953b
Tweak some comments
ncoghlan Aug 14, 2021
4a097bd
Another comment fix
ncoghlan Aug 14, 2021
bd00490
Fix LLTRACE macro compile error
ncoghlan Aug 14, 2021
04aa7e8
Revert unintended function name changes
ncoghlan Aug 14, 2021
8000 e9018e7
Fix comment alignment
ncoghlan Aug 14, 2021
0ce41c8
Follow proposed new naming conventions in gdb hooks
ncoghlan Aug 14, 2021
c269e1f
Merge remote-tracking branch 'origin/main' into bpo-44800-rename-inte…
ncoghlan Aug 21, 2021
4eeff9a
Reduce conflicts for main branch merge
ncoghlan Mar 6, 2022
6fa0f53
Fix bad search & replace
ncoghlan Mar 6, 2022
776ca80
main branch has no underscore
ncoghlan Mar 6, 2022
682af23
Reduce function header conflicts
ncoghlan Mar 6, 2022
c76e63b
Yet more merge conflict reduction
ncoghlan Mar 6, 2022
b1d1438
Merged and compiles, naming is inconsistent
ncoghlan Mar 6, 2022
cae935d
Reinstate _Py_framedata struct rename
ncoghlan Mar 6, 2022
2866bfa
Fix type declaration for gen/coro frame data
ncoghlan Mar 6, 2022
239a62f
Document frame related naming conventions
ncoghlan Mar 6, 2022
2680f35
Migrate gen/coro iframe field to fdata naming convention
ncoghlan Mar 6, 2022
ebda1d3
Use fdata for frame data locals and parameters
ncoghlan Mar 12, 2022
269a4a0
frame -> fdata in ceval.c & allow compilation
ncoghlan Mar 12, 2022
34cf023
Disambiguate f_fdata and f_frame_data
ncoghlan Mar 12, 2022
55d9276
Merge remote-tracking branch 'origin/main' into bpo-44800-rename-inte…
ncoghlan Mar 12, 2022
3eba918
Document the currently implemented conventions
ncoghlan Mar 12, 2022
e8a4adf
Note the 'current_frame' exception
ncoghlan Mar 12, 2022
3d654a0
Fix test_gdb
ncoghlan Mar 12, 2022
b09b114
Fix header file include guard var
ncoghlan Mar 12, 2022
9b51976
Distinguish frame state error messages
ncoghlan Mar 12, 2022
0a3611c
super() does not access C frame structs
ncoghlan Mar 12, 2022
08410cc
new_frame -> new_fdata in frame push
ncoghlan Mar 12, 2022
c694768
Add missing error check in PyImport_Import
ncoghlan Mar 12, 2022
ba87ef3
No Python frame seems legit for PyImport_Import()
ncoghlan Mar 12, 2022
7168f7d
Get test_gdb passing locally
ncoghlan Mar 12, 2022
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/main' into bpo-44800-rename-inte…
…rpreter-frames
  • Loading branch information
ncoghlan committed Aug 14, 2021
commit cd340b07f09258b457be89a575fc0d881826e2e8
88 changes: 22 additions & 66 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ static PyObject * do_call_core(
#ifdef LLTRACE
static int lltrace;
static int prtrace(PyThreadState *, PyObject *, const char *);
static void lltrace_instruction(InterpreterFrame *frame, int opcode, int oparg)
static void lltrace_instruction(_Py_framedata *fdata, int opcode, int oparg)
{
if (HAS_ARG(opcode)) {
printf("%d: %d, %d\n",
frame->f_lasti, opcode, oparg);
fdata->lasti, opcode, oparg);
}
else {
printf("%d: %d\n",
frame->f_lasti, opcode);
fdata->lasti, opcode);
}
}
#endif
Expand Down Expand Up @@ -1435,7 +1435,7 @@ eval_frame_handle_pending(PyThreadState *tstate)
#define LOCALS() fdata->locals

static int
trace_function_entry(PyThreadState *tstate, InterpreterFrame *frame)
trace_function_entry(PyThreadState *tstate, _Py_framedata *fdata)
{
if (tstate->c_tracefunc != NULL) {
/* tstate->c_tracefunc, if defined, is a
Expand All @@ -1453,7 +1453,7 @@ trace_function_entry(PyThreadState *tstate, InterpreterFrame *frame)
whenever an exception is detected. */
if (call_trace_protected(tstate->c_tracefunc,
tstate->c_traceobj,
tstate, frame,
tstate, fdata,
PyTrace_CALL, Py_None)) {
/* Trace function raised an error */
return -1;
Expand All @@ -1464,7 +1464,7 @@ trace_function_entry(PyThreadState *tstate, InterpreterFrame *frame)
return itself and isn't called for "line" events */
if (call_trace_protected(tstate->c_profilefunc,
tstate->c_profileobj,
tstate, frame,
tstate, fdata,
PyTrace_CALL, Py_None)) {
/* Profile function raised an error */
return -1;
Expand Down Expand Up @@ -1506,50 +1506,19 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _Py_framedata *fdata, int throwf
cframe.previous = prev_cframe;
tstate->cframe = &cframe;

/* push execution frame */
/* push frame */
tstate->fdata = fdata;
co = fdata->code;

if (cframe.use_tracing) {
if (tstate->c_tracefunc != NULL) {
/* tstate->c_tracefunc, if defined, is a
function that will be called on *every* entry
to a code block. Its return value, if not
None, is a function that will be called at
the start of each executed line of code.
(Actually, the function must return itself
in order to continue tracing.) The trace
functions are called with three arguments:
a pointer to the current frame, a string
indicating why the function is called, and
an argument which depends on the situation.
The global trace function is also called
whenever an exception is detected. */
if (call_trace_protected(tstate->c_tracefunc,
tstate->c_traceobj,
tstate, fdata,
PyTrace_CALL, Py_None)) {
/* Trace function raised an error */
goto exit_eval_frame;
}
}
if (tstate->c_profilefunc != NULL) {
/* Similar for c_profilefunc, except it needn't
return itself and isn't called for "line" events */
if (call_trace_protected(tstate->c_profilefunc,
tstate->c_profileobj,
tstate, fdata,
PyTrace_CALL, Py_None)) {
/* Profile function raised an error */
goto exit_eval_frame;
}
if (trace_function_entry(tstate, fdata)) {
goto exit_eval_frame;
}
}

if (PyDTrace_FUNCTION_ENTRY_ENABLED())
dtrace_function_entry(fdata);

PyCodeObject *co = frame->f_code;
PyCodeObject *co = fdata->code;
/* Increment the warmup counter and quicken if warm enough
* _Py_Quicken is idempotent so we don't worry about overflow */
if (!PyCodeObject_IsWarmedUp(co)) {
Expand All @@ -1562,10 +1531,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _Py_framedata *fdata, int throwf
}


names = co->co_names;
consts = co->co_consts;
localsplus = _Py_framedata_GetLocalsArray(fdata);
first_instr = co->co_firstinstr;
PyObject *names = co->co_names;
PyObject *consts = co->co_consts;
PyObject **localsplus = _Py_framedata_GetLocalsArray(fdata);
_Py_CODEUNIT *first_instr = co->co_firstinstr;
/*
fdata->lasti refers to the index of the last instruction,
unless it's -1 in which case next_instr should be first_instr.
Expand All @@ -1582,8 +1551,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _Py_framedata *fdata, int throwf
to the beginning of the combined pair.)
*/
assert(fdata->lasti >= -1);
next_instr = first_instr + fdata->lasti + 1;
stack_pointer = fdata->stack + fdata->stackdepth;
_Py_CODEUNIT *next_instr = first_instr + fdata->lasti + 1;
PyObject **stack_pointer = fdata->stack + fdata->stackdepth;
/* Set stackdepth to -1.
* Update when returning or calling trace function.
Having f_stackdepth <= 0 ensures that invalid
Expand Down Expand Up @@ -1692,21 +1661,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _Py_framedata *fdata, int throwf
DISPATCH_GOTO();
}

#ifdef LLTRACE
/* Instruction tracing */

if (lltrace) {
if (HAS_ARG(opcode)) {
printf("%d: %d, %d\n",
fdata->lasti, opcode, oparg);
}
else {
printf("%d: %d\n",
fdata->lasti, opcode);
}
}
#endif

/* Start instructions */
#if USE_COMPUTED_GOTOS
{
#else
dispatch_opcode:
switch (opcode) {
#endif
Expand Down Expand Up @@ -4674,8 +4632,8 @@ MISS_WITH_OPARG_COUNTER(BINARY_SUBSCR)
PyObject *o = POP();
Py_XDECREF(o);
}
frame->stackdepth = 0;
frame->f_state = FRAME_RAISED;
fdata->stackdepth = 0;
fdata->state = FRAME_RAISED;
goto exiting;
}

Expand Down Expand Up @@ -4717,8 +4675,6 @@ MISS_WITH_OPARG_COUNTER(BINARY_SUBSCR)
PRE_DISPATCH_GOTO();
DISPATCH_GOTO();
}
fdata->stackdepth = 0;
fdata->state = FRAME_RAISED;
exiting:
if (cframe.use_tracing) {
if (tstate->c_tracefunc) {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0