@@ -48,12 +48,22 @@ struct _Py_long_state {
48
48
*/
49
49
struct _is {
50
50
51
- struct _ceval_state ceval ;
52
51
PyInterpreterState * next ;
53
52
53
+ int64_t id ;
54
+ int64_t id_refcount ;
55
+ int requires_idref ;
56
+ PyThread_type_lock id_mutex ;
57
+
58
+ /* Has been initialized to a safe state.
59
+
60
+ In order to be effective, this must be set to 0 during or right
61
+ after allocation. */
62
+ int _initialized ;
63
+ int finalizing ;
64
+
54
65
uint64_t monitoring_version ;
55
66
uint64_t last_restart_version ;
56
-
57
67
struct pythreads {
58
68
uint64_t next_unique_id ;
59
69
/* The linked list of threads, newest first. */
@@ -72,36 +82,40 @@ struct _is {
72
82
Get runtime from tstate: tstate->interp->runtime. */
73
83
struct pyruntimestate * runtime ;
74
84
75
- int64_t id ;
76
- int64_t id_refcount ;
77
- int requires_idref ;
78
- PyThread_type_lock id_mutex ;
79
-
80
- /* Has been initialized to a safe state.
81
-
82
- In order to be effective, this must be set to 0 during or right
83
- after allocation. */
84
- int _initialized ;
85
- int finalizing ;
86
-
87
85
/* Set by Py_EndInterpreter().
88
86
89
87
Use _PyInterpreterState_GetFinalizing()
90
88
and _PyInterpreterState_SetFinalizing()
91
89
to access it, don't access it directly. */
92
90
_Py_atomic_address _finalizing ;
93
91
94
- struct _obmalloc_state obmalloc ;
95
-
96
92
struct _gc_runtime_state gc ;
97
93
98
- struct _import_state imports ;
94
+ /* The following fields are here to avoid allocation during init.
95
+ The data is exposed through PyInterpreterState pointer fields.
96
+ These fields should not be accessed directly outside of init.
97
+
98
+ All other PyInterpreterState pointer fields are populated when
99
+ needed and default to NULL.
100
+
101
+ For now there are some exceptions to that rule, which require
102
+ allocation during init. These will be addressed on a case-by-case
103
+ basis. Also see _PyRuntimeState regarding the various mutex fields.
104
+ */
105
+
106
+ /* The per-interpreter GIL, which might not be used. */
107
+ struct _gil_runtime_state _gil ;
99
108
100
109
// Dictionary of the sys module
101
110
PyObject * sysdict ;
102
111
// Dictionary of the builtins module
103
112
PyObject * builtins ;
104
113
114
+ /* ---------- IMPORTANT ---------------------------
115
+ The fields above this line are declared as early as
116
+ possible to facilitate out-of-process observability
117
+ tools. */
118
+
105
119
PyObject * codec_search_path ;
106
120
PyObject * codec_search_cache ;
107
121
PyObject * codec_error_registry ;
@@ -133,6 +147,12 @@ struct _is {
133
147
struct _warnings_runtime_state warnings ;
134
148
struct atexit_state atexit ;
135
149
150
+ struct _ceval_state ceval ;
151
+
152
+ struct _obmalloc_state obmalloc ;
153
+
154
+ struct _import_state imports ;
155
+
136
156
PyObject * audit_hooks ;
137
157
PyType_WatchCallback type_watchers [TYPE_MAX_WATCHERS ];
138
158
PyCode_WatchCallback code_watchers [CODE_MAX_WATCHERS ];
@@ -175,22 +195,7 @@ struct _is {
175
195
struct _Py_interp_cached_objects cached_objects ;
176
196
struct _Py_interp_static_objects static_objects ;
177
197
178
- /* The following fields are here to avoid allocation during init.
179
- The data is exposed through PyInterpreterState pointer fields.
180
- These fields should not be accessed directly outside of init.
181
-
182
- All other PyInterpreterState pointer fields are populated when
183
- needed and default to NULL.
184
-
185
- For now there are some exceptions to that rule, which require
186
- allocation during init. These will be addressed on a case-by-case
187
- basis. Also see _PyRuntimeState regarding the various mutex fields.
188
- */
189
-
190
- /* The per-interpreter GIL, which might not be used. */
191
- struct _gil_runtime_state _gil ;
192
-
193
- /* the initial PyInterpreterState.threads.head */
198
+ /* the initial PyInterpreterState.threads.head */
194
199
PyThreadState _initial_thread ;
195
200
};
196
201
0 commit comments