Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner committed Jan 21, 2025
1 parent 134d2a0 commit 732c6b4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
6 changes: 4 additions & 2 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ typedef struct _PyInterpreterFrame {
_PyStackRef *stackpointer;
uint16_t return_offset; /* Only relevant during a function call */
char owner;
char visited;
#ifdef Py_DEBUG
unsigned char lltrace;
char visited:4;
char lltrace:4;
#else
char visited;
#endif
/* Locals and stack */
_PyStackRef localsplus[1];
Expand Down
5 changes: 2 additions & 3 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,11 +1620,10 @@ class C(object): pass
def func():
return sys._getframe()
x = func()
LLTRACE = 'B' if support.Py_DEBUG else ''
if support.Py_GIL_DISABLED:
INTERPRETER_FRAME = f'10Phcc{LLTRACE}P'
INTERPRETER_FRAME = f'10PhcP'
else:
INTERPRETER_FRAME = f'9Phcc{LLTRACE}P'
INTERPRETER_FRAME = f'9PhcP'
check(x, size('3PiccPP' + INTERPRETER_FRAME + 'P'))
# function
def func(): pass
Expand Down
4 changes: 2 additions & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4993,7 +4993,7 @@ dummy_func(
_Py_CODEUNIT *target = _PyFrame_GetBytecode(frame) + exit->target;
#if defined(Py_DEBUG) && !defined(_Py_JIT)
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
if (FT_ATOMIC_LOAD_UINT8_RELAXED(frame->lltrace) >= 2) {
if (frame->lltrace >= 2) {
printf("SIDE EXIT: [UOp ");
_PyUOpPrint(&next_uop[-1]);
printf(", exit %u, temp %d, target %d -> %s]\n",
Expand Down Expand Up @@ -5111,7 +5111,7 @@ dummy_func(
_Py_CODEUNIT *target = frame->instr_ptr;
#if defined(Py_DEBUG) && !defined(_Py_JIT)
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
if (FT_ATOMIC_LOAD_UINT8_RELAXED(frame->lltrace) >= 2) {
if (frame->lltrace >= 2) {
printf("DYNAMIC EXIT: [UOp ");
_PyUOpPrint(&next_uop[-1]);
printf(", exit %u, temp %d, target %d -> %s]\n",
Expand Down
8 changes: 4 additions & 4 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
}
/* Resume normal execution */
#ifdef LLTRACE
if (FT_ATOMIC_LOAD_UINT8_RELAXED(frame->lltrace) >= 5) {
if (frame->lltrace >= 5) {
lltrace_resume_frame(frame);
}
#endif
Expand Down Expand Up @@ -1083,7 +1083,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
for (;;) {
uopcode = next_uop->opcode;
#ifdef Py_DEBUG
if (FT_ATOMIC_LOAD_UINT8_RELAXED(frame->lltrace) >= 3) {
if (frame->lltrace >= 3) {
dump_stack(frame, stack_pointer);
if (next_uop->opcode == _START_EXECUTOR) {
printf("%4d uop: ", 0);
Expand Down Expand Up @@ -1125,7 +1125,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int

jump_to_error_target:
#ifdef Py_DEBUG
if (FT_ATOMIC_LOAD_UINT8_RELAXED(frame->lltrace) >= 2) {
if (frame->lltrace >= 2) {
printf("Error: [UOp ");
_PyUOpPrint(&next_uop[-1]);
printf(" @ %d -> %s]\n",
Expand Down Expand Up @@ -1161,7 +1161,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
next_instr = next_uop[-1].target + _PyFrame_GetBytecode(frame);
goto_to_tier1:
#ifdef Py_DEBUG
if (FT_ATOMIC_LOAD_UINT8_RELAXED(frame->lltrace) >= 2) {
if (frame->lltrace >= 2) {
printf("DEOPT: [UOp ");
_PyUOpPrint(&next_uop[-1]);
printf(" -> %s]\n",
Expand Down
2 changes: 1 addition & 1 deletion Python/ceval_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

/* PRE_DISPATCH_GOTO() does lltrace if enabled. Normally a no-op */
#ifdef LLTRACE
#define PRE_DISPATCH_GOTO() if (FT_ATOMIC_LOAD_UINT8_RELAXED(frame->lltrace) >= 5) { \
#define PRE_DISPATCH_GOTO() if (frame->lltrace >= 5) { \
lltrace_instruction(frame, stack_pointer, next_instr, opcode, oparg); }
#else
#define PRE_DISPATCH_GOTO() ((void)0)
Expand Down
4 changes: 2 additions & 2 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 732c6b4

Please sign in to comment.