Skip to content

Commit 0c89654

Browse files
committed
Merge branch 'main' into jit_float_truediv
2 parents b432e1a + 6349262 commit 0c89654

File tree

90 files changed

+3017
-1763
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+3017
-1763
lines changed

Doc/c-api/interp-lifecycle.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,11 @@ Initializing and finalizing the interpreter
410410
(zero) if not. After :c:func:`Py_FinalizeEx` is called, this returns false until
411411
:c:func:`Py_Initialize` is called again.
412412
413+
.. versionchanged:: next
414+
This function no longer returns true until initialization has fully
415+
completed, including import of the :mod:`site` module. Previously it
416+
could return true while :c:func:`Py_Initialize` was still running.
417+
413418
414419
.. c:function:: int Py_IsFinalizing()
415420

Doc/library/functions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ are always available. They are listed here in alphabetical order.
644644
If the given source is a string, then leading and trailing spaces and tabs
645645
are stripped.
646646

647-
See :func:`ast.literal_eval` for a function that can safely evaluate strings
647+
See :func:`ast.literal_eval` for a function to evaluate strings
648648
with expressions containing only literals.
649649

650650
.. audit-event:: exec code_object eval

Doc/library/multiprocessing.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,8 @@ For an example of the usage of queues for interprocess communication see
932932
standard library's :mod:`queue` module are raised to signal timeouts.
933933

934934
:class:`Queue` implements all the methods of :class:`queue.Queue` except for
935-
:meth:`~queue.Queue.task_done` and :meth:`~queue.Queue.join`.
935+
:meth:`~queue.Queue.task_done`, :meth:`~queue.Queue.join`, and
936+
:meth:`~queue.Queue.shutdown`.
936937

937938
.. method:: qsize()
938939

