Skip to content

Commit a2bdac7

Browse files
committed
Deopt if not owned, and mark as shared in specializer
1 parent aa0b67d commit a2bdac7

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
@@ -2287,7 +2287,7 @@ dummy_func(
22872287
PyDictKeysObject *dk = FT_ATOMIC_LOAD_PTR(dict->ma_keys);
22882288
assert(PyDict_CheckExact((PyObject *)dict));
22892289
#ifdef Py_GIL_DISABLED
2290-
_PyDict_EnsureSharedOnRead(dict);
2290+
DEOPT_IF(!_Py_IsOwnedByCurrentThread((PyObject *)dict) && !_PyObject_GC_IS_SHARED(dict));
22912291
#endif
22922292
PyObject *attr_o;
22932293
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)