Skip to content

Commit f965c81

Browse files
committed
Add back printing optimized uops
1 parent 8d2c3b5 commit f965c81

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

0 commit comments

Comments
 (0)