Skip to content

Commit b838435

Browse files
committed
Add back printing optimized uops
1 parent 053a0a2 commit b838435

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Python/optimizer.c

+20-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ uop_dealloc(_PyUOpExecutorObject *self) {
325325
}
326326

327327
static const char *
328-
uop_name(int index) {
328+
uop_name(int index)
329+
{
329330
if (index <= MAX_REAL_OPCODE) {
330331
return _PyOpcode_OpName[index];
331332
}
@@ -832,6 +833,24 @@ make_executor_from_uops(_PyUOpInstruction *buffer, _PyBloomFilter *dependencies)
832833
assert(dest == -1);
833834
executor->base.execute = _PyUopExecute;
834835
_Py_ExecutorInit((_PyExecutorObject *)executor, dependencies);
836+
#ifdef Py_DEBUG
837+
char *python_lltrace = Py_GETENV("PYTHON_LLTRACE");
838+
int lltrace = 0;
839+
if (python_lltrace != NULL && *python_lltrace >= '0') {
840+
lltrace = *python_lltrace - '0'; // TODO: Parse an int and all that
841+
}
842+
if (lltrace >= 2) {
843+
printf("Optimized executor (length %d):\n", length);
844+
for (int i = 0; i < length; i++) {
845+
printf("%4d %s(%d, %d, %" PRIu64 ")\n",
846+
i,
847+
uop_name(executor->trace[i].opcode),
848+
executor->trace[i].oparg,
849+
executor->trace[i].target,
850+
executor->trace[i].operand);
851+
}
852+
}
853+
#endif
835854
return (_PyExecutorObject *)executor;
836855
}
837856

0 commit comments

Comments
 (0)