Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
bpo-45340: Don't create object dictionaries unless actually needed#28802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
8214006
45c9814
c3de09e
58dd2a0
769183a
1e6cd1f
a8fbb34
37d8cc6
0e022f9
ddd2e2c
e979575
42361ad
e9b09d5
70dc34f
022f2c5
4ec5f11
1818a5a
bfc7be0
62a3a59
7978220
b25b1d9
7b2efa4
459e29e
83b90c5
8c894f3
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3615,6 +3615,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr | ||
} | ||
TARGET(LOAD_ATTR_SPLIT_KEYS): { | ||
/* TO DO: rename instruction */ | ||
assert(cframe.use_tracing == 0); | ||
PyObject *owner = TOP(); | ||
PyObject *res; | ||
@@ -3625,11 +3626,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr | ||
assert(cache1->tp_version != 0); | ||
DEOPT_IF(tp->tp_version_tag != cache1->tp_version, LOAD_ATTR); | ||
assert(tp->tp_dictoffset > 0); | ||
assert(tp->tp_inline_values_offset > 0); | ||
PyDictValues *values = *(PyDictValues **)(((char *)owner) + tp->tp_inline_values_offset); | ||
DEOPT_IF(values == NULL, LOAD_ATTR); | ||
res = values->values[cache0->index]; | ||
DEOPT_IF(res == NULL, LOAD_ATTR); | ||
STAT_INC(LOAD_ATTR, hit); | ||
record_cache_hit(cache0); | ||
@@ -3722,6 +3722,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr | ||
} | ||
TARGET(STORE_ATTR_SPLIT_KEYS): { | ||
/* TO DO: rename instruction */ | ||
assert(cframe.use_tracing == 0); | ||
PyObject *owner = TOP(); | ||
PyTypeObject *tp = Py_TYPE(owner); | ||
@@ -3731,31 +3732,23 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr | ||
assert(cache1->tp_version != 0); | ||
DEOPT_IF(tp->tp_version_tag != cache1->tp_version, STORE_ATTR); | ||
assert(tp->tp_dictoffset > 0); | ||
assert(tp->tp_inline_values_offset > 0); | ||
PyDictValues *values = *(PyDictValues **)(((char *)owner) + tp->tp_inline_values_offset); | ||
DEOPT_IF(values == NULL, STORE_ATTR); | ||
STAT_INC(STORE_ATTR, hit); | ||
record_cache_hit(cache0); | ||
int index = cache0->index; | ||
STACK_SHRINK(1); | ||
PyObject *value = POP(); | ||
PyObject *old_value =values->values[index]; | ||
values->values[index] = value; | ||
if (old_value == NULL) { | ||
assert(index < 16); | ||
values->mv_order = (values->mv_order << 4) | index; | ||
} | ||
else { | ||
Py_DECREF(old_value); | ||
} | ||
Py_DECREF(owner); | ||
DISPATCH(); | ||
} | ||
@@ -4470,21 +4463,31 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr | ||
_PyObjectCache *cache2 = &caches[-2].obj; | ||
DEOPT_IF(self_cls->tp_version_tag != cache1->tp_version, LOAD_METHOD); | ||
assert(self_cls->tp_dictoffset > 0); | ||
assert(self_cls->tp_inline_values_offset > 0); | ||
PyDictObject *dict = *(PyDictObject **)(((char *)self) + self_cls->tp_dictoffset); | ||
DEOPT_IF(dict != NULL, LOAD_METHOD); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Wait is this due to the new scheme that objects shouldn't have dict unless really required? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yes, it is. We assume that having no | ||
DEOPT_IF(((PyHeapTypeObject *)self_cls)->ht_cached_keys->dk_version != cache1->dk_version_or_hint, LOAD_METHOD); | ||
STAT_INC(LOAD_METHOD, hit); | ||
record_cache_hit(cache0); | ||
PyObject *res = cache2->obj; | ||
assert(res != NULL); | ||
assert(_PyType_HasFeature(Py_TYPE(res), Py_TPFLAGS_METHOD_DESCRIPTOR)); | ||
Py_INCREF(res); | ||
SET_TOP(res); | ||
PUSH(self); | ||
DISPATCH(); | ||
} | ||
TARGET(LOAD_METHOD_NO_DICT): { | ||
PyObject *self = TOP(); | ||
PyTypeObject *self_cls = Py_TYPE(self); | ||
SpecializedCacheEntry *caches = GET_CACHE(); | ||
_PyAdaptiveEntry *cache0 = &caches[0].adaptive; | ||
_PyAttrCache *cache1 = &caches[-1].attr; | ||
_PyObjectCache *cache2 = &caches[-2].obj; | ||
DEOPT_IF(self_cls->tp_version_tag != cache1->tp_version, LOAD_METHOD); | ||
assert(self_cls->tp_dictoffset == 0); | ||
STAT_INC(LOAD_METHOD, hit); | ||
record_cache_hit(cache0); | ||
PyObject *res = cache2->obj; | ||
@@ -4526,7 +4529,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr | ||
record_cache_hit(cache0); | ||
PyObject *res = cache2->obj; | ||
assert(res != NULL); | ||
Py_INCREF(res); | ||
SET_TOP(NULL); | ||
Py_DECREF(cls); | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.