From c4dbfb5bb8948ed640e973d8cd5c07633a3d35ce Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Wed, 14 Dec 2022 11:02:20 -0700 Subject: [PATCH 1/4] Move the interned dict from _PyRuntime.global_objects to _PyRuntime.cached_objects. --- Include/internal/pycore_global_objects.h | 4 ++-- Objects/unicodeobject.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Include/internal/pycore_global_objects.h b/Include/internal/pycore_global_objects.h index 80f6bb2c8a7c16..1378bacc161aeb 100644 --- a/Include/internal/pycore_global_objects.h +++ b/Include/internal/pycore_global_objects.h @@ -28,6 +28,8 @@ extern "C" { struct _Py_cached_objects { PyObject *str_replace_inf; + + PyObject *interned; }; #define _Py_GLOBAL_OBJECT(NAME) \ @@ -59,8 +61,6 @@ struct _Py_global_objects { PyHamtNode_Bitmap hamt_bitmap_node_empty; _PyContextTokenMissing context_token_missing; } singletons; - - PyObject *interned; }; #define _Py_INTERP_CACHED_OBJECT(interp, NAME) \ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index b721ccd805edf1..40452f97f798d4 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -233,12 +233,12 @@ static inline PyObject* unicode_new_empty(void) */ static inline PyObject *get_interned_dict(void) { - return _PyRuntime.global_objects.interned; + return _PyRuntime.cached_objects.interned; } static inline void set_interned_dict(PyObject *dict) { - _PyRuntime.global_objects.interned = dict; + _PyRuntime.cached_objects.interned = dict; } #define _Py_RETURN_UNICODE_EMPTY() \ From fb890fe295df9f34890ab9ebc51470fe3cd67e33 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Wed, 14 Dec 2022 11:09:43 -0700 Subject: [PATCH 2/4] Use _Py_CACHED_OBJECT() for the interned strings. --- Objects/unicodeobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 40452f97f798d4..bf13d56ff62697 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -233,12 +233,12 @@ static inline PyObject* unicode_new_empty(void) */ static inline PyObject *get_interned_dict(void) { - return _PyRuntime.cached_objects.interned; + return _Py_CACHED_OBJECT(interned); } static inline void set_interned_dict(PyObject *dict) { - _PyRuntime.cached_objects.interned = dict; + _Py_CACHED_OBJECT(interned) = dict; } #define _Py_RETURN_UNICODE_EMPTY() \ From 3d428fde8546134d76fd6a44e8eb1841dfa80da1 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Wed, 14 Dec 2022 11:10:39 -0700 Subject: [PATCH 3/4] interned -> interned_strings --- Include/internal/pycore_global_objects.h | 2 +- Objects/unicodeobject.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Include/internal/pycore_global_objects.h b/Include/internal/pycore_global_objects.h index 1378bacc161aeb..a1c493d6432436 100644 --- a/Include/internal/pycore_global_objects.h +++ b/Include/internal/pycore_global_objects.h @@ -29,7 +29,7 @@ extern "C" { struct _Py_cached_objects { PyObject *str_replace_inf; - PyObject *interned; + PyObject *interned_strings; }; #define _Py_GLOBAL_OBJECT(NAME) \ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index bf13d56ff62697..f0c7aa7707fdb5 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -233,12 +233,12 @@ static inline PyObject* unicode_new_empty(void) */ static inline PyObject *get_interned_dict(void) { - return _Py_CACHED_OBJECT(interned); + return _Py_CACHED_OBJECT(interned_strings); } static inline void set_interned_dict(PyObject *dict) { - _Py_CACHED_OBJECT(interned) = dict; + _Py_CACHED_OBJECT(interned_strings) = dict; } #define _Py_RETURN_UNICODE_EMPTY() \ From db8ddb581c4f0f4386cd7a0bd8b2e42b2a97c6d0 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Wed, 14 Dec 2022 11:14:38 -0700 Subject: [PATCH 4/4] global_objects -> static_objects --- Include/internal/pycore_global_objects.h | 4 ++-- Include/internal/pycore_runtime.h | 2 +- Include/internal/pycore_runtime_init.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Include/internal/pycore_global_objects.h b/Include/internal/pycore_global_objects.h index a1c493d6432436..d0461fa7e82e8b 100644 --- a/Include/internal/pycore_global_objects.h +++ b/Include/internal/pycore_global_objects.h @@ -33,11 +33,11 @@ struct _Py_cached_objects { }; #define _Py_GLOBAL_OBJECT(NAME) \ - _PyRuntime.global_objects.NAME + _PyRuntime.static_objects.NAME #define _Py_SINGLETON(NAME) \ _Py_GLOBAL_OBJECT(singletons.NAME) -struct _Py_global_objects { +struct _Py_static_objects { struct { /* Small integers are preallocated in this array so that they * can be shared. diff --git a/Include/internal/pycore_runtime.h b/Include/internal/pycore_runtime.h index 92ed45956c99b3..d100e836c7d153 100644 --- a/Include/internal/pycore_runtime.h +++ b/Include/internal/pycore_runtime.h @@ -163,7 +163,7 @@ typedef struct pyruntimestate { /* All the objects that are shared by the runtime's interpreters. */ struct _Py_cached_objects cached_objects; - struct _Py_global_objects global_objects; + struct _Py_static_objects static_objects; /* The following fields are here to avoid allocation during init. The data is exposed through _PyRuntimeState pointer fields. diff --git a/Include/internal/pycore_runtime_init.h b/Include/internal/pycore_runtime_init.h index 1431096e2d24ba..6342a28f4df911 100644 --- a/Include/internal/pycore_runtime_init.h +++ b/Include/internal/pycore_runtime_init.h @@ -70,7 +70,7 @@ extern "C" { .types = { \ .next_version_tag = 1, \ }, \ - .global_objects = { \ + .static_objects = { \ .singletons = { \ .small_ints = _Py_small_ints_INIT, \ .bytes_empty = _PyBytes_SIMPLE_INIT(0, 0), \