Skip to content

Commit aa8a81c

Browse files
committed
nit
1 parent bafabd7 commit aa8a81c

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Python/specialize.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -690,10 +690,13 @@ set_opcode(_Py_CODEUNIT *instr, uint8_t opcode)
690690
}
691691

692692
static inline int
693-
set_cache_verison(uint16_t *old_version, uint32_t new_version)
693+
set_cache_version(uint16_t *old_version, uint32_t new_version)
694694
{
695695
#ifdef Py_GIL_DISABLED
696696
uint16_t old_version_val = _Py_atomic_load_uint16_relaxed(old_version);
697+
if (old_version_val > (uint16_t)new_version) {
698+
return 0;
699+
}
697700
if (!_Py_atomic_compare_exchange_uint16(old_version, &old_version_val, new_version)) {
698701
return 0;
699702
}
@@ -2757,13 +2760,7 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27572760
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
27582761
return;
27592762
}
2760-
#ifdef Py_GIL_DISABLED
2761-
if (read_u32(cache->version) > version) {
2762-
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
2763-
return;
2764-
}
2765-
#endif
2766-
if (!set_cache_verison(cache->version, version)) {
2763+
if (!set_cache_version(cache->version, version)) {
27672764
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
27682765
return;
27692766
}

0 commit comments

Comments
 (0)