@@ -562,12 +562,13 @@ dynamic_exit_uop[MAX_UOP_ID + 1] = {
562562
563563static inline void
564564add_to_trace (
565- _PyJitUopBuffer * trace ,
565+ _PyJitTracerState * tracer ,
566566 uint16_t opcode ,
567567 uint16_t oparg ,
568568 uint64_t operand ,
569569 uint32_t target )
570570{
571+ _PyJitUopBuffer * trace = & tracer -> code_buffer ;
571572 _PyUOpInstruction * inst = trace -> next ;
572573 inst -> opcode = opcode ;
573574 inst -> format = UOP_FORMAT_TARGET ;
@@ -576,22 +577,23 @@ add_to_trace(
576577 inst -> operand0 = operand ;
577578#ifdef Py_STATS
578579 inst -> execution_count = 0 ;
580+ inst -> fitness = tracer -> translator_state .fitness ;
579581#endif
580582 trace -> next ++ ;
581583}
582584
583585
584586#ifdef Py_DEBUG
585587#define ADD_TO_TRACE (OPCODE , OPARG , OPERAND , TARGET ) \
586- add_to_trace(trace , (OPCODE), (OPARG), (OPERAND), (TARGET)); \
588+ add_to_trace(tracer , (OPCODE), (OPARG), (OPERAND), (TARGET)); \
587589 if (lltrace >= 2) { \
588590 printf("%4d ADD_TO_TRACE: ", uop_buffer_length(trace)); \
589591 _PyUOpPrint(uop_buffer_last(trace)); \
590592 printf("\n"); \
591593 }
592594#else
593595#define ADD_TO_TRACE (OPCODE , OPARG , OPERAND , TARGET ) \
594- add_to_trace(trace , (OPCODE), (OPARG), (OPERAND), (TARGET))
596+ add_to_trace(tracer , (OPCODE), (OPARG), (OPERAND), (TARGET))
595597#endif
596598
597599#define INSTR_IP (INSTR , CODE ) \
@@ -1133,6 +1135,9 @@ _PyJit_TryInitializeTracing(
11331135 /* Set up tracing buffer*/
11341136 _PyJitUopBuffer * trace = & tracer -> code_buffer ;
11351137 uop_buffer_init (trace , & tracer -> uop_array [0 ], UOP_MAX_TRACE_LENGTH );
1138+ _PyJitTracerTranslatorState * ts = & tracer -> translator_state ;
1139+ ts -> fitness = tstate -> interp -> opt_config .fitness_initial ;
1140+ ts -> frame_depth = 0 ;
11361141 ADD_TO_TRACE (_START_EXECUTOR , 0 , (uintptr_t )start_instr , INSTR_IP (start_instr , code ));
11371142 ADD_TO_TRACE (_MAKE_WARM , 0 , 0 , 0 );
11381143
@@ -1162,10 +1167,6 @@ _PyJit_TryInitializeTracing(
11621167 assert (curr_instr -> op .code == JUMP_BACKWARD_JIT || curr_instr -> op .code == RESUME_CHECK_JIT || (exit != NULL ));
11631168 tracer -> initial_state .jump_backward_instr = curr_instr ;
11641169
1165- const _PyOptimizationConfig * cfg = & tstate -> interp -> opt_config ;
1166- _PyJitTracerTranslatorState * ts = & tracer -> translator_state ;
1167- ts -> fitness = cfg -> fitness_initial ;
1168- ts -> frame_depth = 0 ;
11691170 DPRINTF (3 , "Fitness init: chain_depth=%d, fitness=%d\n" ,
11701171 chain_depth , ts -> fitness );
11711172
@@ -2100,8 +2101,8 @@ write_row_for_uop(_PyExecutorObject *executor, uint32_t i, FILE *out)
21002101#ifdef Py_STATS
21012102 const char * bg_color = get_background_color (inst , executor -> trace [0 ].execution_count );
21022103 const char * color = get_foreground_color (inst , executor -> trace [0 ].execution_count );
2103- fprintf (out , " <tr><td port=\"i%d\" border=\"1\" color=\"%s\" bgcolor=\"%s\" ><font color=\"%s\"> %s -- %" PRIu64 "</font></td></tr>\n" ,
2104- i , color , bg_color , color , opname , inst -> execution_count );
2104+ fprintf (out , " <tr><td port=\"i%d\" border=\"1\" color=\"%s\" bgcolor=\"%s\" ><font color=\"%s\"> %s [%d] -- %" PRIu64 "</font></td></tr>\n" ,
2105+ i , color , bg_color , color , opname , inst -> fitness , inst -> execution_count );
21052106#else
21062107 const char * color = (_PyUop_Uncached [inst -> opcode ] == _DEOPT ) ? RED : BLACK ;
21072108 fprintf (out , " <tr><td port=\"i%d\" border=\"1\" color=\"%s\" >%s op0=%" PRIu64 "</td></tr>\n" , i , color , opname , inst -> operand0 );
0 commit comments