Amit Lavon
685fd74f81
GH-131798: Remove type checks for _TO_BOOL_STR (GH-131816)
2025-03-30 16:07:25 -07:00
Jelle Zijlstra
425f60b9eb
gh-130924: Do not create cells for usages of names in local annotations ( #131843 )
2025-03-29 21:15:48 +00:00
Dino Viehland
2984ff9e51
gh-130373: Avoid locking in _LOAD_ATTR_WITH_HINT ( #130372 )
...
Avoid locking in _LOAD_ATTR_WITH_HINT
2025-03-28 15:16:41 -07:00
Irit Katriel
2c8f329dc6
gh-131738: optimize builtin any/all/tuple calls with a generator expression arg ( #131737 )
2025-03-28 10:35:20 +00:00
Michael Droettboom
8614f86b71
gh-131525: Cache the result of tuple_hash ( #131529 )
...
* gh-131525: Cache the result of tuple_hash
* Fix debug builds
* Add blurb
* Fix formatting
* Pre-compute empty tuple singleton
* Mostly set the cache within tuple_alloc
* Fixes for TSAN
* Pre-compute empty tuple singleton
* Fix for 32-bit platforms
* Assert that op != NULL in _PyTuple_RESET_HASH_CACHE
* Use FT_ATOMIC_STORE_SSIZE_RELAXED macro
* Update Include/internal/pycore_tuple.h
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* Fix alignment
* atomic load
* Update Objects/tupleobject.c
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
---------
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2025-03-27 09:57:06 -04:00
Neil Schemenauer
316938bddf
Revise pycore_stackref.h comments. ( #130601 )
2025-03-27 14:00:25 +05:30
Neil Schemenauer
c824d8e6f9
gh-131782: Fix cast to match type of bits in _Py_TryIncrefCompareStackRef ( #131783 )
2025-03-27 13:58:59 +05:30
Brandt Bucher
4b3d5b6042
GH-119866: Don't clear frame->stackpointer on release builds (GH-131750)
2025-03-26 19:00:16 +00:00
Sam Gross
67fbfb42bd
gh-131586: Avoid refcount contention in some "special" calls ( #131588 )
...
In the free threaded build, the `_PyObject_LookupSpecial()` call can lead to
reference count contention on the returned function object becuase it
doesn't use stackrefs. Refactor some of the callers to use
`_PyObject_MaybeCallSpecialNoArgs`, which uses stackrefs internally.
This fixes the scaling bottleneck in the "lookup_special" microbenchmark
in `ftscalingbench.py`. However, the are still some uses of
`_PyObject_LookupSpecial()` that need to be addressed in future PRs.
2025-03-26 14:38:47 -04:00
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