diff options
author | Mark Shannon <mark@hotpy.org> | 2021-12-15 15:03:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-15 15:03:42 (GMT) |
commit | 3a60bfef49b3324660a615a8e6d10710e5f669d9 (patch) | |
tree | c0b4dec8daf9f020a68be673c169d88faded0e6a /Python/ceval.c | |
parent | f025ae63dccf96c4a1d781a6438bd9ed1502f0a1 (diff) | |
download | cpython-3a60bfef49b3324660a615a8e6d10710e5f669d9.zip cpython-3a60bfef49b3324660a615a8e6d10710e5f669d9.tar.gz cpython-3a60bfef49b3324660a615a8e6d10710e5f669d9.tar.bz2 |
bpo-44525: Specialize for calls to type and other builtin classes with 1 argument. (GH-29942)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 7932433..b9444b2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4854,6 +4854,41 @@ check_eval_breaker: goto start_frame; } + TARGET(CALL_NO_KW_TYPE_1) { + assert(STACK_ADJUST_IS_RESET); + assert(GET_CACHE()->adaptive.original_oparg == 1); + PyObject *obj = TOP(); + PyObject *callable = SECOND(); + DEOPT_IF(callable != (PyObject *)&PyType_Type, CALL_NO_KW); + PyObject *res = Py_NewRef(Py_TYPE(obj)); + STACK_SHRINK(1); + Py_DECREF(callable); + Py_DECREF(obj); + SET_TOP(res); + DISPATCH(); + } + + TARGET(CALL_NO_KW_BUILTIN_CLASS_1) { + assert(STACK_ADJUST_IS_RESET); + SpecializedCacheEntry *caches = GET_CACHE(); + _PyAdaptiveEntry *cache0 = &caches[0].adaptive; + assert(cache0->original_oparg == 1); + PyObject *callable = SECOND(); + PyObject *arg = TOP(); + DEOPT_IF(!PyType_Check(callable), CALL_NO_KW); + PyTypeObject *tp = (PyTypeObject *)callable; + DEOPT_IF(tp->tp_version_tag != cache0->version, CALL_NO_KW); + STACK_SHRINK(1); + PyObject *res = tp->tp_vectorcall((PyObject *)tp, stack_pointer, 1, NULL); + SET_TOP(res); + Py_DECREF(tp); + Py_DECREF(arg); + if (res == NULL) { + goto error; + } + DISPATCH(); + } + TARGET(CALL_NO_KW_BUILTIN_O) { assert(cframe.use_tracing == 0); assert(STACK_ADJUST_IS_RESET); |