Commit Graph
9616 Commits
Author SHA1 Message Date
Tomasz PytelandGitHub 891c61c1fa gh-128632: fix segfault on nested __classdict__ type param (#128744) 2025-04-04 06:23:35 -07:00
Victor StinnerandGitHub 37d47d4965 gh-125434: Display thread name in faulthandler (#132016) 2025-04-04 12:24:41 +00:00
Filipe Laíns 🇵🇸andGitHub 6ab4acecf9 GH-131770: increase assumed WASI stack size to 131072 (wasi-sdk default) (#131844)
https://github.com/WebAssembly/wasi-libc/blob/e9524a0980b9bb6bb92e87a41ed1055bdda5bb86/libc-top-half/musl/src/internal/pthread_impl.h#L220

Signed-off-by: Filipe Laíns <[email protected]>
2025-04-04 09:34:02 +01:00
943cc1431e gh-131591: Implement PEP 768 (#131937)
Co-authored-by: Ivona Stojanovic <[email protected]>
Co-authored-by: Matt Wozniski <[email protected]>
2025-04-03 16:20:01 +01:00
Mark ShannonandGitHub 275056a7fd GH-131904: Fix Py_STACKREF_DEBUG build (GH-132022) 2025-04-03 09:40:37 +01:00
Adam TurnerandGitHub f20f02e6b5 gh-118761: Optimise import time for ast (#131953) 2025-04-02 17:22:15 +01:00
Mark ShannonandGitHub ad053d8d6a GH-131498: Cases generator: Parse down to C statement level. (GH-131948)
* Parse down to statement level in the cases generator

* Add handling for #if macros, treating them much like normal ifs.
2025-04-02 16:31:59 +01:00
sobolevnandGitHub ab2a3dda1d gh-132002: Fix crash of ContextVar on unhashable str subtype (#132003) 2025-04-02 14:48:47 +03:00
Brandt BucherandGitHub 3a8cefba0b GH-131726: Split up _CHECK_VALIDITY_AND_SET_IP (GH-131810) 2025-04-01 16:55:05 -07:00
Brandt BucherandGitHub 1a9d4a1fb3 GH-131798: Allow the JIT to remove more int/float/str guards (GH-131800) 2025-04-01 15:10:15 -07:00
mpageandGitHub 053c285f6b gh-130704: Strength reduce LOAD_FAST{_LOAD_FAST} (#130708)
Optimize `LOAD_FAST` opcodes into faster versions that load borrowed references onto the operand stack when we can prove that the lifetime of the local outlives the lifetime of the temporary that is loaded onto the stack.
2025-04-01 10:18:42 -07:00
Bénédikt TranandGitHub edbf7fb129 gh-111178: remove redundant casts for functions with correct signatures (#131673) 2025-04-01 17:18:11 +02:00
Chris EiblandGitHub 2e96f5ae4d GH-131296: Add missing UNREACHABLE mark in thread_nt.h (GH-131589) 2025-03-31 20:28:35 +01:00
sobolevnandGitHub 1e3ec335e0 Fix PEP number in ast_opt.c for new finally check (#131928) 2025-03-31 16:29:23 +03:00
Mark ShannonandGitHub c535a132e4 GH-131498: Another refactoring of the code generator (GH-131827)
* 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 analyis to optimizer generated code

* Add 'out' parameter to stack.pop
2025-03-31 13:52:48 +01:00
Amit LavonandGitHub 685fd74f81 GH-131798: Remove type checks for _TO_BOOL_STR (GH-131816) 2025-03-30 16:07:25 -07:00
Jelle ZijlstraandGitHub 425f60b9eb gh-130924: Do not create cells for usages of names in local annotations (#131843) 2025-03-29 21:15:48 +00:00
Martin DeMelloandGitHub 9c1e85fd64 gh-131740: minor readability fix in PyUnstable_GC_VisitObjects (gh-131786)
Minor readability fix in PyUnstable_GC_VisitObjects

Replaces `if (visit_generation())` with `if (visit_generation() < 0)`,
since we are checking for the failure case, and it's confusing to have
that be implicitly `true`.

Also fixes a misspelt variable name.
2025-03-29 08:58:17 +09:00
Dino ViehlandandGitHub 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 KatrielandGitHub 2c8f329dc6 gh-131738: optimize builtin any/all/tuple calls with a generator expression arg (#131737) 2025-03-28 10:35:20 +00:00
HangandGitHub 8bd88e2827 gh-131818: Add imply -P in -I's help message (#131819) 2025-03-28 08:49:13 +01:00
Brandt BucherandGitHub 972a295fe3 GH-130415: Remove redundant sym_matches_type calls in the JIT optimizer (GH-131778) 2025-03-27 09:12:30 -07:00
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 <[email protected]>

* Fix alignment

* atomic load

* Update Objects/tupleobject.c

Co-authored-by: Chris Eibl <[email protected]>

---------

Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Chris Eibl <[email protected]>
2025-03-27 09:57:06 -04:00
Mark ShannonandGitHub d836d287a7 GH-131729: Consider in-memory state when merging storage and stack (GH-131773) 2025-03-27 08:32:45 +00:00
Sergey MuraviovandGitHub 151d1bfd1b gh-131763: Replace the redundant check with assert in remove_tools (#131765) 2025-03-26 18:36:04 -04:00
Sam GrossandGitHub 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
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 <[email protected]>
2025-03-26 12:08:20 -04:00
Mark ShannonandGitHub 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 ZijlstraandGitHub 898e6b395e gh-130881: Handle conditionally defined annotations (#130935) 2025-03-26 03:48:19 +00:00
Donghee NaandGitHub 7bb41aef4b gh-131740: Update PyUnstable_GC_VisitObjects to traverse perm gen (gh-131744) 2025-03-26 09:45:29 +09:00
929afd1d6e gh-131670: Fix crash in anext() when __anext__ is sync and raises (#131682)
Co-authored-by: Bénédikt Tran <[email protected]>
2025-03-24 19:00:48 +00:00
Sam GrossandGitHub 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
Bénédikt TranandGitHub 511a844028 gh-111178: fix UBSan failures for Python/legacy_tracing.c (#131611) 2025-03-24 11:00:32 +01:00
Bénédikt TranandGitHub 43fde78bef gh-111178: fix UBSan failures for Python/instrumentation.c (#131608) 2025-03-24 10:58:33 +01:00
Bénédikt TranandGitHub f65be097ed gh-111178: fix UBSan failures for _PyExecutorObject (#131610) 2025-03-24 10:53:23 +01:00
Irit KatrielandGitHub 64906bb223 gh-130080: do not fold match case constants in unoptimized AST (#131577) 2025-03-23 13:50:14 +00:00
Victor StinnerandGitHub 9962469943 gh-131296: fix clang-cl warning in tracemalloc.c (#131514)
Always set MAX_NFRAME to UINT16_MAX.

Avoid the complicated code which emitted a compiler warning.
2025-03-22 10:38:47 +01:00
Victor StinnerandGitHub 49fb75c676 gh-131238: Add missing pycore_function.h includes for JIT compiler (#131571) 2025-03-21 23:37:49 +00:00
Dino ViehlandandGitHub d9411ae3c2 gh-130312: SET_ADD should not lock (#130136)
SET_ADD should not lock
2025-03-21 15:58:32 -07:00
Victor StinnerandGitHub 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 OstrowskiandGitHub b92ee14b80 GH-130415: Optimize constant comparison in JIT builds (GH-131489) 2025-03-21 11:23:12 -07:00
Sam GrossandGitHub 0de5e0c544 gh-117657: Fix TSAN data race in _PyEval_SetTrace assertion (gh-131561)
The `sys_tracing_threads` variable should be read inside `LOCK_SETUP()`.
2025-03-21 14:22:37 -04:00
Victor StinnerandGitHub 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
Sam GrossandGitHub 4f32516804 gh-128421: Add locking to most frame object functions (gh-131479)
This makes more operations on frame objects thread-safe in the free
threaded build, which fixes some data races that occurred when passing
exceptions between threads.

However, accessing local variables from another thread while its running
is still not thread-safe and may crash the interpreter.
2025-03-21 11:10:07 -04:00
Bénédikt TranandGitHub 883c2f682b GH-131331: Rename "not" to "invert" (GH-131334) 2025-03-20 16:59:41 -07:00
Chris EiblandGitHub a2ea417578 GH-131296: fix clang-cl warnings in sysmodule.c (#131304) 2025-03-20 16:29:21 +00:00
Mark ShannonandGitHub 7ebd71ee14 GH-131498: Remove conditional stack effects (GH-131499)
* Adds some missing #includes
2025-03-20 15:39:38 +00:00
Mark ShannonandGitHub 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 StinnerandGitHub 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 StinnerandGitHub 34c1ea3109 gh-111178: Fix function signatures for multiple tests (#131496) 2025-03-20 12:27:03 +01:00