@@ -5414,6 +5414,7 @@ dummy_func(
54145414 }
54155415
54165416 tier2 op (_ERROR_POP_N , (target /2 -- )) {
5417+ assert (target != 0 );
54175418 assert (oparg == 0 );
54185419 frame -> instr_ptr = _PyFrame_GetBytecode (frame ) + target ;
54195420 SYNC_SP ();
@@ -5435,28 +5436,35 @@ dummy_func(
54355436 tier2 op (_COLD_EXIT , ( -- )) {
54365437 _PyExitData * exit = tstate -> jit_exit ;
54375438 assert (exit != NULL );
5438- _Py_CODEUNIT * target = _PyFrame_GetBytecode (frame ) + exit -> target ;
5439- _Py_BackoffCounter temperature = exit -> temperature ;
5440- if (!backoff_counter_triggers (temperature )) {
5441- exit -> temperature = advance_backoff_counter (temperature );
5442- GOTO_TIER_ONE (target , 0 );
5443- }
5444- _PyExecutorObject * executor ;
5445- if (target -> op .code == ENTER_EXECUTOR ) {
5446- PyCodeObject * code = _PyFrame_GetCode (frame );
5447- executor = code -> co_executors -> executors [target -> op .arg ];
5448- Py_INCREF (executor );
5449- }
5450- else {
5451- _PyExecutorObject * previous_executor = _PyExecutor_FromExit (exit );
5452- assert (tstate -> current_executor == (PyObject * )previous_executor );
5453- int chain_depth = previous_executor -> vm_data .chain_depth + 1 ;
5454- _PyJIT_InitializeTracing (tstate , frame , target , STACK_LEVEL (), chain_depth );
5455- GOTO_TIER_ONE (target , 1 );
5456- }
5457- assert (tstate -> jit_exit == exit );
5458- exit -> executor = executor ;
5459- TIER2_TO_TIER2 (exit -> executor );
5439+ bool is_dynamic = exit -> is_dynamic ;
5440+ _Py_CODEUNIT * target = is_dynamic ? frame -> instr_ptr : (_PyFrame_GetBytecode (frame ) + exit -> target );
5441+ GOTO_TIER_ONE (target , 0 );
5442+ // _Py_BackoffCounter temperature = exit->temperature;
5443+ // if (target->op.code == ENTER_EXECUTOR) {
5444+ // PyCodeObject *code = _PyFrame_GetCode(frame);
5445+ // _PyExecutorObject *executor = code->co_executors->executors[target->op.arg];
5446+ // if (is_dynamic && executor->expected_entrypoint != target) {
5447+ // GOTO_TIER_ONE(target, 0);
5448+ // }
5449+ // Py_INCREF(executor);
5450+ // assert(tstate->jit_exit == exit);
5451+ // exit->executor = executor;
5452+ // TIER2_TO_TIER2(exit->executor);
5453+ // }
5454+ // else {
5455+ // if (!backoff_counter_triggers(temperature)) {
5456+ // exit->temperature = advance_backoff_counter(temperature);
5457+ // GOTO_TIER_ONE(target, 0);
5458+ // }
5459+ // if (is_dynamic) {
5460+ // GOTO_TIER_ONE(target, 0);
5461+ // }
5462+ // _PyExecutorObject *previous_executor = _PyExecutor_FromExit(exit);
5463+ // assert(tstate->current_executor == (PyObject *)previous_executor);
5464+ // int chain_depth = 0;
5465+ // _PyJIT_InitializeTracing(tstate, frame, target, STACK_LEVEL(), chain_depth);
5466+ // GOTO_TIER_ONE(target, 1);
5467+ // }
54605468 }
54615469
54625470 tier2 op (_GUARD_IP , (ip /4 -- )) {
@@ -5465,36 +5473,20 @@ dummy_func(
54655473
54665474 tier2 op (_DYNAMIC_EXIT , (exit_p /4 -- )) {
54675475 _Py_CODEUNIT * target = frame -> instr_ptr ;
5476+ _PyExitData * exit = (_PyExitData * )exit_p ;
54685477#if defined(Py_DEBUG ) && !defined(_Py_JIT )
5478+ OPT_HIST (trace_uop_execution_counter , trace_run_length_hist );
54695479 if (frame -> lltrace >= 2 ) {
5470- printf ("GUARD IP EXIT: [UOp " );
5480+ printf ("DYNAMIC EXIT: [UOp " );
54715481 _PyUOpPrint (& next_uop [-1 ]);
5472- printf (", target %d -> %s]\n" ,
5482+ printf (", exit %tu, temp %d, target %d -> %s]\n" ,
5483+ exit - current_executor -> exits , exit -> temperature .value_and_backoff ,
54735484 (int )(target - _PyFrame_GetBytecode (frame )),
54745485 _PyOpcode_OpName [target -> op .code ]);
54755486 }
54765487#endif
5477- _PyExitData * exit = (_PyExitData * )exit_p ;
5478- tstate -> jit_exit = exit_p ;
5479- _Py_BackoffCounter temperature = exit -> temperature ;
5480- _PyExecutorObject * executor ;
5481- if (target -> op .code == ENTER_EXECUTOR ) {
5482- PyCodeObject * code = _PyFrame_GetCode (frame );
5483- executor = code -> co_executors -> executors [target -> op .arg ];
5484- Py_INCREF (executor );
5485- }
5486- else {
5487- if (!backoff_counter_triggers (temperature )) {
5488- exit -> temperature = advance_backoff_counter (temperature );
5489- GOTO_TIER_ONE (frame -> instr_ptr , 0 );
5490- }
5491- _PyExecutorObject * previous_executor = _PyExecutor_FromExit (exit );
5492- assert (tstate -> current_executor == (PyObject * )previous_executor );
5493- // Set chain_depth to 0 because we want to keep tracing whatever we see next.
5494- _PyJIT_InitializeTracing (tstate , frame , target , STACK_LEVEL (), 0 );
5495- GOTO_TIER_ONE (target , 1 );
5496- }
5497- exit -> executor = executor ;
5488+ assert (exit -> is_dynamic );
5489+ tstate -> jit_exit = exit ;
54985490 TIER2_TO_TIER2 (exit -> executor );
54995491 }
55005492
0 commit comments