Skip to content

Commit ffcc450

Browse files
authored
gh-112075: Enable freeing with qsbr and fallback to lock on key changed (GH-116336)
1 parent 7af063d commit ffcc450

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Objects/dictobject.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ set_values(PyDictObject *mp, PyDictValues *values)
183183
_Py_atomic_store_ptr_release(&mp->ma_values, values);
184184
}
185185

186-
// Defined until we get QSBR
187-
#define _PyMem_FreeQsbr PyMem_Free
188-
189186
#define LOCK_KEYS(keys) PyMutex_LockFlags(&keys->dk_mutex, _Py_LOCK_DONT_DETACH)
190187
#define UNLOCK_KEYS(keys) PyMutex_Unlock(&keys->dk_mutex)
191188

@@ -806,7 +803,7 @@ free_keys_object(PyDictKeysObject *keys, bool use_qsbr)
806803
{
807804
#ifdef Py_GIL_DISABLED
808805
if (use_qsbr) {
809-
_PyMem_FreeQsbr(keys);
806+
_PyMem_FreeDelayed(keys);
810807
return;
811808
}
812809
#endif
@@ -846,7 +843,7 @@ free_values(PyDictValues *values, bool use_qsbr)
846843
int prefix_size = DICT_VALUES_SIZE(values);
847844
#ifdef Py_GIL_DISABLED
848845
if (use_qsbr) {
849-
_PyMem_FreeQsbr(((char *)values)-prefix_size);
846+
_PyMem_FreeDelayed(((char *)values)-prefix_size);
850847
return;
851848
}
852849
#endif
@@ -6694,7 +6691,7 @@ _PyObject_StoreInstanceAttribute(PyObject *obj, PyDictValues *values,
66946691
#ifdef Py_GIL_DISABLED
66956692
// Try a thread-safe lookup to see if the index is already allocated
66966693
ix = unicodekeys_lookup_unicode_threadsafe(keys, name, hash);
6697-
if (ix == DKIX_EMPTY) {
6694+
if (ix == DKIX_EMPTY || ix == DKIX_KEY_CHANGED) {
66986695
// Lock keys and do insert
66996696
LOCK_KEYS(keys);
67006697
ix = insert_into_splitdictkeys(keys, name, hash);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy