Sam Gross
3d4ac1a2c2
gh-123358: Use _PyStackRef
in LOAD_DEREF
(gh-130064)
...
Concurrent accesses from multiple threads to the same `cell` object did not
scale well in the free-threaded build. Use `_PyStackRef` and optimistically
avoid locking to improve scaling.
With the locks around cell reads gone, some of the free threading tests were
prone to starvation: the readers were able to run in a tight loop and the
writer threads weren't scheduled frequently enough to make timely progress.
Adjust the tests to avoid this.
Co-authored-by: Donghee Na <donghee.na@python.org>
2025-03-26 12:08:20 -04:00
Mark Shannon
1b8bb1ed0c
GH-131729: Code-gen better liveness analysis (GH-131732)
...
* Rename 'defined' attribute to 'in_local' to more accurately reflect how it is used
* Make death of variables explicit even for array variables.
* Convert in_memory from boolean to stack offset
* Don't apply liveness analysis to optimizer generated code
* Fix RETURN_VALUE in optimizer
2025-03-26 15:21:35 +00:00
Jelle Zijlstra
898e6b395e
gh-130881: Handle conditionally defined annotations ( #130935 )
2025-03-26 03:48:19 +00:00
Victor Stinner
5fef4ff9ed
gh-111178: Fix function signature in pyexpat.c ( #131674 )
...
Move _Py_NO_SANITIZE_UNDEFINED macro from faulthandler.c to pyport.h.
2025-03-24 17:22:45 +00:00
Sam Gross
da6730caa5
gh-128421: Avoid TSAN warnings in sys._current_frames()
(gh-131548)
...
This tells TSAN not to sanitize `PyUnstable_InterpreterFrame_GetLine()`.
There's a possible data race on the access to the frame's `instr_ptr`
if the frame is currently executing. We don't really care about the
race. In theory, we could use relaxed atomics for every access to
`instr_ptr`, but that would create more code churn and current compilers
are overly conservative with optimizations around relaxed atomic
accesses.
We also don't sanitize `_PyFrame_IsIncomplete()` because it accesses
`instr_ptr` and is called from assertions within PyFrame_GetCode().
2025-03-24 09:49:39 -04:00
Petr Viktorin
0e53038ea8
gh-128715: Expose ctypes.CField, with info attributes (GH-128950)
...
- Restore max field size to sys.maxsize, as in Python 3.13 & below
- PyCField: Split out bit/byte sizes/offsets.
- Expose CField's size/offset data to Python code
- Add generic checks for all the test structs/unions, using the newly exposed attrs
2025-03-24 14:18:34 +01:00
Dino Viehland
d9411ae3c2
gh-130312: SET_ADD should not lock ( #130136 )
...
SET_ADD should not lock
2025-03-21 15:58:32 -07:00
Victor Stinner
7101cba6bf
gh-131238: Move _Py_VISIT_STACKREF() to pycore_stackref.h ( #131560 )
...
* Move _Py_VISIT_STACKREF() from pycore_gc.h to pycore_stackref.h.
* Remove pycore_interpframe.h include from pycore_genobject.h.
* Remove now useless includes from C files.
* Add pycore_interpframe_structs.h to Makefile.pre.in and
pythoncore.vcxproj.
2025-03-21 23:24:14 +01:00
Savannah Ostrowski
b92ee14b80
GH-130415: Optimize constant comparison in JIT builds (GH-131489)
2025-03-21 11:23:12 -07:00
Victor Stinner
61317074d4
gh-131238: Add pycore_interpframe_structs.h header ( #131553 )
...
Add an explicit include to pycore_interpframe_structs.h in
pycore_runtime_structs.h to fix a dependency cycle.
2025-03-21 17:19:47 +00:00
Victor Stinner
1a082085ae
gh-131238: Remove pycore_object_deferred.h from pycore_object.h ( #131549 )
...
Remove also pycore_function.h from pycore_typeobject.h.
2025-03-21 16:44:10 +00:00
Bénédikt Tran
883c2f682b
GH-131331: Rename "not" to "invert" (GH-131334)
2025-03-20 16:59:41 -07:00
Mark Shannon
684a759c20
GH-127705: Don't call _Py_ForgetReference before _Py_Dealloc (GH-131508)
2025-03-20 15:45:43 +00:00
Mark Shannon
7ebd71ee14
GH-131498: Remove conditional stack effects (GH-131499)
...
* Adds some missing #includes
2025-03-20 15:39:38 +00:00
Mark Shannon
83d54fa876
GH-130296: Remove _PyOpcode_max_stack_effect
as it is no longer used (GH-131493)
2025-03-20 11:42:54 +00:00
Victor Stinner
b69da006a4
gh-131238: Remove includes from pycore_interp.h ( #131495 )
...
Remove also now unused includes in C files.
2025-03-20 11:35:23 +00:00
Victor Stinner
6c776abb90
gh-131238: Cleanup pycore_runtime.h includes ( #131486 )
2025-03-20 00:47:30 +00:00
Victor Stinner
344f3c3fd4
gh-131238: Remove pycore_lock.h includes ( #131483 )
...
PyMutex type is now part of <Python.h>, it's no longer needed to
include <pycore_lock.h> to get it.
2025-03-19 23:46:25 +00:00
Victor Stinner
6827c5129c
gh-131238: Move pycore_obmalloc.h include to pycore_runtime_structs.h ( #131482 )
...
Move pycore_obmalloc.h include from pycore_interp_structs.h to
pycore_runtime_structs.h.
Add also comment explaining the purpose of each include in
pycore_interp_structs.h, pycore_runtime_structs.h and
pycore_structs.h.
Remove <stdbool.h> and <stddef.h> from pycore_structs.h.
2025-03-19 23:32:30 +00:00
Victor Stinner
a7411025c5
gh-131238: Use pycore_interp_structs.h header ( #131481 )
...
Replace pycore_runtime_structs.h include with pycore_interp_structs.h
include in internal headers.
2025-03-19 23:13:25 +00:00
Victor Stinner
20c5f969dd
gh-131238: Remove more includes from pycore_interp.h ( #131480 )
2025-03-19 23:01:32 +01:00
Victor Stinner
22706843e0
gh-131238: Remove many includes from pycore_interp.h ( #131472 )
2025-03-19 17:46:24 +00:00
Victor Stinner
5c44d7d99c
gh-130931: Add pycore_interpframe.h internal header ( #131249 )
...
Move _PyInterpreterFrame and associated functions
to a new pycore_interpframe.h header.
2025-03-19 18:17:44 +01:00
Victor Stinner
4b54031323
gh-131238: Remove pycore_runtime.h from pycore_pystate.h ( #131356 )
...
* Remove includes from pycore_pystate.h:
* pycore_runtime_structs.h
* pycore_runtime.h
* pycore_tstate.h
* pycore_interp.h
* Reorganize internal headers. Move _gc_thread_state from
pycore_interp_structs.h to pycore_tstate.h.
* Add 3 new header files to PCbuild/pythoncore.vcxproj.
2025-03-19 17:33:24 +01:00
Victor Stinner
b8367e7cf3
gh-130931: Add pycore_typedefs.h internal header ( #131396 )
...
Declare _PyInterpreterFrame and _PyRuntimeState types before
declaring their structure members. Break reference cycles between
header files.
2025-03-19 15:23:32 +01:00
Irit Katriel
ffc2f1dd1c
gh-130080: implement PEP 765 ( #130087 )
2025-03-17 20:48:54 +00:00
Mark Shannon
fd545d735d
GH-127705: Move mortal decrefs to internal header and make sure _PyReftracerTrack is called
2025-03-17 17:23:50 +00:00
Mark Shannon
9881fc5483
GH-125174: Make immortality "sticky" (GH-131355)
...
* Use a higher threshold for immortality for INCREF than DECREF
2025-03-17 17:22:35 +00:00
Mark Shannon
a45f25361d
GH-131238: More refactoring of core header files (GH-131351)
...
Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
2025-03-17 14:41:05 +00:00
Victor Stinner
0453e494b6
gh-131238: Convert pycore_pystate.h static inline to functions ( #131352 )
...
Convert static inline functions to functions:
* _Py_IsMainThread()
* _PyInterpreterState_Main()
* _Py_IsMainInterpreterFinalizing()
* _Py_GetMainConfig()
2025-03-17 12:31:55 +01:00
Mark Shannon
a1aeec61c4
GH-131238: Core header refactor (GH-131250)
...
* Moves most structs in pycore_ header files into pycore_structs.h and pycore_runtime_structs.h
* Removes many cross-header dependencies
2025-03-17 09:19:04 +00:00
Tomas R.
d07e9ebbe8
gh-131306: Remove unused code related to BINARY_SUBSCR
( #131307 )
2025-03-16 16:37:29 +00:00
Hugo van Kemenade
c107b15ab8
Post 3.14.0a6
2025-03-14 19:09:56 +02:00
Hugo van Kemenade
77b2c933ca
Python 3.14.0a6
2025-03-14 17:05:02 +02:00
Mark Shannon
67af96c61c
GH-127705: Handle trace refs in specialized decref (GH-131198)
...
This is missing `_PyReftracerTrack` calls, see gh-131238.
Merging as-is for the 3.14.0a6 release.
2025-03-14 13:02:09 +01:00
Mark Shannon
2250ab6a13
GH-125174 Revert: Make immortality "sticky" (GH-131184)" ( #131230 )
...
Revert "GH-125174: Make immortality "sticky" (GH-131184)"
This reverts commit 3a91ee9724
.
2025-03-14 13:13:47 +02:00
Mark Shannon
3a91ee9724
GH-125174: Make immortality "sticky" (GH-131184)
2025-03-13 16:10:13 +00:00
Irit Katriel
4242c2b8d0
gh-130080: move _Py_EnsureArrayLargeEnough to a separate header so it can be used outside of the compiler ( #130930 )
2025-03-13 16:02:58 +00:00
Victor Stinner
10cbd1fe88
gh-130947: Add again PySequence_Fast() to the limited C API ( #130948 )
...
Add again PySequence_Fast() to the limited C API.
Add unit tests.
2025-03-13 13:00:57 +01:00
Yan Yanchii
3618240624
gh-126835: Avoid creating unnecessary tuple when looking for constant sequence during constant folding ( #131054 )
2025-03-12 21:45:54 +00:00
Mark Shannon
f30376c650
GH-127705: Fix _Py_RefcntAdd to handle objects becoming immortal (GH-131140)
2025-03-12 16:54:10 +00:00
T. Wouters
de2f7da77d
gh-115999: Add free-threaded specialization for FOR_ITER ( #128798 )
...
Add free-threaded versions of existing specialization for FOR_ITER (list, tuples, fast range iterators and generators), without significantly affecting their thread-safety. (Iterating over shared lists/tuples/ranges should be fine like before. Reusing iterators between threads is not fine, like before. Sharing generators between threads is a recipe for significant crashes, like before.)
2025-03-12 16:21:46 +01:00
Sam Gross
7ffe93faf1
gh-131121: Fix _Py_atomic_store_char_relaxed
memory order (gh-131122)
2025-03-12 09:03:04 -04:00
Victor Stinner
4dcbe06fd2
gh-111178: Fix type of PyCMethod's "nargs" argument (GH-131135)
...
Replace "size_t nargs" with "Py_ssize_t nargs" in PyCMethod.
2025-03-12 11:54:02 +01:00
Mark Shannon
6e5b9f3d00
GH-127705: Check for immortality in refcount accounting ( #131072 )
...
Check for immortality in refcount accounting
2025-03-11 11:53:07 +00:00
Max Bachmann
de8818ae23
gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN ( #131044 )
...
* Add missing guards for WIN32_LEAN_AND_MEAN
* add missing whitespaces
2025-03-11 12:33:01 +01:00
Ken Jin
a8ee1e16f5
gh-130039: Tailcall for windows builds (GH-130040)
...
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-11 10:52:56 +08:00
Mark Shannon
be046ee6e0
GH-123044: Give the POP_TOP
after a case test a location in the body, not the pattern. (GH-130627)
2025-03-10 17:31:16 +00:00
Mark Shannon
2bef8ea8ea
GH-127705: Use _PyStackRef
s in the default build. (GH-127875)
2025-03-10 14:06:56 +00:00
Mark Shannon
89df62c120
GH-128534: Fix behavior of branch monitoring for async for
(GH-130847)
...
* Both branches in a pair now have a common source and are included in co_branches
2025-03-07 14:30:31 +00:00