Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f036a46

Browse files
GH-121583: Remove dependency from pystats.h to internal header file (GH-121587)
Co-authored-by: Peter Bierma <[email protected]>
1 parent 4e35dd6 commit f036a46

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Include/cpython/pystats.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
// Define _PY_INTERPRETER macro to increment interpreter_increfs and
2020
// interpreter_decrefs. Otherwise, increment increfs and decrefs.
2121

22-
#include "pycore_uop_ids.h"
23-
2422
#ifndef Py_CPYTHON_PYSTATS_H
2523
# error "this header file must not be included directly"
2624
#endif
2725

26+
#define PYSTATS_MAX_UOP_ID 512
27+
2828
#define SPECIALIZATION_FAILURE_KINDS 36
2929

3030
/* Stats for determining who is calling PyEval_EvalFrame */
@@ -100,7 +100,7 @@ typedef struct _gc_stats {
100100
typedef struct _uop_stats {
101101
uint64_t execution_count;
102102
uint64_t miss;
103-
uint64_t pair_count[MAX_UOP_ID + 1];
103+
uint64_t pair_count[PYSTATS_MAX_UOP_ID + 1];
104104
} UOpStats;
105105

106106
#define _Py_UOP_HIST_SIZE 32
@@ -118,7 +118,7 @@ typedef struct _optimization_stats {
118118
uint64_t recursive_call;
119119
uint64_t low_confidence;
120120
uint64_t executors_invalidated;
121-
UOpStats opcode[MAX_UOP_ID+1];
121+
UOpStats opcode[PYSTATS_MAX_UOP_ID + 1];
122122
uint64_t unsupported_opcode[256];
123123
uint64_t trace_length_hist[_Py_UOP_HIST_SIZE];
124124
uint64_t trace_run_length_hist[_Py_UOP_HIST_SIZE];
@@ -128,7 +128,7 @@ typedef struct _optimization_stats {
128128
uint64_t optimizer_failure_reason_no_memory;
129129
uint64_t remove_globals_builtins_changed;
130130
uint64_t remove_globals_incorrect_keys;
131-
uint64_t error_in_opcode[MAX_UOP_ID+1];
131+
uint64_t error_in_opcode[PYSTATS_MAX_UOP_ID + 1];
132132
} OptimizationStats;
133133

134134
typedef struct _rare_event_stats {

Python/specialize.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ GCStats _py_gc_stats[NUM_GENERATIONS] = { 0 };
2929
static PyStats _Py_stats_struct = { .gc_stats = _py_gc_stats };
3030
PyStats *_Py_stats = NULL;
3131

32+
#if PYSTATS_MAX_UOP_ID < MAX_UOP_ID
33+
#error "Not enough space allocated for pystats. Increase PYSTATS_MAX_UOP_ID to at least MAX_UOP_ID"
34+
#endif
35+
3236
#define ADD_STAT_TO_DICT(res, field) \
3337
do { \
3438
PyObject *val = PyLong_FromUnsignedLongLong(stats->field); \

0 commit comments

Comments
 (0)