Include/internal/pycore_dict.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ _PyDict_NotifyEvent(PyDict_WatchEvent event,
292292
PyObject *value)
293293
{
294294
assert(Py_REFCNT((PyObject*)mp) > 0);
295-
int watcher_bits = mp->_ma_watcher_tag & DICT_WATCHER_MASK;
295+
int watcher_bits = FT_ATOMIC_LOAD_UINT64_RELAXED(mp->_ma_watcher_tag) & DICT_WATCHER_MASK;
296296
if (watcher_bits) {
297297
RARE_EVENT_STAT_INC(watched_dict_modification);
298298
_PyDict_SendEvent(watcher_bits, event, mp, key, value);
@@ -368,7 +368,7 @@ PyDictObject *_PyObject_MaterializeManagedDict_LockHeld(PyObject *);
368368
static inline Py_ssize_t
369369
_PyDict_UniqueId(PyDictObject *mp)
370370
{
371-
return (Py_ssize_t)(mp->_ma_watcher_tag >> DICT_UNIQUE_ID_SHIFT);
371+
return (Py_ssize_t)(FT_ATOMIC_LOAD_UINT64_RELAXED(mp->_ma_watcher_tag) >> DICT_UNIQUE_ID_SHIFT);
372372
}
373373

374374
static inline void

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_optimizer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,6 @@ extern PyCodeObject *_Py_uop_sym_get_probable_func_code(JitOptRef sym);
424424
extern PyObject *_Py_uop_sym_get_probable_value(JitOptRef sym);
425425
extern PyTypeObject *_Py_uop_sym_get_probable_type(JitOptRef sym);
426426
extern JitOptRef *_Py_uop_sym_set_stack_depth(JitOptContext *ctx, int stack_depth, JitOptRef *current_sp);
427-
extern uint32_t _Py_uop_sym_get_func_version(JitOptRef ref);
428-
bool _Py_uop_sym_set_func_version(JitOptContext *ctx, JitOptRef ref, uint32_t version);
429427

430428
extern void _Py_uop_abstractcontext_init(JitOptContext *ctx, _PyBloomFilter *dependencies);
431429
extern void _Py_uop_abstractcontext_fini(JitOptContext *ctx);

Include/internal/pycore_optimizer_types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ typedef enum _JitSymType {
3636
JIT_SYM_NON_NULL_TAG = 3,
3737
JIT_SYM_BOTTOM_TAG = 4,
3838
JIT_SYM_TYPE_VERSION_TAG = 5,
39-
JIT_SYM_FUNC_VERSION_TAG = 6,
4039
JIT_SYM_KNOWN_CLASS_TAG = 7,
4140
JIT_SYM_KNOWN_VALUE_TAG = 8,
4241
JIT_SYM_TUPLE_TAG = 9,

Include/internal/pycore_pyatomic_ft_wrappers.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ extern "C" {
4949
_Py_atomic_load_uint16_relaxed(&value)
5050
#define FT_ATOMIC_LOAD_UINT32_RELAXED(value) \
5151
_Py_atomic_load_uint32_relaxed(&value)
52+
#define FT_ATOMIC_LOAD_UINT64_RELAXED(value) \
53+
_Py_atomic_load_uint64_relaxed(&value)
5254
#define FT_ATOMIC_LOAD_ULONG_RELAXED(value) \
5355
_Py_atomic_load_ulong_relaxed(&value)
5456
#define FT_ATOMIC_STORE_PTR_RELAXED(value, new_value) \
@@ -71,6 +73,12 @@ extern "C" {
7173
_Py_atomic_store_uint16_relaxed(&value, new_value)
7274
#define FT_ATOMIC_STORE_UINT32_RELAXED(value, new_value) \
7375
_Py_atomic_store_uint32_relaxed(&value, new_value)
76+
#define FT_ATOMIC_AND_UINT64(value, new_value) \
77+
(void)_Py_atomic_and_uint64(&value, new_value)
78+
#define FT_ATOMIC_OR_UINT64(value, new_value) \
79+
(void)_Py_atomic_or_uint64(&value, new_value)
80+
#define FT_ATOMIC_ADD_UINT64(value, new_value) \
81+
(void)_Py_atomic_add_uint64(&value, new_value)
7482
#define FT_ATOMIC_STORE_CHAR_RELAXED(value, new_value) \
7583
_Py_atomic_store_char_relaxed(&value, new_value)
7684
#define FT_ATOMIC_LOAD_CHAR_RELAXED(value) \
@@ -146,6 +154,7 @@ extern "C" {
146154
#define FT_ATOMIC_LOAD_UINT8_RELAXED(value) value
147155
#define FT_ATOMIC_LOAD_UINT16_RELAXED(value) value
148156
#define FT_ATOMIC_LOAD_UINT32_RELAXED(value) value
157+
#define FT_ATOMIC_LOAD_UINT64_RELAXED(value) value
149158
#define FT_ATOMIC_LOAD_ULONG_RELAXED(value) value
150159
#define FT_ATOMIC_STORE_PTR_RELAXED(value, new_value) value = new_value
151160
#define FT_ATOMIC_STORE_PTR_RELEASE(value, new_value) value = new_value
@@ -157,6 +166,9 @@ extern "C" {
157166
#define FT_ATOMIC_STORE_UINT8_RELAXED(value, new_value) value = new_value
158167
#define FT_ATOMIC_STORE_UINT16_RELAXED(value, new_value) value = new_value
159168
#define FT_ATOMIC_STORE_UINT32_RELAXED(value, new_value) value = new_value
169+
#define FT_ATOMIC_AND_UINT64(value, new_value) (void)(value &= new_value)
170+
#define FT_ATOMIC_OR_UINT64(value, new_value) (void)(value |= new_value)
171+
#define FT_ATOMIC_ADD_UINT64(value, new_value) (void)(value += new_value)
160172
#define FT_ATOMIC_LOAD_CHAR_RELAXED(value) value
161173
#define FT_ATOMIC_STORE_CHAR_RELAXED(value, new_value) value = new_value
162174
#define FT_ATOMIC_LOAD_UCHAR_RELAXED(value) value

Include/internal/pycore_runtime.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,29 @@ _PyRuntimeState_SetFinalizing(_PyRuntimeState *runtime, PyThreadState *tstate) {
5656
}
5757
}
5858

59+
// Atomic so a thread that reads initialized=1 observes all writes
60+
// from the initialization sequence (gh-146302).
61+
62+
static inline int
63+
_PyRuntimeState_GetCoreInitialized(_PyRuntimeState *runtime) {
64+
return _Py_atomic_load_int(&runtime->core_initialized);
65+
}
66+
67+
static inline void
68+
_PyRuntimeState_SetCoreInitialized(_PyRuntimeState *runtime, int initialized) {
69+
_Py_atomic_store_int(&runtime->core_initialized, initialized);
70+
}
71+
72+
static inline int
73+
_PyRuntimeState_GetInitialized(_PyRuntimeState *runtime) {
74+
return _Py_atomic_load_int(&runtime->initialized);
75+
}
76+
77+
static inline void
78+
_PyRuntimeState_SetInitialized(_PyRuntimeState *runtime, int initialized) {
79+
_Py_atomic_store_int(&runtime->initialized, initialized);
80+
}
81+
5982

6083
#ifdef __cplusplus
6184
}

Include/internal/pycore_runtime_structs.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,18 @@ struct pyruntimestate {
158158
/* Is Python preinitialized? Set to 1 by Py_PreInitialize() */
159159
int preinitialized;
160160

161-
/* Is Python core initialized? Set to 1 by _Py_InitializeCore() */
161+
/* Is Python core initialized? Set to 1 by _Py_InitializeCore().
162+
163+
Use _PyRuntimeState_GetCoreInitialized() and
164+
_PyRuntimeState_SetCoreInitialized() to access it,
165+
don't access it directly. */
162166
int core_initialized;
163167

164-
/* Is Python fully initialized? Set to 1 by Py_Initialize() */
168+
/* Is Python fully initialized? Set to 1 by Py_Initialize().
169+
170+
Use _PyRuntimeState_GetInitialized() and
171+
_PyRuntimeState_SetInitialized() to access it,
172+
don't access it directly. */
165173
int initialized;
166174

167175
/* Set by Py_FinalizeEx(). Only reset to NULL if Py_Initialize()

0 commit comments

Comments
 (0)