mirror of
https://github.com/python/cpython.git
synced 2026-01-06 07:22:09 +00:00
gh-115999: Enable BINARY_SUBSCR_GETITEM for free-threaded build (gh-127737)
This commit is contained in:
parent
f802c8bf87
commit
48c70b8f7d
12 changed files with 118 additions and 62 deletions
|
|
@ -5679,6 +5679,31 @@ _PyType_CacheInitForSpecialization(PyHeapTypeObject *type, PyObject *init,
|
|||
return can_cache;
|
||||
}
|
||||
|
||||
int
|
||||
_PyType_CacheGetItemForSpecialization(PyHeapTypeObject *ht, PyObject *descriptor, uint32_t tp_version)
|
||||
{
|
||||
if (!descriptor || !tp_version) {
|
||||
return 0;
|
||||
}
|
||||
int can_cache;
|
||||
BEGIN_TYPE_LOCK();
|
||||
can_cache = ((PyTypeObject*)ht)->tp_version_tag == tp_version;
|
||||
// This pointer is invalidated by PyType_Modified (see the comment on
|
||||
// struct _specialization_cache):
|
||||
PyFunctionObject *func = (PyFunctionObject *)descriptor;
|
||||
uint32_t version = _PyFunction_GetVersionForCurrentState(func);
|
||||
can_cache = can_cache && _PyFunction_IsVersionValid(version);
|
||||
#ifdef Py_GIL_DISABLED
|
||||
can_cache = can_cache && _PyObject_HasDeferredRefcount(descriptor);
|
||||
#endif
|
||||
if (can_cache) {
|
||||
FT_ATOMIC_STORE_PTR_RELEASE(ht->_spec_cache.getitem, descriptor);
|
||||
FT_ATOMIC_STORE_UINT32_RELAXED(ht->_spec_cache.getitem_version, version);
|
||||
}
|
||||
END_TYPE_LOCK();
|
||||
return can_cache;
|
||||
}
|
||||
|
||||
static void
|
||||
set_flags(PyTypeObject *self, unsigned long mask, unsigned long flags)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue