Skip to content

Commit 1f4a350

Browse files
committed
Address code review
1 parent aa8a81c commit 1f4a350

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

Python/specialize.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -689,24 +689,6 @@ set_opcode(_Py_CODEUNIT *instr, uint8_t opcode)
689689
#endif
690690
}
691691

692-
static inline int
693-
set_cache_version(uint16_t *old_version, uint32_t new_version)
694-
{
695-
#ifdef Py_GIL_DISABLED
696-
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-
}
700-
if (!_Py_atomic_compare_exchange_uint16(old_version, &old_version_val, new_version)) {
701-
return 0;
702-
}
703-
return 1;
704-
#else
705-
write_u32(old_version, new_version);
706-
return 1;
707-
#endif
708-
}
709-
710692
static inline void
711693
set_counter(_Py_BackoffCounter *counter, _Py_BackoffCounter value)
712694
{
@@ -2755,16 +2737,13 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27552737
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
27562738
return;
27572739
}
2758-
uint32_t version = FT_ATOMIC_LOAD_UINT32_RELAXED(Py_TYPE(value)->tp_version_tag);
2740+
uint32_t version = Py_TYPE(value)->tp_version_tag;
27592741
if (version == 0) {
27602742
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
27612743
return;
27622744
}
2763-
if (!set_cache_version(cache->version, version)) {
2764-
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
2765-
return;
2766-
}
27672745
specialize(instr, TO_BOOL_ALWAYS_TRUE);
2746+
write_u32(cache->version, version);
27682747
assert(version);
27692748
return;
27702749
}

0 commit comments

Comments
 (0)