Skip to content

Commit b666cd0

Browse files
committed
Deopt if not owned, and mark as shared in specializer
1 parent 60df19c commit b666cd0

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

Python/bytecodes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ dummy_func(
22882288
PyDictKeysObject *dk = FT_ATOMIC_LOAD_PTR(dict->ma_keys);
22892289
assert(PyDict_CheckExact((PyObject *)dict));
22902290
#ifdef Py_GIL_DISABLED
2291-
_PyDict_EnsureSharedOnRead(dict);
2291+
DEOPT_IF(!_Py_IsOwnedByCurrentThread((PyObject *)dict) && !_PyObject_GC_IS_SHARED(dict));
22922292
#endif
22932293
PyObject *attr_o;
22942294
if (hint >= (size_t)FT_ATOMIC_LOAD_SSIZE_RELAXED(dk->dk_nentries)) {

Python/executor_cases.c.h

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/specialize.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,9 @@ specialize_dict_access_hint(
10091009
_PyAttrCache *cache = (_PyAttrCache *)(instr + 1);
10101010

10111011
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(dict);
1012+
#ifdef Py_GIL_DISABLED
1013+
_PyDict_EnsureSharedOnRead(dict);
1014+
#endif
10121015

10131016
// We found an instance with a __dict__.
10141017
if (_PyDict_HasSplitTable(dict)) {

0 commit comments

Comments
 (0)