Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 015bb00

Browse files
committed
Fix no-GIL build failure in _COLD_EXIT
1 parent 54c1f8e commit 015bb00

File tree

2 files changed

+50
-46
lines changed

2 files changed

+50
-46
lines changed

Python/bytecodes.c

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4159,32 +4159,34 @@ dummy_func(
41594159
_PyExitData *exit = &previous->exits[oparg];
41604160
PyCodeObject *code = _PyFrame_GetCode(frame);
41614161
_Py_CODEUNIT *target = _PyCode_CODE(code) + exit->target;
4162-
if (!ADAPTIVE_COUNTER_IS_ZERO(exit->temperature)) {
4163-
DECREMENT_ADAPTIVE_COUNTER(exit->temperature);
4164-
GOTO_TIER_ONE(target);
4165-
}
4166-
_PyExecutorObject *executor;
4167-
if (target->op.code == ENTER_EXECUTOR) {
4168-
executor = code->co_executors->executors[target->op.arg];
4169-
Py_INCREF(executor);
4170-
}
4171-
else {
4172-
int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor);
4173-
if (optimized <= 0) {
4174-
exit->temperature = adaptive_counter_backoff(exit->temperature);
4175-
if (optimized < 0) {
4176-
Py_DECREF(previous);
4177-
tstate->previous_executor = Py_None;
4178-
GOTO_UNWIND();
4162+
#if ENABLE_SPECIALIZATION
4163+
if (ADAPTIVE_COUNTER_IS_ZERO(exit->temperature)) {
4164+
_PyExecutorObject *executor;
4165+
if (target->op.code == ENTER_EXECUTOR) {
4166+
executor = code->co_executors->executors[target->op.arg];
4167+
Py_INCREF(executor);
4168+
}
4169+
else {
4170+
int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor);
4171+
if (optimized <= 0) {
4172+
exit->temperature = adaptive_counter_backoff(exit->temperature);
4173+
if (optimized < 0) {
4174+
Py_DECREF(previous);
4175+
tstate->previous_executor = Py_None;
4176+
GOTO_UNWIND();
4177+
}
4178+
GOTO_TIER_ONE(target);
41794179
}
4180-
GOTO_TIER_ONE(target);
41814180
}
4181+
/* We need two references. One to store in exit->executor and
4182+
* one to keep the executor alive when executing. */
4183+
Py_INCREF(executor);
4184+
exit->executor = executor;
4185+
GOTO_TIER_TWO(executor);
41824186
}
4183-
/* We need two references. One to store in exit->executor and
4184-
* one to keep the executor alive when executing. */
4185-
Py_INCREF(executor);
4186-
exit->executor = executor;
4187-
GOTO_TIER_TWO(executor);
4187+
DECREMENT_ADAPTIVE_COUNTER(exit->temperature);
4188+
#endif
4189+
GOTO_TIER_ONE(target);
41884190
}
41894191

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

Python/executor_cases.c.h

Lines changed: 25 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)