mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03: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
|
|
@ -103,6 +103,7 @@ _PyObject_CallNoArgsTstate(PyThreadState *tstate, PyObject *func) {
|
|||
// Private static inline function variant of public PyObject_CallNoArgs()
|
||||
static inline PyObject *
|
||||
_PyObject_CallNoArgs(PyObject *func) {
|
||||
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, func);
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL);
|
||||
}
|
||||
|
|
@ -111,6 +112,7 @@ _PyObject_CallNoArgs(PyObject *func) {
|
|||
static inline PyObject *
|
||||
_PyObject_FastCallTstate(PyThreadState *tstate, PyObject *func, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, func);
|
||||
return _PyObject_VectorcallTstate(tstate, func, args, (size_t)nargs, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ extern PyObject* _PyEval_BuiltinsFromGlobals(
|
|||
static inline PyObject*
|
||||
_PyEval_EvalFrame(PyThreadState *tstate, struct _PyInterpreterFrame *frame, int throwflag)
|
||||
{
|
||||
EVAL_CALL_STAT_INC(EVAL_CALL_TOTAL);
|
||||
if (tstate->interp->eval_frame == NULL) {
|
||||
return _PyEval_EvalFrameDefault(tstate, frame, throwflag);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,6 +265,9 @@ extern int _PyStaticCode_InternStrings(PyCodeObject *co);
|
|||
#define OBJECT_STAT_INC(name) _py_stats.object_stats.name++
|
||||
#define OBJECT_STAT_INC_COND(name, cond) \
|
||||
do { if (cond) _py_stats.object_stats.name++; } while (0)
|
||||
#define EVAL_CALL_STAT_INC(name) _py_stats.call_stats.eval_calls[name]++
|
||||
#define EVAL_CALL_STAT_INC_IF_FUNCTION(name, callable) \
|
||||
do { if (PyFunction_Check(callable)) _py_stats.call_stats.eval_calls[name]++; } while (0)
|
||||
|
||||
// Used by the _opcode extension which is built as a shared library
|
||||
PyAPI_FUNC(PyObject*) _Py_GetSpecializationStats(void);
|
||||
|
|
@ -276,6 +279,8 @@ PyAPI_FUNC(PyObject*) _Py_GetSpecializationStats(void);
|
|||
#define CALL_STAT_INC(name) ((void)0)
|
||||
#define OBJECT_STAT_INC(name) ((void)0)
|
||||
#define OBJECT_STAT_INC_COND(name, cond) ((void)0)
|
||||
#define EVAL_CALL_STAT_INC(name) ((void)0)
|
||||
#define EVAL_CALL_STAT_INC_IF_FUNCTION(name, callable) ((void)0)
|
||||
#endif // !Py_STATS
|
||||
|
||||
// Cache values are only valid in memory, so use native endianness.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue