5252 #define DPRINTF (level , ...) \
5353 if (get_lltrace() >= (level)) { printf(__VA_ARGS__); }
5454
55-
56-
5755static void
5856dump_abstract_stack (_Py_UOpsAbstractFrame * frame , JitOptRef * stack_pointer )
5957{
@@ -83,8 +81,25 @@ dump_abstract_stack(_Py_UOpsAbstractFrame *frame, JitOptRef *stack_pointer)
8381 fflush (stdout );
8482}
8583
84+ static void
85+ dump_uop (JitOptContext * ctx , const char * label , int index ,
86+ const _PyUOpInstruction * instr , JitOptRef * stack_pointer )
87+ {
88+ if (get_lltrace () >= 3 ) {
89+ printf ("%4d %s: " , index , label );
90+ _PyUOpPrint (instr );
91+ printf ("\n" );
92+ if (get_lltrace () >= 5 && ctx -> frame -> code != ((PyCodeObject * )& _Py_InitCleanup )) {
93+ dump_abstract_stack (ctx -> frame , stack_pointer );
94+ }
95+ }
96+ }
97+
98+ #define DUMP_UOP dump_uop
99+
86100#else
87101 #define DPRINTF (level , ...)
102+ #define DUMP_UOP (ctx , label , index , instr , stack_pointer )
88103#endif
89104
90105static int
@@ -347,19 +362,19 @@ get_code_with_logging(_PyUOpInstruction *op)
347362 uint64_t push_operand = op -> operand0 ;
348363 if (push_operand & 1 ) {
349364 co = (PyCodeObject * )(push_operand & ~1 );
350- DPRINTF (3 , "code=%p " , co );
365+ DPRINTF (3 , " code=%p\n " , co );
351366 assert (PyCode_Check (co ));
352367 }
353368 else {
354369 PyFunctionObject * func = (PyFunctionObject * )push_operand ;
355- DPRINTF (3 , "func=%p " , func );
370+ DPRINTF (3 , " func=%p " , func );
356371 if (func == NULL ) {
357372 DPRINTF (3 , "\n" );
358373 DPRINTF (1 , "Missing function\n" );
359374 return NULL ;
360375 }
361376 co = (PyCodeObject * )func -> func_code ;
362- DPRINTF (3 , "code=%p " , co );
377+ DPRINTF (3 , "code=%p\n " , co );
363378 }
364379 return co ;
365380}
@@ -493,16 +508,7 @@ optimize_uops(
493508 stack_pointer = ctx -> frame -> stack_pointer ;
494509 }
495510
496- #ifdef Py_DEBUG
497- if (get_lltrace () >= 3 ) {
498- printf ("%4d abs: " , (int )(this_instr - trace ));
499- _PyUOpPrint (this_instr );
500- printf (" \n" );
501- if (get_lltrace () >= 5 && !CURRENT_FRAME_IS_INIT_SHIM ()) {
502- dump_abstract_stack (ctx -> frame , stack_pointer );
503- }
504- }
505- #endif
511+ DUMP_UOP (ctx , "abs" , this_instr - trace , this_instr , stack_pointer );
506512
507513 _PyUOpInstruction * out_ptr = ctx -> out_buffer .next ;
508514
@@ -519,6 +525,7 @@ optimize_uops(
519525 * (ctx -> out_buffer .next ++ ) = * this_instr ;
520526 }
521527 assert (ctx -> frame != NULL );
528+ DUMP_UOP (ctx , "out" , uop_buffer_length (& ctx -> out_buffer ) - 1 , out_ptr , stack_pointer );
522529 if (!CURRENT_FRAME_IS_INIT_SHIM () && !ctx -> done ) {
523530 DPRINTF (3 , " stack_level %d\n" , STACK_LEVEL ());
524531 ctx -> frame -> stack_pointer = stack_pointer ;
0 commit comments