summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c61
1 files changed, 40 insertions, 21 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index b7a5d62..06c136a 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -649,7 +649,10 @@ static const _Py_CODEUNIT _Py_INTERPRETER_TRAMPOLINE_INSTRUCTIONS[] = {
extern const struct _PyCode_DEF(8) _Py_InitCleanup;
-extern const char *_PyUOpName(int index);
+#ifdef Py_DEBUG
+extern void _PyUOpPrint(const _PyUOpInstruction *uop);
+#endif
+
/* Disable unused label warnings. They are handy for debugging, even
if computed gotos aren't used. */
@@ -1006,14 +1009,14 @@ enter_tier_two:
assert(next_uop->opcode == _START_EXECUTOR || next_uop->opcode == _COLD_EXIT);
for (;;) {
uopcode = next_uop->opcode;
- DPRINTF(3,
- "%4d: uop %s, oparg %d, operand %" PRIu64 ", target %d, stack_level %d\n",
- (int)(next_uop - (current_executor == NULL ? next_uop : current_executor->trace)),
- _PyUOpName(uopcode),
- next_uop->oparg,
- next_uop->operand,
- next_uop->target,
+#ifdef Py_DEBUG
+ if (lltrace >= 3) {
+ printf("%4d uop: ", (int)(next_uop - (current_executor == NULL ? next_uop : current_executor->trace)));
+ _PyUOpPrint(next_uop);
+ printf(" stack_level=%d\n",
(int)(stack_pointer - _PyFrame_Stackbase(frame)));
+ }
+#endif
next_uop++;
OPT_STAT_INC(uops_executed);
UOP_STAT_INC(uopcode, execution_count);
@@ -1028,9 +1031,9 @@ enter_tier_two:
default:
#ifdef Py_DEBUG
{
- fprintf(stderr, "Unknown uop %d, oparg %d, operand %" PRIu64 " @ %d\n",
- next_uop[-1].opcode, next_uop[-1].oparg, next_uop[-1].operand,
- (int)(next_uop - (current_executor == NULL ? next_uop : current_executor->trace) - 1));
+ printf("Unknown uop: ");
+ _PyUOpPrint(&next_uop[-1]);
+ printf(" @ %d\n", (int)(next_uop - current_executor->trace - 1));
Py_FatalError("Unknown uop");
}
#else
@@ -1058,10 +1061,15 @@ pop_2_error_tier_two:
pop_1_error_tier_two:
STACK_SHRINK(1);
error_tier_two:
- DPRINTF(2, "Error: [UOp %d (%s), oparg %d, operand %" PRIu64 ", target %d @ %d -> %s]\n",
- uopcode, _PyUOpName(uopcode), next_uop[-1].oparg, next_uop[-1].operand, next_uop[-1].target,
- (int)(next_uop - current_executor->trace - 1),
- _PyOpcode_OpName[frame->instr_ptr->op.code]);
+#ifdef Py_DEBUG
+ if (lltrace >= 2) {
+ printf("Error: [UOp ");
+ _PyUOpPrint(&next_uop[-1]);
+ printf(" @ %d -> %s]\n",
+ (int)(next_uop - current_executor->trace - 1),
+ _PyOpcode_OpName[frame->instr_ptr->op.code]);
+ }
+#endif
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
frame->return_offset = 0; // Don't leave this random
_PyFrame_SetStackPointer(frame, stack_pointer);
@@ -1072,9 +1080,14 @@ error_tier_two:
// Jump here from DEOPT_IF()
deoptimize:
next_instr = next_uop[-1].target + _PyCode_CODE(_PyFrame_GetCode(frame));
- DPRINTF(2, "DEOPT: [UOp %d (%s), oparg %d, operand %" PRIu64 ", target %d -> %s]\n",
- uopcode, _PyUOpName(uopcode), next_uop[-1].oparg, next_uop[-1].operand, next_uop[-1].target,
- _PyOpcode_OpName[next_instr->op.code]);
+#ifdef Py_DEBUG
+ if (lltrace >= 2) {
+ printf("DEOPT: [UOp ");
+ _PyUOpPrint(&next_uop[-1]);
+ printf(" -> %s]\n",
+ _PyOpcode_OpName[frame->instr_ptr->op.code]);
+ }
+#endif
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
UOP_STAT_INC(uopcode, miss);
Py_DECREF(current_executor);
@@ -1088,9 +1101,15 @@ side_exit:
uint32_t exit_index = next_uop[-1].exit_index;
assert(exit_index < current_executor->exit_count);
_PyExitData *exit = &current_executor->exits[exit_index];
- DPRINTF(2, "SIDE EXIT: [UOp %d (%s), oparg %d, operand %" PRIu64 ", exit %u, temp %d, target %d -> %s]\n",
- uopcode, _PyUOpName(uopcode), next_uop[-1].oparg, next_uop[-1].operand, exit_index, exit->temperature,
- exit->target, _PyOpcode_OpName[_PyCode_CODE(_PyFrame_GetCode(frame))[exit->target].op.code]);
+#ifdef Py_DEBUG
+ if (lltrace >= 2) {
+ printf("SIDE EXIT: [UOp ");
+ _PyUOpPrint(&next_uop[-1]);
+ printf(", exit %u, temp %d, target %d -> %s]\n",
+ exit_index, exit->temperature, exit->target,
+ _PyOpcode_OpName[frame->instr_ptr->op.code]);
+ }
+#endif
Py_INCREF(exit->executor);
tstate->previous_executor = (PyObject *)current_executor;
GOTO_TIER_TWO(exit->executor);