aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>2021-09-17 18:47:36 +0800
committerGitHub <noreply@github.com>2021-09-17 18:47:36 +0800
commit70bed6f9936c811472b376edd93c37bcf8f06f35 (patch)
tree7d44f3cd6bbca61a4b827918fdad66e2bc9c5509 /Python/ceval.c
parentb0a6ede3d0bd6fa4ffe413ab4dfc1059201df25b (diff)
downloadcpython-70bed6f9936c811472b376edd93c37bcf8f06f35.tar.gz
cpython-70bed6f9936c811472b376edd93c37bcf8f06f35.zip
bpo-45107: Make LOAD_METHOD_CLASS safer and faster, clean up comments (GH-28177)
* Improve comments * Check cls is a type, remove dict calculation
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index bf95d50b629..ab692fd8ded 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4496,6 +4496,7 @@ check_eval_breaker:
}
TARGET(LOAD_METHOD_MODULE): {
+ /* LOAD_METHOD, for module methods */
assert(cframe.use_tracing == 0);
PyObject *owner = TOP();
PyObject *res;
@@ -4515,15 +4516,9 @@ check_eval_breaker:
_PyObjectCache *cache2 = &caches[-2].obj;
PyObject *cls = TOP();
- PyTypeObject *cls_type = Py_TYPE(cls);
- assert(cls_type->tp_dictoffset > 0);
- PyObject *dict = *(PyObject **) ((char *)cls + cls_type->tp_dictoffset);
- // Don't care if no dict -- tp_version_tag should catch anything wrong.
- DEOPT_IF(dict != NULL && ((PyDictObject *)dict)->ma_keys->dk_version !=
- cache1->dk_version_or_hint, LOAD_METHOD);
+ DEOPT_IF(!PyType_Check(cls), LOAD_METHOD);
DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != cache1->tp_version,
LOAD_METHOD);
- assert(cache1->dk_version_or_hint != 0);
assert(cache1->tp_version != 0);
STAT_INC(LOAD_METHOD, hit);