mirror of
https://github.com/python/cpython.git
synced 2026-05-06 12:49:07 -04:00
gh-143732: allow dict subclasses to be specialized (GH-148128)
This commit is contained in:
@@ -2166,17 +2166,45 @@ dummy_func(void) {
|
||||
}
|
||||
}
|
||||
|
||||
op(_GUARD_NOS_DICT, (nos, unused -- nos, unused)) {
|
||||
if (sym_matches_type(nos, &PyDict_Type)) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
op(_GUARD_NOS_DICT_SUBSCRIPT, (nos, unused -- nos, unused)) {
|
||||
PyTypeObject *tp = sym_get_type(nos);
|
||||
bool definite = true;
|
||||
if (!tp) {
|
||||
tp = sym_get_probable_type(nos);
|
||||
definite = false;
|
||||
}
|
||||
if (tp && tp->tp_as_mapping &&
|
||||
tp->tp_as_mapping->mp_subscript == _PyDict_Subscript) {
|
||||
if (definite) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
else {
|
||||
ADD_OP(_GUARD_TYPE, 0, (uintptr_t)tp);
|
||||
sym_set_type(nos, tp);
|
||||
}
|
||||
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)tp);
|
||||
_Py_BloomFilter_Add(dependencies, tp);
|
||||
}
|
||||
sym_set_type(nos, &PyDict_Type);
|
||||
}
|
||||
|
||||
op(_GUARD_NOS_ANY_DICT, (nos, unused -- nos, unused)) {
|
||||
op(_GUARD_NOS_DICT_STORE_SUBSCRIPT, (unused, nos, unused -- unused, nos, unused)) {
|
||||
PyTypeObject *tp = sym_get_type(nos);
|
||||
if (tp == &PyDict_Type || tp == &PyFrozenDict_Type) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
bool definite = true;
|
||||
if (!tp) {
|
||||
tp = sym_get_probable_type(nos);
|
||||
definite = false;
|
||||
}
|
||||
if (tp && tp->tp_as_mapping &&
|
||||
tp->tp_as_mapping->mp_ass_subscript == _PyDict_StoreSubscript) {
|
||||
if (definite) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
else {
|
||||
ADD_OP(_GUARD_TYPE, 0, (uintptr_t)tp);
|
||||
sym_set_type(nos, tp);
|
||||
}
|
||||
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)tp);
|
||||
_Py_BloomFilter_Add(dependencies, tp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user