@@ -588,7 +588,10 @@ _PyJit_translate_single_bytecode_to_trace(
588588 PyCodeObject * old_code = _tstate -> jit_tracer_state .prev_state .instr_code ;
589589 bool progress_needed = (_tstate -> jit_tracer_state .initial_state .chain_depth % MAX_CHAIN_DEPTH ) == 0 ;
590590 _PyBloomFilter * dependencies = & _tstate -> jit_tracer_state .prev_state .dependencies ;
591- _Py_BloomFilter_Add (dependencies , old_code );
591+ // Can be NULL for the entry frame.
592+ if (old_code != NULL ) {
593+ _Py_BloomFilter_Add (dependencies , old_code );
594+ }
592595 int trace_length = _tstate -> jit_tracer_state .prev_state .code_curr_size ;
593596 _PyUOpInstruction * trace = _tstate -> jit_tracer_state .code_buffer ;
594597 int max_length = _tstate -> jit_tracer_state .prev_state .code_max_size ;
@@ -1348,17 +1351,7 @@ uop_optimize(
13481351 bool progress_needed )
13491352{
13501353 _PyThreadStateImpl * _tstate = (_PyThreadStateImpl * )tstate ;
1351- // Note: the executor has a slightly different set of dependencies than the tracer.
1352- // For example: the tracer depends on function and code objects.
1353- // The executor may only depend on the code object.
1354- // Furthermore, it may decide to cut the trace early, meaning it does not depend on the rest
1355- // of the code objects in the trace.
1356- // It is crucial we differentiate them for performance reasons.
1357- // This prevents endless re-tracing for nested functions.
1358- // It is the optimizer's responsibility to add the dependencies it requires on its own.
1359- _PyBloomFilter new_dependencies ;
1360- _Py_BloomFilter_Init (& new_dependencies );
1361- _Py_BloomFilter_Add (& new_dependencies , _tstate -> jit_tracer_state .initial_state .code );
1354+ _PyBloomFilter * dependencies = & _tstate -> jit_tracer_state .prev_state .dependencies ;
13621355 _PyUOpInstruction * buffer = _tstate -> jit_tracer_state .code_buffer ;
13631356 OPT_STAT_INC (attempts );
13641357 char * env_var = Py_GETENV ("PYTHON_UOPS_OPTIMIZE" );
@@ -1378,7 +1371,7 @@ uop_optimize(
13781371 length = _Py_uop_analyze_and_optimize (
13791372 _tstate -> jit_tracer_state .initial_state .func ,
13801373 buffer ,length ,
1381- curr_stackentries , & new_dependencies );
1374+ curr_stackentries , dependencies );
13821375 if (length <= 0 ) {
13831376 return length ;
13841377 }
@@ -1402,7 +1395,7 @@ uop_optimize(
14021395 length = prepare_for_execution (buffer , length );
14031396 assert (length <= UOP_MAX_TRACE_LENGTH );
14041397 _PyExecutorObject * executor = make_executor_from_uops (
1405- buffer , length , & new_dependencies , _tstate -> jit_tracer_state .initial_state .chain_depth );
1398+ buffer , length , dependencies , _tstate -> jit_tracer_state .initial_state .chain_depth );
14061399 if (executor == NULL ) {
14071400 return -1 ;
14081401 }
0 commit comments