summaryrefslogtreecommitdiffstats
path: root/Objects/call.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-05-27 15:31:41 (GMT)
committerGitHub <noreply@github.com>2022-05-27 15:31:41 (GMT)
commitbbcf42449e13c0b62f145cd49d12674ef3d5bf64 (patch)
tree68d3a84f78de47229c46df66eafd4c27474379a7 /Objects/call.c
parent8995177030c8b41885ad92b260279b7e622ecaea (diff)
downloadcpython-bbcf42449e13c0b62f145cd49d12674ef3d5bf64.zip
cpython-bbcf42449e13c0b62f145cd49d12674ef3d5bf64.tar.gz
cpython-bbcf42449e13c0b62f145cd49d12674ef3d5bf64.tar.bz2
GH-90230: Add stats to breakdown the origin of calls to `PyEval_EvalFrame` (GH-93284)
Diffstat (limited to 'Objects/call.c')
-rw-r--r--Objects/call.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/Objects/call.c b/Objects/call.c
index 678d162..3b5259b 100644
--- a/Objects/call.c
+++ b/Objects/call.c
@@ -109,7 +109,9 @@ _Py_CheckSlotResult(PyObject *obj, const char *slot_name, int success)
PyObject *
PyObject_CallNoArgs(PyObject *func)
{
- return _PyObject_CallNoArgs(func);
+ EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, func);
+ PyThreadState *tstate = _PyThreadState_GET();
+ return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL);
}
@@ -322,7 +324,7 @@ _PyObject_Call(PyThreadState *tstate, PyObject *callable,
assert(!_PyErr_Occurred(tstate));
assert(PyTuple_Check(args));
assert(kwargs == NULL || PyDict_Check(kwargs));
-
+ EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, callable);
vectorcallfunc vector_func = _PyVectorcall_Function(callable);
if (vector_func != NULL) {
return _PyVectorcall_Call(tstate, vector_func, callable, args, kwargs);
@@ -367,6 +369,7 @@ PyCFunction_Call(PyObject *callable, PyObject *args, PyObject *kwargs)
PyObject *
PyObject_CallOneArg(PyObject *func, PyObject *arg)
{
+ EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, func);
assert(arg != NULL);
PyObject *_args[2];
PyObject **args = _args + 1; // For PY_VECTORCALL_ARGUMENTS_OFFSET
@@ -389,6 +392,7 @@ _PyFunction_Vectorcall(PyObject *func, PyObject* const* stack,
assert(nargs >= 0);
PyThreadState *tstate = _PyThreadState_GET();
assert(nargs == 0 || stack != NULL);
+ EVAL_CALL_STAT_INC(EVAL_CALL_FUNCTION_VECTORCALL);
if (((PyCodeObject *)f->func_code)->co_flags & CO_OPTIMIZED) {
return _PyEval_Vector(tstate, f, NULL, stack, nargs, kwnames);
}
@@ -520,7 +524,7 @@ _PyObject_CallFunctionVa(PyThreadState *tstate, PyObject *callable,
if (stack == NULL) {
return NULL;
}
-
+ EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, callable);
if (nargs == 1 && PyTuple_Check(stack[0])) {
/* Special cases for backward compatibility:
- PyObject_CallFunction(func, "O", tuple) calls func(*tuple)
@@ -815,6 +819,11 @@ object_vacall(PyThreadState *tstate, PyObject *base,
stack[i] = va_arg(vargs, PyObject *);
}
+#ifdef Py_STATS
+ if (PyFunction_Check(callable)) {
+ EVAL_CALL_STAT_INC(EVAL_CALL_API);
+ }
+#endif
/* Call the function */
result = _PyObject_VectorcallTstate(tstate, callable, stack, nargs, NULL);
@@ -852,6 +861,7 @@ PyObject_VectorcallMethod(PyObject *name, PyObject *const *args,
args++;
nargsf--;
}
+ EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_METHOD, callable);
PyObject *result = _PyObject_VectorcallTstate(tstate, callable,
args, nargsf, kwnames);
Py_DECREF(callable);