Skip to content

Commit bcbefb7

Browse files
Move memo_statistics to _PyRuntimeState.
1 parent cca8253 commit bcbefb7

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

Include/internal/pycore_parser.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,31 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11+
12+
#include "pycore_pyarena.h" // PyArena
13+
14+
15+
#ifdef Py_DEBUG
16+
#define _PYPEGEN_NSTATISTICS 2000
17+
#endif
18+
19+
struct _parser_runtime_state {
20+
#ifdef Py_DEBUG
21+
long memo_statistics[_PYPEGEN_NSTATISTICS];
22+
#else
23+
int _not_used;
24+
#endif
25+
};
26+
27+
28+
1129
extern struct _mod* _PyParser_ASTFromString(
1230
const char *str,
1331
PyObject* filename,
1432
int mode,
1533
PyCompilerFlags *flags,
1634
PyArena *arena);
35+
1736
extern struct _mod* _PyParser_ASTFromFile(
1837
FILE *fp,
1938
PyObject *filename_ob,
@@ -25,6 +44,7 @@ extern struct _mod* _PyParser_ASTFromFile(
2544
int *errcode,
2645
PyArena *arena);
2746

47+
2848
#ifdef __cplusplus
2949
}
3050
#endif

Include/internal/pycore_runtime.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extern "C" {
1717
#include "pycore_global_objects.h" // struct _Py_global_objects
1818
#include "pycore_import.h" // struct _import_runtime_state
1919
#include "pycore_interp.h" // PyInterpreterState
20+
#include "pycore_parser.h" // struct _parser_runtime_state
2021
#include "pycore_pymem.h" // struct _pymem_allocators
2122
#include "pycore_pyhash.h" // struct pyhash_runtime_state
2223
#include "pycore_obmalloc.h" // struct obmalloc_state
@@ -131,6 +132,8 @@ typedef struct pyruntimestate {
131132

132133
PyWideStringList orig_argv;
133134

135+
struct _parser_runtime_state parser;
136+
134137
#define NEXITFUNCS 32
135138
void (*exitfuncs[NEXITFUNCS])(void);
136139
int nexitfuncs;

Parser/pegen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ _PyPegen_fill_token(Parser *p)
246246
// The array counts the number of tokens skipped by memoization,
247247
// indexed by type.
248248

249-
#define NSTATISTICS 2000
250-
static long memo_statistics[NSTATISTICS];
249+
#define NSTATISTICS _PYPEGEN_NSTATISTICS
250+
#define memo_statistics _PyRuntime.parser.memo_statistics
251251

252252
void
253253
_PyPegen_clear_memo_statistics()

Tools/c-analyzer/cpython/ignored.tsv

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,6 @@ Python/pylifecycle.c - runtime_initialized -
141141
Modules/syslogmodule.c - S_ident_o -
142142
Modules/syslogmodule.c - S_log_open -
143143

144-
##-----------------------
145-
## *not* tied to init/fini cycle
146-
147-
# These do not ge reset with each init/fini cycle.
148-
# XXX These should probably be tied to init/fini. Move to _PyRuntimeState?
149-
150-
# special-use diagnistic state
151-
Parser/pegen.c - memo_statistics -
152-
153144
##-----------------------
154145
## one-off temporary state
155146

0 commit comments

Comments
 (0)