Skip to content

Commit

Permalink
remove debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel committed Oct 11, 2023
1 parent 41bba62 commit d363fc3
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 35 deletions.
1 change: 0 additions & 1 deletion Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef Py_PYTHON_H
#define Py_PYTHON_H

#define VERBOSE 0
// Since this is a "meta-include" file, "#ifdef __cplusplus / extern "C" {"
// is not needed.

Expand Down
10 changes: 0 additions & 10 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ static inline PyCodeObject *_PyFrame_GetCode(_PyInterpreterFrame *f) {
return (PyCodeObject *)f->f_executable;
}

static void
dump_frame_ip(const char* title, _PyInterpreterFrame *frame) {
if (frame) {
fprintf(stderr, "%s: frame=%p frame->instr_ptr=%p ",
title, frame, frame->instr_ptr);
fprintf(stderr, "next_instr_offset=%d yield_offset=%d \n",
frame->next_instr_offset, frame->yield_offset);
}
}

static inline PyObject **_PyFrame_Stackbase(_PyInterpreterFrame *f) {
return f->localsplus + _PyFrame_GetCode(f)->co_nlocalsplus;
}
Expand Down
17 changes: 0 additions & 17 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,22 +734,12 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
_Py_CODEUNIT *next_instr = NULL;
PyObject **stack_pointer;

#undef DUMP_FRAME
#define DUMP_FRAME(TITLE) do { \
if (VERBOSE) { \
dump_frame_ip(TITLE, frame); \
fprintf(stderr, "next_instr = %p \n", next_instr); \
} \
} while(0);


/* Sets the above local variables from the frame */
#define SET_LOCALS_FROM_FRAME() \
/* Jump back to the last instruction executed... */ \
DUMP_FRAME("SET_LOCALS_FROM_FRAME1"); \
next_instr = frame->instr_ptr + frame->next_instr_offset; \
frame->next_instr_offset = frame->yield_offset = 0; \
DUMP_FRAME("SET_LOCALS_FROM_FRAME2"); \
stack_pointer = _PyFrame_GetStackPointer(frame);

start_frame:
Expand Down Expand Up @@ -792,7 +782,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
case INSTRUMENTED_LINE:
#endif
{
DUMP_FRAME("INSTRUMENTED_LINE");
_Py_CODEUNIT *prev = frame->instr_ptr;
_Py_CODEUNIT *here = frame->instr_ptr = next_instr;
_PyFrame_SetStackPointer(frame, stack_pointer);
Expand Down Expand Up @@ -880,10 +869,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
{
/* We can't use frame->f_lasti here, as RERAISE may have set it */
int offset = INSTR_OFFSET()-1;
DUMP_FRAME("exception_unwind:");
int level, handler, lasti;
if (get_exception_handler(_PyFrame_GetCode(frame), offset, &level, &handler, &lasti) == 0) {
if (VERBOSE) fprintf(stderr, "No Exception Handler: offset=%d lasti=%d handler=%d\n", offset, lasti, handler);
// No handlers, so exit.
assert(_PyErr_Occurred(tstate));

Expand All @@ -896,12 +883,9 @@ if (VERBOSE) fprintf(stderr, "No Exception Handler: offset=%d lasti=%d handler=
assert(STACK_LEVEL() == 0);
_PyFrame_SetStackPointer(frame, stack_pointer);
monitor_unwind(tstate, frame, next_instr-1);
DUMP_FRAME("goto exit_unwind");
goto exit_unwind;
}

if (VERBOSE) fprintf(stderr, "Exception Handler: %d\n", handler);

assert(STACK_LEVEL() >= level);
PyObject **new_top = _PyFrame_Stackbase(frame) + level;
while (stack_pointer > new_top) {
Expand Down Expand Up @@ -946,7 +930,6 @@ if (VERBOSE) fprintf(stderr, "Exception Handler: %d\n", handler);
frame = tstate->current_frame = dying->previous;
_PyEval_FrameClearAndPop(tstate, dying);
frame->yield_offset = frame->next_instr_offset = 0;
DUMP_FRAME("exit_unwind");
if (frame == &entry_frame) {
/* Restore previous frame and exit */
tstate->current_frame = frame->previous;
Expand Down
7 changes: 0 additions & 7 deletions Python/ceval_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@
#else
#define INSTRUCTION_START(op) \
do { \
if (VERBOSE) fprintf(stderr, "--- %s: frame=%p frame->instr_ptr=%p next_instr=%p next_instr_offset=%d yield_offset=%d\n", _PyOpcode_OpName[op], frame, frame->instr_ptr, next_instr, frame->next_instr_offset, frame->yield_offset); \
frame->instr_ptr = next_instr++; \
frame->next_instr_offset = 0; \
assert(frame->yield_offset == 0); \
if (VERBOSE) fprintf(stderr, "=== %s: frame=%p frame->instr_ptr=%p next_instr=%p next_instr_offset=%d yield_offset=%d\n", _PyOpcode_OpName[op], frame, frame->instr_ptr, next_instr, frame->next_instr_offset, frame->yield_offset); \
} while(0)
#endif

Expand Down Expand Up @@ -165,11 +163,6 @@ GETITEM(PyObject *v, Py_ssize_t i) {
#define SKIP_OVER(x) JUMPBY(x)


#define DUMP_FRAME(TITLE) do { \
if (VERBOSE) { \
dump_frame_ip(TITLE, frame); \
} \
} while(0);

/* OpCode prediction macros
Some opcodes tend to come in pairs thus making it possible to
Expand Down

0 comments on commit d363fc3

Please sign in to comment.