mirror of
https://github.com/python/cpython.git
synced 2025-09-01 22:47:59 +00:00
bpo-44525: Specialize for calls to type and other builtin classes with 1 argument. (GH-29942)
This commit is contained in:
parent
f025ae63dc
commit
3a60bfef49
6 changed files with 105 additions and 40 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue