Skip to content

Commit e822cb9

Browse files
committed
Fix no-GIL build failure in _COLD_EXIT
1 parent 309f021 commit e822cb9

File tree

2 files changed

+50
-46
lines changed

2 files changed

+50
-46
lines changed

Python/bytecodes.c

+25-23
Original file line numberDiff line numberDiff line change
@@ -4151,32 +4151,34 @@ dummy_func(
41514151
_PyExitData *exit = &previous->exits[oparg];
41524152
PyCodeObject *code = _PyFrame_GetCode(frame);
41534153
_Py_CODEUNIT *target = _PyCode_CODE(code) + exit->target;
4154-
if (!ADAPTIVE_COUNTER_IS_ZERO(exit->temperature)) {
4155-
DECREMENT_ADAPTIVE_COUNTER(exit->temperature);
4156-
GOTO_TIER_ONE(target);
4157-
}
4158-
_PyExecutorObject *executor;
4159-
if (target->op.code == ENTER_EXECUTOR) {
4160-
executor = code->co_executors->executors[target->op.arg];
4161-
Py_INCREF(executor);
4162-
}
4163-
else {
4164-
int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor);
4165-
if (optimized <= 0) {
4166-
exit->temperature = adaptive_counter_backoff(exit->temperature);
4167-
if (optimized < 0) {
4168-
Py_DECREF(previous);
4169-
tstate->previous_executor = Py_None;
4170-
ERROR_IF(1, error);
4154+
#if ENABLE_SPECIALIZATION
4155+
if (ADAPTIVE_COUNTER_IS_ZERO(exit->temperature)) {
4156+
_PyExecutorObject *executor;
4157+
if (target->op.code == ENTER_EXECUTOR) {
4158+
executor = code->co_executors->executors[target->op.arg];
4159+
Py_INCREF(executor);
4160+
}
4161+
else {
4162+
int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor);
4163+
if (optimized <= 0) {
4164+
exit->temperature = adaptive_counter_backoff(exit->temperature);
4165+
if (optimized < 0) {
4166+
Py_DECREF(previous);
4167+
tstate->previous_executor = Py_None;
4168+
ERROR_IF(1, error);
4169+
}
4170+
GOTO_TIER_ONE(target);
41714171
}
4172-
GOTO_TIER_ONE(target);
41734172
}
4173+
/* We need two references. One to store in exit->executor and
4174+
* one to keep the executor alive when executing. */
4175+
Py_INCREF(executor);
4176+
exit->executor = executor;
4177+
GOTO_TIER_TWO(executor);
41744178
}
4175-
/* We need two references. One to store in exit->executor and
4176-
* one to keep the executor alive when executing. */
4177-
Py_INCREF(executor);
4178-
exit->executor = executor;
4179-
GOTO_TIER_TWO(executor);
4179+
DECREMENT_ADAPTIVE_COUNTER(exit->temperature);
4180+
#endif
4181+
GOTO_TIER_ONE(target);
41804182
}
41814183

41824184
tier2 op(_START_EXECUTOR, (executor/4 --)) {

Python/executor_cases.c.h

+25-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)