diff options
| author | Ken Jin <kenjin4096@gmail.com> | 2022-05-25 13:06:15 (GMT) | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-25 13:06:15 (GMT) | 
| commit | 5e6e5b98a8b943a8e05feb9c0c982150565f4c10 (patch) | |
| tree | 6dd6c8e8057ff014fcc365db4fe83dad0bf3aea6 /Python/ceval.c | |
| parent | db3ef0c82a1a16db60c35f8a08c3fd9bfaa8b643 (diff) | |
| download | cpython-5e6e5b98a8b943a8e05feb9c0c982150565f4c10.zip cpython-5e6e5b98a8b943a8e05feb9c0c982150565f4c10.tar.gz cpython-5e6e5b98a8b943a8e05feb9c0c982150565f4c10.tar.bz2 | |
gh-92777: Add LOAD_METHOD_LAZY_DICT (GH-92778)
Diffstat (limited to 'Python/ceval.c')
| -rw-r--r-- | Python/ceval.c | 23 | 
1 files changed, 23 insertions, 0 deletions
| diff --git a/Python/ceval.c b/Python/ceval.c index e82f734..56b1017 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4673,6 +4673,29 @@ handle_eval_breaker:              NOTRACE_DISPATCH();          } +        TARGET(LOAD_METHOD_LAZY_DICT) { +            assert(cframe.use_tracing == 0); +            PyObject *self = TOP(); +            PyTypeObject *self_cls = Py_TYPE(self); +            _PyLoadMethodCache *cache = (_PyLoadMethodCache *)next_instr; +            uint32_t type_version = read_u32(cache->type_version); +            DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_METHOD); +            int dictoffset = cache->dict_offset; +            PyObject *dict = *(PyObject **)((char *)self + dictoffset); +            assert(dictoffset == self_cls->tp_dictoffset && dictoffset > 0); +            /* This object has a __dict__, just not yet created */ +            DEOPT_IF(dict != NULL, LOAD_METHOD); +            STAT_INC(LOAD_METHOD, hit); +            PyObject *res = read_obj(cache->descr); +            assert(res != NULL); +            assert(_PyType_HasFeature(Py_TYPE(res), Py_TPFLAGS_METHOD_DESCRIPTOR)); +            Py_INCREF(res); +            SET_TOP(res); +            PUSH(self); +            JUMPBY(INLINE_CACHE_ENTRIES_LOAD_METHOD); +            NOTRACE_DISPATCH(); +        } +          TARGET(LOAD_METHOD_MODULE) {              /* LOAD_METHOD, for module methods */              assert(cframe.use_tracing == 0); | 
