mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
GH-90230: Add stats to breakdown the origin of calls to PyEval_EvalFrame (GH-93284)
This commit is contained in:
parent
8995177030
commit
bbcf42449e
13 changed files with 63 additions and 11 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1677,6 +1677,7 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value)
|
|||
res = PyObject_CallOneArg(func, obj);
|
||||
}
|
||||
else {
|
||||
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, func);
|
||||
PyObject *args[] = { obj, value };
|
||||
res = PyObject_Vectorcall(func, args, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "pycore_pystate.h" // _PyThreadState_GET()
|
||||
#include "structmember.h" // PyMemberDef
|
||||
#include "opcode.h" // SEND
|
||||
#include "pystats.h"
|
||||
|
||||
static PyObject *gen_close(PyGenObject *, PyObject *);
|
||||
static PyObject *async_gen_asend_new(PyAsyncGenObject *, PyObject *);
|
||||
|
|
@ -218,6 +219,7 @@ gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult,
|
|||
}
|
||||
|
||||
gen->gi_frame_state = FRAME_EXECUTING;
|
||||
EVAL_CALL_STAT_INC(EVAL_CALL_GENERATOR);
|
||||
result = _PyEval_EvalFrame(tstate, frame, exc);
|
||||
if (gen->gi_frame_state == FRAME_EXECUTING) {
|
||||
gen->gi_frame_state = FRAME_COMPLETED;
|
||||
|
|
|
|||
|
|
@ -1653,6 +1653,7 @@ vectorcall_unbound(PyThreadState *tstate, int unbound, PyObject *func,
|
|||
args++;
|
||||
nargsf = nargsf - 1 + PY_VECTORCALL_ARGUMENTS_OFFSET;
|
||||
}
|
||||
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_SLOT, func);
|
||||
return _PyObject_VectorcallTstate(tstate, func, args, nargsf, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue