@@ -165,8 +165,6 @@ ASSERT_DICT_LOCKED(PyObject *op)
165165
166166#define  IS_DICT_SHARED (mp ) _PyObject_GC_IS_SHARED(mp)
167167#define  SET_DICT_SHARED (mp ) _PyObject_GC_SET_SHARED(mp)
168- #define  IS_DICT_SHARED_INLINE (mp ) _PyObject_GC_IS_SHARED_INLINE(mp)
169- #define  SET_DICT_SHARED_INLINE (mp ) _PyObject_GC_SET_SHARED_INLINE(mp)
170168#define  LOAD_INDEX (keys , size , idx ) _Py_atomic_load_int##size##_relaxed(&((const int##size##_t*)keys->dk_indices)[idx]);
171169#define  STORE_INDEX (keys , size , idx , value ) _Py_atomic_store_int##size##_relaxed(&((int##size##_t*)keys->dk_indices)[idx], (int##size##_t)value);
172170#define  ASSERT_OWNED_OR_SHARED (mp ) \
@@ -247,8 +245,6 @@ static inline void split_keys_entry_added(PyDictKeysObject *keys)
247245#define  UNLOCK_KEYS_IF_SPLIT (keys , kind )
248246#define  IS_DICT_SHARED (mp ) (false)
249247#define  SET_DICT_SHARED (mp )
250- #define  IS_DICT_SHARED_INLINE (mp ) (false)
251- #define  SET_DICT_SHARED_INLINE (mp )
252248#define  LOAD_INDEX (keys , size , idx ) ((const int##size##_t*)(keys->dk_indices))[idx]
253249#define  STORE_INDEX (keys , size , idx , value ) ((int##size##_t*)(keys->dk_indices))[idx] = (int##size##_t)value
254250
@@ -3202,7 +3198,7 @@ dict_dealloc(PyObject *self)
32023198        assert (keys -> dk_refcnt  ==  1  ||  keys  ==  Py_EMPTY_KEYS );
32033199        dictkeys_decref (interp , keys , false);
32043200    }
3205-     if  (Py_IS_TYPE (mp , & PyDict_Type )  &&  ! IS_DICT_SHARED_INLINE ( mp ) ) {
3201+     if  (Py_IS_TYPE (mp , & PyDict_Type )) {
32063202        _Py_FREELIST_FREE (dicts , mp , Py_TYPE (mp )-> tp_free );
32073203    }
32083204    else  {
@@ -7167,8 +7163,6 @@ try_set_dict_inline_only_or_other_dict(PyObject *obj, PyObject *new_dict, PyDict
71677163    return  replaced ;
71687164}
71697165
7170- #endif 
7171- 
71727166// Replaces a dictionary that is probably the dictionary which has been 
71737167// materialized and points at the inline values. We could have raced 
71747168// and replaced it with another dictionary though. 
@@ -7187,18 +7181,20 @@ replace_dict_probably_inline_materialized(PyObject *obj, PyDictObject *inline_di
71877181        if  (err  !=  0 ) {
71887182            return  err ;
71897183        }
7190-         SET_DICT_SHARED_INLINE ((PyObject  * )inline_dict );
71917184        // We incref'd the inline dict and the object owns a ref. 
71927185        // Clear the object's reference, we'll clear the local 
71937186        // reference after releasing the lock. 
7194-         Py_CLEAR (* replaced_dict );
7187+         _PyObject_XDecRefDelayed ((PyObject  * )* replaced_dict );
7188+         * replaced_dict  =  NULL ;
71957189    }
71967190
71977191    FT_ATOMIC_STORE_PTR (_PyObject_ManagedDictPointer (obj )-> dict ,
71987192                    (PyDictObject  * )Py_XNewRef (new_dict ));
71997193    return  err ;
72007194}
72017195
7196+ #endif 
7197+ 
72027198int 
72037199_PyObject_SetManagedDict (PyObject  * obj , PyObject  * new_dict )
72047200{
@@ -7231,12 +7227,9 @@ _PyObject_SetManagedDict(PyObject *obj, PyObject *new_dict)
72317227        }
72327228
72337229        if  (prev_dict  !=  NULL ) {
7234-             Py_BEGIN_CRITICAL_SECTION (prev_dict );
7235-             SET_DICT_SHARED_INLINE ((PyObject  * )prev_dict );
7236-             Py_END_CRITICAL_SECTION ();
72377230            // Readers from the old dictionary use a borrowed reference. We need 
7238-             // to set the dict to be freed via QSBR which requires locking it . 
7239-             Py_DECREF ( prev_dict );
7231+             // to set the decref the dict at the next safe point . 
7232+             _PyObject_XDecRefDelayed (( PyObject   * ) prev_dict );
72407233        }
72417234        return  0 ;
72427235#else 
@@ -7264,14 +7257,7 @@ _PyObject_SetManagedDict(PyObject *obj, PyObject *new_dict)
72647257                            (PyDictObject  * )Py_XNewRef (new_dict ));
72657258
72667259        Py_END_CRITICAL_SECTION ();
7267- #ifdef  Py_GIL_DISABLED 
7268-         if  (dict  !=  NULL ) {
7269-             Py_BEGIN_CRITICAL_SECTION (dict );
7270-             SET_DICT_SHARED_INLINE ((PyObject  * )dict );
7271-             Py_END_CRITICAL_SECTION ();
7272-         }
7273- #endif 
7274-         Py_XDECREF (dict );
7260+         _PyObject_XDecRefDelayed ((PyObject  * )dict );
72757261    }
72767262    assert (_PyObject_InlineValuesConsistencyCheck (obj ));
72777263    return  err ;
0 commit comments