1606 Commits

Author SHA1 Message Date
Serhiy Storchaka
bac3fcba5b
gh-108512: Add and use new replacements for PySys_GetObject() (GH-111035)
Add functions PySys_GetAttr(), PySys_GetAttrString(),
PySys_GetOptionalAttr() and PySys_GetOptionalAttrString().
2025-05-28 20:11:09 +03:00
Neil Schemenauer
fbbbc10055
gh-127266: avoid data races when updating type slots (gh-133177)
In the free-threaded build, avoid data races caused by updating type
slots or type flags after the type was initially created.  For those
(typically rare) cases, use the stop-the-world mechanism.  Remove the
use of atomics when reading or writing type flags.
2025-05-27 18:27:41 -07:00
Mark Shannon
f6f4e8a662
GH-132554: "Virtual" iterators (GH-132555)
* FOR_ITER now pushes either the iterator and NULL or leaves the iterable and pushes tagged zero

* NEXT_ITER uses the tagged int as the index into the sequence or, if TOS is NULL, iterates as before.
2025-05-27 15:59:45 +01:00
Brett Cannon
ad42dc1909
GH-130397: remove special-casing of C stack depth for WASI (#134469)
Removed special-casing for WASI when setting C stack depth limits. Since WASI has its own C stack checking this isn't a security risk.

Also disabled some tests that stopped passing. They all happened to have already been disabled under Emscripten.
2025-05-22 14:08:44 -07:00
Mark Shannon
ac7d5ba96e
GH-133231: Changes to executor management to support proposed sys._jit module (GH-133287)
* Track the current executor, not the previous one, on the thread-state. 

* Batch executors for deallocation to avoid having to constantly incref executors; this is an ad-hoc form of deferred reference counting.
2025-05-04 10:05:35 +01:00
Adam Turner
f21e42d906
Remove duplicate includes: Python/{bytecodes,ceval,optimizer_analysis}.c (#132622) 2025-05-01 12:07:53 +01:00
Mark Shannon
44e4c479fb
GH-124715: Move trashcan mechanism into Py_Dealloc (GH-132280) 2025-04-30 11:37:53 +01:00
Lysandros Nikolaou
60202609a2
gh-132661: Implement PEP 750 (#132662)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Wingy <git@wingysam.xyz>
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
Co-authored-by: Dave Peck <davepeck@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Paul Everitt <pauleveritt@me.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-04-30 11:46:41 +02:00
Mark Shannon
ccf1b0b1c1
GH-132508: Use tagged integers on the evaluation stack for the last instruction offset (GH-132545) 2025-04-29 18:00:35 +01:00
Neil Schemenauer
eecafc3380
Revert gh-127266: avoid data races when updating type slots (gh-131174) (gh-133129)
This is triggering deadlocks in test_opcache.  See GH-133130 for stack trace.
2025-04-28 23:38:29 -07:00
Neil Schemenauer
e414a2d81c
gh-127266: avoid data races when updating type slots (gh-131174)
In the free-threaded build, avoid data races caused by updating type slots
or type flags after the type was initially created.  For those (typically
rare) cases, use the stop-the-world mechanism.  Remove the use of atomics
when reading or writing type flags.  The use of atomics is not sufficient to
avoid races (since flags are sometimes read without a lock and without
atomics) and are no longer required.
2025-04-28 20:28:44 +00:00
Ken Jin
6430c634da
gh-132758: Fix tail call and pystats builds (GH-132759) 2025-04-23 18:17:35 +08:00
Bénédikt Tran
8a9c6c4d16
gh-128398: improve error messages when incorrectly using with and async with (#132218)
Improve the error message with a suggestion when an object supporting the synchronous
(resp. asynchronous) context manager protocol is entered using `async with` (resp. `with`)
instead of `with` (resp. `async with`).
2025-04-19 10:44:01 +02:00
T. Wouters
c66ffcf8e3
gh-129987: Selectively re-enable SLP autovectorization of _PyEval_EvalFrameDefault (#132530)
Only disable SLP autovectorization of `_PyEval_EvalFrameDefault` on newer
GCCs, as the optimization bug seems to exist only on GCC 12 and later, and
before GCC 9 disabling the optimization has a dramatic performance impact.
2025-04-15 09:39:32 +00:00
Furkan Onder
c7f6535e4a
gh-131624: Fix posix_spawn tests failing on NetBSD with stack limit assertions (GH-131625)
Fix recursive limit assertions on NetBSD for posix_spawn.
2025-04-13 14:06:38 +03:00
Tomas R.
e6ef47ac22
gh-132386: Fix a crash when passing a dict subclass to exec (GH-132412)
* Fix crash when passing a dict subclass to exec

* Add news entry
2025-04-12 05:05:03 +08:00
Chris Eibl
e5f68fd29b
GH-131296: Suppress "unused label" warning for clang-cl closer to actual occurrence (GH-131900) 2025-04-10 23:17:33 +01:00
mpage
619edb802e
gh-132336: Mark a few "slow path" functions used by the interpreter loop as noinline (#132337)
Mark a few functions used by the interpreter loop as noinline

These are all the slow path and should not be inlined into the interpreter
loop. Unfortunately, they end up being inlined with LTO and the current PGO
task.
2025-04-10 10:41:15 +02:00
mpage
1f5682f3a2
gh-129987: Disable GCC SLP autovectorization for the interpreter loop on x86-64 (#132295)
The SLP autovectorizer can cause poor code generation for opcode dispatch, negating any benefit we get from vectorization elsewhere in the interpreter loop.
2025-04-09 10:34:12 -07:00
Mark Shannon
7099c75550
GH-131498: Cases generator: manage stacks automatically (GH-132074) 2025-04-04 17:59:36 +01:00
Filipe Laíns 🇵🇸
6ab4acecf9
GH-131770: increase assumed WASI stack size to 131072 (wasi-sdk default) (#131844)
e9524a0980/libc-top-half/musl/src/internal/pthread_impl.h (L220)

Signed-off-by: Filipe Laíns <lains@riseup.net>
2025-04-04 09:34:02 +01: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
Kumar Aditya
b12af0a48f
gh-131401: fix data races in exception handling (#131447) 2025-03-20 12:02:05 +05:30
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
Hood Chatham
f3e275f1a9
GH-130396: Work around for broken pthread_get_stackaddr_np on Emscripten (#131088)
Implements a workaround implementation of `pthread_get_stackaddr_np` for Emscripten.
This will be replaced by an implementation that will be included in Emscripten 4.0.6.
2025-03-14 07:04:40 +08:00
Tomasz Pytel
c5abded099
gh-130382: add missing _PyReftracerTrack to ceval Py_DECREF (#130689) 2025-03-13 12:31:49 -04:00
Sam Gross
4162bc133b
gh-130396: Fix thread sanitizer crashes on stack overflow tests (gh-130966)
Thread sanitizer will often crash if a test uses more than half the
stack.
2025-03-11 10:33:23 -04:00
Mark Shannon
2bef8ea8ea
GH-127705: Use _PyStackRefs in the default build. (GH-127875) 2025-03-10 14:06:56 +00:00
Serhiy Storchaka
0ef4ffeefd
gh-130163: Fix crashes related to PySys_GetObject() (GH-130503)
The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed
reference, has been replaced by using one of the following functions, which
return a strong reference and distinguish a missing attribute from an error:
_PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(),
_PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().
2025-02-25 23:04:27 +02:00
Mark Shannon
014223649c
GH-130396: Use computed stack limits on linux (GH-130398)
* Implement C recursion protection with limit pointers for Linux, MacOS and Windows

* Remove calls to PyOS_CheckStack

* Add stack protection to parser

* Make tests more robust to low stacks

* Improve error messages for stack overflow
2025-02-25 09:24:48 +00:00
Petr Viktorin
ef29104f7d
GH-91079: Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now (GH130413)
Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now

Unfortunatlely, the change broke some buildbots.

This reverts commit 2498c22fa0a2b560491bc503fa676585c1a603d0.
2025-02-24 11:16:08 +01:00
Mark Shannon
2498c22fa0
GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)
* Implement C recursion protection with limit pointers

* Remove calls to PyOS_CheckStack

* Add stack protection to parser

* Make tests more robust to low stacks

* Improve error messages for stack overflow
2025-02-19 11:44:57 +00:00
Ken Jin
46ac85e4d9
gh-129989: Change Py_TAIL_CALL_INTERP ifndef to ! (#130269)
Change Py_TAIL_CALL_INTERP ifndef to !
2025-02-18 15:48:49 +00:00
Ken Jin
359c7dde3b
gh-129989: Properly disable tailcall interp in configure (GH-129991)
Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-02-16 03:01:24 +08:00
Mark Shannon
72f56654d0
GH-128682: Account for escapes in DECREF_INPUTS (GH-129953)
* Handle escapes in DECREF_INPUTS

* Mark a few more functions as escaping

* Replace DECREF_INPUTS with PyStackRef_CLOSE where possible
2025-02-12 17:44:59 +00:00
Michael Droettboom
00ec781877
gh-129244: Only remove the workaround when MSVC has the bugfix (#130011) 2025-02-11 14:49:42 -05:00
Ken Jin
5cdd6e5e75
gh-130004: Disable PGO for ceval.c on MSVC for default build (GH-130009)
Disable PGO for ceval.c on MSVC on default build
2025-02-12 01:13:05 +08:00
Ken Jin
247b50dec8
gh-130004: Revert commit 9e52e55 (GH-130005)
Revert commit 9e52e55
2025-02-11 23:23:58 +08:00
Irit Katriel
a1417b211f
gh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR (#129700) 2025-02-07 22:39:54 +00:00
Brandt Bucher
70e387c990
GH-129709: Clean up tier two (GH-129710) 2025-02-07 09:52:49 -08:00
Brandt Bucher
fbaa6c8ff0
GH-129763: Remove the LLTRACE macro (GH-129764) 2025-02-07 08:49:51 -08:00
Ken Jin
cb640b659e
gh-128563: A new tail-calling interpreter (GH-128718)
Co-authored-by: Garrett Gu <garrettgu777@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-02-06 23:21:57 +08:00
Mark Shannon
96ff4c2486
GH-128682: Mark two more macros as escaping. (GH-129645)
Expand out SETLOCAL so that code generator can see the decref. Mark Py_CLEAR as escaping
2025-02-04 14:00:51 +00:00
Mark Shannon
54f74b80ae
GH-128563: Move some labels, to simplify implementing tailcalling interpreter. (GH-129525) 2025-01-31 17:13:20 +00:00
Mark Shannon
c3ae5c9e4a
GH-128563: Simplify recursion check in _PyEval_EvalFrameDefault (GH-129481)
Simplify recursion check in _PyEval_EvalFrameDefault
2025-01-31 12:12:24 +00:00
Ken Jin
87fb8b198c
gh-128563: Move labels in ceval.c to bytecodes.c (GH-129112) 2025-01-27 18:30:20 +08:00
Irit Katriel
c39ae8922b
gh-128799: Add frame of except* to traceback when wrapping a naked exception (#128971) 2025-01-25 13:00:23 +00:00
Michael Droettboom
9e52e553f4
gh-129244: Remove workaround for MSVC compiler crash (#129263)
* Remove compiler workaround

* Remote _Py_USING_PGO
2025-01-25 07:56:13 -05:00
Chris Eibl
8fecb9fa0b
Remove unused DPRINTF in ceval.c (GH-129282)
remove unused DPRINTF in ceval.c
2025-01-25 18:33:26 +08:00