Skip to content

Commit 1a6411f

Browse files
authored
Gather stats for PRECALL_METHOD. (GH-31259)
1 parent e19059e commit 1a6411f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Diff for: Python/ceval.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -4451,8 +4451,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
44514451
assert(call_shape.kwnames == NULL);
44524452
#ifdef Py_STATS
44534453
extern int _PySpecialization_ClassifyCallable(PyObject *);
4454-
_py_stats.opcode_stats[PRECALL_FUNCTION].specialization.failure++;
4455-
_py_stats.opcode_stats[PRECALL_FUNCTION].specialization.failure_kinds[_PySpecialization_ClassifyCallable(call_shape.callable)]++;
4454+
SpecializationStats *stats =
4455+
&_py_stats.opcode_stats[PRECALL_FUNCTION].specialization;
4456+
stats->failure++;
4457+
int kind = _PySpecialization_ClassifyCallable(call_shape.callable);
4458+
stats->failure_kinds[kind]++;
44564459
#endif
44574460
DISPATCH();
44584461
}
@@ -4493,6 +4496,14 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
44934496

44944497
call_shape.total_args = nargs;
44954498
assert(call_shape.kwnames == NULL);
4499+
#ifdef Py_STATS
4500+
extern int _PySpecialization_ClassifyCallable(PyObject *);
4501+
SpecializationStats *stats =
4502+
&_py_stats.opcode_stats[PRECALL_METHOD].specialization;
4503+
stats->failure++;
4504+
int kind = _PySpecialization_ClassifyCallable(call_shape.callable);
4505+
stats->failure_kinds[kind]++;
4506+
#endif
44964507
DISPATCH();
44974508
}
44984509

Diff for: Python/specialize.c

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ print_spec_stats(FILE *out, OpcodeStats *stats)
176176
* even though we don't specialize them yet. */
177177
fprintf(out, " opcode[%d].specializable : 1\n", FOR_ITER);
178178
fprintf(out, " opcode[%d].specializable : 1\n", PRECALL_FUNCTION);
179+
fprintf(out, " opcode[%d].specializable : 1\n", PRECALL_METHOD);
179180
fprintf(out, " opcode[%d].specializable : 1\n", UNPACK_SEQUENCE);
180181
for (int i = 0; i < 256; i++) {
181182
if (adaptive_opcodes[i]) {

0 commit comments

Comments
 (0)