Skip to content

Commit cbee8d2

Browse files
committed
Fix uop execution stats
1 parent ba2331a commit cbee8d2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Include/internal/pycore_stats.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern "C" {
2828
#define GC_STAT_ADD(gen, name, n) do { if (_Py_stats) _Py_stats->gc_stats[(gen)].name += (n); } while (0)
2929
#define OPT_STAT_INC(name) do { if (_Py_stats) _Py_stats->optimization_stats.name++; } while (0)
3030
#define OPT_STAT_ADD(name, n) do { if (_Py_stats) _Py_stats->optimization_stats.name += (n); } while (0)
31-
#define UOP_STAT_INC(opname, name) do { if (_Py_stats) { assert(opname < 512); _Py_stats->optimization_stats.opcode[opname].name++; } } while (0)
31+
#define UOP_STAT_INC(opname, name) do { if (_Py_stats) { _Py_stats->optimization_stats.opcode[opname].name++; } } while (0)
3232
#define UOP_PAIR_INC(uopcode, lastuop) \
3333
do { \
3434
if (lastuop && _Py_stats) { \

Python/specialize.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "pycore_object.h"
1515
#include "pycore_opcode_metadata.h" // _PyOpcode_Caches
1616
#include "pycore_uop_metadata.h" // _PyOpcode_uop_name
17-
#include "pycore_uop_ids.h" // MAX_UOP_ID
17+
#include "pycore_uop_ids.h" // MAX_UOP_REGS_ID
1818
#include "pycore_opcode_utils.h" // RESUME_AT_FUNC_START
1919
#include "pycore_pylifecycle.h" // _PyOS_URandomNonblock()
2020
#include "pycore_runtime.h" // _Py_ID()
@@ -34,7 +34,7 @@ static PyStats _Py_stats_struct = { .gc_stats = _py_gc_stats };
3434
PyStats *_Py_stats = NULL;
3535

3636
#if PYSTATS_MAX_UOP_ID < MAX_UOP_REGS_ID
37-
#error "Not enough space allocated for pystats. Increase PYSTATS_MAX_UOP_ID to at least MAX_UOP_ID"
37+
#error "Not enough space allocated for pystats. Increase PYSTATS_MAX_UOP_ID to at least MAX_UOP_REGS_ID"
3838
#endif
3939

4040
#define ADD_STAT_TO_DICT(res, field) \
@@ -277,7 +277,7 @@ print_optimization_stats(FILE *out, OptimizationStats *stats)
277277
stats->optimizer_failure_reason_no_memory);
278278
fprintf(out, "Optimizer remove globals builtins changed: %" PRIu64 "\n", stats->remove_globals_builtins_changed);
279279
fprintf(out, "Optimizer remove globals incorrect keys: %" PRIu64 "\n", stats->remove_globals_incorrect_keys);
280-
for (int i = 0; i <= MAX_UOP_ID; i++) {
280+
for (int i = 0; i <= MAX_UOP_REGS_ID; i++) {
281281
if (stats->opcode[i].execution_count) {
282282
fprintf(out, "uops[%s].execution_count : %" PRIu64 "\n", _PyUOpName(i), stats->opcode[i].execution_count);
283283
}
@@ -296,15 +296,15 @@ print_optimization_stats(FILE *out, OptimizationStats *stats)
296296
}
297297
}
298298

299-
for (int i = 1; i <= MAX_UOP_ID; i++){
300-
for (int j = 1; j <= MAX_UOP_ID; j++) {
299+
for (int i = 1; i <= MAX_UOP_REGS_ID; i++){
300+
for (int j = 1; j <= MAX_UOP_REGS_ID; j++) {
301301
if (stats->opcode[i].pair_count[j]) {
302302
fprintf(out, "uop[%s].pair_count[%s] : %" PRIu64 "\n",
303303
_PyOpcode_uop_name[i], _PyOpcode_uop_name[j], stats->opcode[i].pair_count[j]);
304304
}
305305
}
306306
}
307-
for (int i = 0; i < MAX_UOP_ID; i++) {
307+
for (int i = 0; i < MAX_UOP_REGS_ID; i++) {
308308
if (stats->error_in_opcode[i]) {
309309
fprintf(
310310
out,

0 commit comments

Comments
 (0)