10000 gh-81057: Move More Globals to _PyRuntimeState by ericsnowcurrently · Pull Request #100092 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-81057: Move More Globals to _PyRuntimeState #100092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Move memo_statistics to _PyRuntimeState.
  • Loading branch information
ericsnowcurrently committed Dec 7, 2022
commit bcbefb7a5b917ebc3610311c24654c8c1c5942bf
20 changes: 20 additions & 0 deletions Include/internal/pycore_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,31 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif


#include "pycore_pyarena.h" // PyArena


#ifdef Py_DEBUG
#define _PYPEGEN_NSTATISTICS 2000
#endif

struct _parser_runtime_state {
#ifdef Py_DEBUG
long memo_statistics[_PYPEGEN_NSTATISTICS];
#else
int _not_used;
#endif
};



extern struct _mod* _PyParser_ASTFromString(
const char *str,
PyObject* filename,
int mode,
PyCompilerFlags *flags,
PyArena *arena);

extern struct _mod* _PyParser_ASTFromFile(
FILE *fp,
PyObject *filename_ob,
Expand All @@ -25,6 +44,7 @@ extern struct _mod* _PyParser_ASTFromFile(
int *errcode,
PyArena *arena);


#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions Include/internal/pycore_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern "C" {
#include "pycore_global_objects.h" // struct _Py_global_objects
#include "pycore_import.h" // struct _import_runtime_state
#include "pycore_interp.h" // PyInterpreterState
#include "pycore_parser.h" // struct _parser_runtime_state
#include "pycore_pymem.h" // struct _pymem_allocators
#include "pycore_pyhash.h" // struct pyhash_runtime_state
#include "pycore_obmalloc.h" // struct obmalloc_state
Expand Down Expand Up @@ -131,6 +132,8 @@ typedef struct pyruntimestate {

PyWideStringList orig_argv;

struct _parser_runtime_state parser;

#define NEXITFUNCS 32
void (*exitfuncs[NEXITFUNCS])(void);
int nexitfuncs;
Expand Down
4 changes: 2 additions & 2 deletions Parser/pegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ _PyPegen_fill_token(Parser *p)
// The array counts the number of tokens skipped by memoization,
// indexed by type.

#define NSTATISTICS 2000
static long memo_statistics[NSTATISTICS];
#define NSTATISTICS _PYPEGEN_NSTATISTICS
#define memo_statistics _PyRuntime.parser.memo_statistics

void
_PyPegen_clear_memo_statistics()
Expand Down
9 changes: 0 additions & 9 deletions Tools/c-analyzer/cpython/ignored.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,6 @@ Python/pylifecycle.c - runtime_initialized -
Modules/syslogmodule.c - S_ident_o -
Modules/syslogmodule.c - S_log_open -

##-----------------------
## *not* tied to init/fini cycle

# These do not ge reset with each init/fini cycle.
# XXX These should probably be tied to init/fini. Move to _PyRuntimeState?

# special-use diagnistic state
Parser/pegen.c - memo_statistics -

##-----------------------
## one-off temporary state

Expand Down
0