Skip to content

Commit a07d32f

Browse files
committed
Fix incorrect use of compare-exchange.
1 parent c92089c commit a07d32f

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

Python/bytecodes.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,12 @@ dummy_func(
297297
#if ENABLE_SPECIALIZATION_FT
298298
#ifdef Py_GIL_DISABLED
299299
uint8_t expected = LOAD_CONST;
300-
_Py_atomic_compare_exchange_uint8(
301-
&this_instr->op.code, &expected,
302-
_Py_IsImmortal(obj) ? LOAD_CONST_IMMORTAL : LOAD_CONST_MORTAL);
303-
// We might lose a race with instrumentation, which we don't care about.
304-
assert(expected >= MIN_INSTRUMENTED_OPCODE ||
305-
(expected == LOAD_CONST_IMMORTAL && _Py_IsImmortal(obj)) ||
306-
(expected == LOAD_CONST_MORTAL && !_Py_IsImmortal(obj)));
300+
if (!_Py_atomic_compare_exchange_uint8(
301+
&this_instr->op.code, &expected,
302+
_Py_IsImmortal(obj) ? LOAD_CONST_IMMORTAL : LOAD_CONST_MORTAL)) {
303+
// We might lose a race with instrumentation, which we don't care about.
304+
assert(expected >= MIN_INSTRUMENTED_OPCODE);
305+
}
307306
#else
308307
if (this_instr->op.code == LOAD_CONST) {
309308
this_instr->op.code = _Py_IsImmortal(obj) ? LOAD_CONST_IMMORTAL : LOAD_CONST_MORTAL;

Python/generated_cases.c.h

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

0 commit comments

Comments
 (0)