Sam Gross
51b4edb1a4
gh-129668: Fix thread-safety of MemoryError freelist in free threaded build (gh-129704)
...
The MemoryError freelist was not thread-safe in the free threaded build.
Use a mutex to protect accesses to the freelist. Unlike other freelists,
the MemoryError freelist is not performance sensitive.
2025-02-06 12:38:12 -05:00
Mark Shannon
2effea4dab
GH-128682: Spill the stack pointer in labels, as well as instructions (GH-129618)
2025-02-04 12:18:31 +00:00
Yan Yanchii
0664c1af9b
gh-126835: Move constant subscript folding to CFG ( #129568 )
...
Move folding of constant subscription from AST optimizer to CFG.
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2025-02-04 10:10:55 +02:00
Mark Shannon
75b628adeb
GH-128563: Generate opcode = ...
in instructions that need opcode
(GH-129608)
...
* Remove support for GO_TO_INSTRUCTION
2025-02-03 15:09:21 +00:00
Mark Shannon
808071b994
GH-128682: Make PyStackRef_CLOSE
escaping. (GH-129404)
2025-02-03 12:41:32 +00:00
Diego Russo
567394517a
GH-128842: Collect JIT memory stats (GH-128941)
2025-02-02 15:17:53 -08:00
Victor Stinner
3bebe46d34
gh-128911: Add PyImport_ImportModuleAttr() function ( #128912 )
...
Add PyImport_ImportModuleAttr() and
PyImport_ImportModuleAttrString() functions.
* Add unit tests.
* Replace _PyImport_GetModuleAttr()
with PyImport_ImportModuleAttr().
* Replace _PyImport_GetModuleAttrString()
with PyImport_ImportModuleAttrString().
* Remove "pycore_import.h" includes, no longer needed.
2025-01-30 11:17:29 +00:00
Sam Gross
5ff2fbc026
gh-129236: Use stackpointer
in free threaded GC ( #129240 )
...
The stack pointers in interpreter frames are nearly always valid now, so
use them when visiting each thread's frame. For now, don't collect
objects with deferred references in the rare case that we see a frame
with a NULL stack pointer.
2025-01-29 10:40:51 -05:00
Pieter Eendebak
a29221675e
gh-127119: Faster check for small ints in long_dealloc (GH-127620)
2025-01-29 15:22:18 +00:00
Irit Katriel
4815131910
gh-100239: specialize bitwise logical binary ops on ints ( #128927 )
2025-01-29 09:28:21 +00:00
Pieter Eendebak
1a80214f11
gh-126703: Add freelists for list and tuple iterators (GH-128592)
2025-01-29 09:15:24 +00:00
Brandt Bucher
41ad2bb248
GH-128563: Don't leave frame->lltrace uninitialized (GH-129417)
2025-01-28 16:26:46 -08:00
Brandt Bucher
828b27680f
GH-126599: Remove the PyOptimizer API (GH-129194)
2025-01-28 16:10:51 -08:00
Sam Gross
a6a8c6f86e
gh-128954: Reorder _PyInterpreterFrame fields for reduced memory usage ( #128958 )
...
This reduces the size of _PyInterpreterFrame by 8 bytes on 64-bit
platforms using the free threading build due to alignment requirements.
This allows for slightly more recursive calls into the interpreter (from
C), but `test_call.test_super_deep` still crashes.
2025-01-27 17:14:51 +00:00
Mark Shannon
75b4962157
GH-128914: Remove all but one conditional stack effects (GH-129226)
...
* Remove all 'if (0)' and 'if (1)' conditional stack effects
* Use array instead of conditional for BUILD_SLICE args
* Refactor LOAD_GLOBAL to use a common conditional uop
* Remove conditional stack effects from LOAD_ATTR specializations
* Replace conditional stack effects in LOAD_ATTR with a 0 or 1 sized array.
* Remove conditional stack effects from CALL_FUNCTION_EX
2025-01-27 16:24:48 +00: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
Pablo Galindo Salgado
3a3a6b86f4
gh-129223: Do not allow the compiler to optimise away symbols for debug sections ( #129225 )
...
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-01-24 21:36:32 +01:00
Victor Stinner
c005ea4951
gh-129185: Use PyMutex in tracemalloc ( #129246 )
2025-01-24 11:25:24 +01:00
Victor Stinner
e579cdb21e
gh-129185: Remove internal TRACE_RAW_MALLOC macro ( #129218 )
...
Always build tracemalloc with PyMem_RawMalloc() hooks.
2025-01-23 13:49:35 +01:00
Sam Gross
a10f99375e
Revert "GH-128914: Remove conditional stack effects from bytecodes.c
and the code generators (GH-128918)" (GH-129202)
...
The commit introduced a ~2.5-3% regression in the free threading build.
This reverts commit ab61d3f430
.
2025-01-23 09:26:25 +00:00
Yury Selivanov
188598851d
GH-91048: Add utils for capturing async call stack for asyncio programs and enable profiling ( #124640 )
...
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
Co-authored-by: Jacob Coffee <jacob@z7x.org>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2025-01-22 17:25:29 +01:00
Mikhail Efimov
8e20e42cc6
gh-125723: Fix crash with f_locals when generator frame outlive their generator ( #126956 )
...
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2025-01-22 15:50:01 +03:00
Mark Shannon
470a0a68eb
GH-128682: Change a couple of functions to only steal references on success. (GH-129132)
...
Change PyTuple_FromStackRefSteal and PyList_FromStackRefSteal to only steal on success to avoid escaping
2025-01-22 10:51:37 +00:00
Ken Jin
5809b25909
gh-128563: Move lltrace into the frame struct (GH-129113)
2025-01-21 22:17:15 +08:00
Bénédikt Tran
36f341ca3e
gh-127787: allow retrieving the clipped slice length in _PyUnicodeError_GetParams
(GH-128980)
2025-01-21 11:45:53 +01:00
Mark Shannon
f5b6356a11
GH-128563: Add new frame owner type for interpreter entry frames (GH-129078)
...
Add new frame owner type for interpreter entry frames
2025-01-21 10:15:02 +00:00
Mark Shannon
ab61d3f430
GH-128914: Remove conditional stack effects from bytecodes.c
and the code generators (GH-128918)
2025-01-20 17:09:23 +00:00
Mark Shannon
f0f7b978be
GH-128939: Refactor JIT optimize structs (GH-128940)
2025-01-20 15:49:15 +00:00
Victor Stinner
8ceb6cb117
gh-129033: Remove _PyInterpreterState_SetConfig() function ( #129048 )
...
Remove _PyInterpreterState_GetConfigCopy() and
_PyInterpreterState_SetConfig() private functions. PEP 741 "Python
Configuration C API" added a better public C API: PyConfig_Get() and
PyConfig_Set().
2025-01-20 16:31:33 +01:00
Peter Bierma
4d0a6595a0
gh-128360: Add _Py_AssertHoldsTstate
as assertion for holding a thread state ( #128361 )
...
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-20 17:04:35 +05:30
Sam Gross
d66c08aa75
gh-128923: Use zero to indicate unassigned unique id ( #128925 )
...
In the free threading build, the per thread reference counting uses a
unique id for some objects to index into the local reference count
table. Use 0 instead of -1 to indicate that the id is not assigned. This
avoids bugs where zero-initialized heap type objects look like they have
a unique id assigned.
2025-01-17 16:42:27 +01:00
Xuanteng Huang
b44ff6d0df
GH-126599: Remove the "counter" optimizer/executor (GH-126853)
2025-01-16 15:57:04 -08:00
Irit Katriel
3893a92d95
gh-100239: specialize long tail of binary operations ( #128722 )
2025-01-16 15:22:13 +00:00
Victor Stinner
36c5e3bcc2
gh-128679: Redesign tracemalloc locking ( #128888 )
...
* Use TABLES_LOCK() to protect 'tracemalloc_config.tracing'.
* Hold TABLES_LOCK() longer while accessing tables.
* tracemalloc_realloc() and tracemalloc_free() no longer
remove the trace on reentrant call.
* _PyTraceMalloc_Stop() unregisters _PyTraceMalloc_TraceRef().
* _PyTraceMalloc_GetTraces() sets the reentrant flag.
* tracemalloc_clear_traces_unlocked() sets the reentrant flag.
2025-01-15 20:22:44 +00:00
Neil Schemenauer
080f444a58
gh-128807: Add marking phase for free-threaded cyclic GC (gh-128808)
2025-01-15 11:27:28 -08:00
mpage
b5ee0258bf
gh-115999: Specialize LOAD_ATTR
for instance and class receivers in free-threaded builds ( #128164 )
...
Finish specialization for LOAD_ATTR in the free-threaded build by adding support for class and instance receivers.
2025-01-14 11:56:11 -08:00
Neil Schemenauer
1c13c56a34
gh-128384: Add locking to warnings.py. (gh-128386)
...
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-14 11:43:42 -08:00
Victor Stinner
24a8d920c1
gh-127787: Move _PyUnicodeError_GetParams() to the internal C API ( #128803 )
2025-01-14 11:17:20 +01:00
Mark Shannon
517dc65ffc
GH-128682: Stronger checking of PyStackRef_CLOSE
and DEAD
. (GH-128683)
2025-01-13 12:37:48 +00:00
Mark Shannon
39fc7ef4fe
GH-124483: Mark Py_DECREF
, etc. as escaping for the JIT (GH-128678)
2025-01-13 11:42:45 +00:00
Mark Shannon
ddd959987c
GH-128685: Specialize (rather than quicken) LOAD_CONST into LOAD_CONST_[IM]MORTAL (GH-128708)
2025-01-13 10:30:28 +00:00
Hood Chatham
d0ecbdd838
gh-128627: Emscripten: Use wasm-gc based call adaptor if available ( #128628 )
...
Replaces the trampoline mechanism in Emscripten with an implementation that uses a
recently added feature of wasm-gc instead of JS type reflection, when that feature is
available.
2025-01-13 07:09:39 +08:00
Pieter Eendebak
ff39e3ff7b
gh-126703: Add freelist for PyMethodObject
( #128594 )
2025-01-12 18:31:49 +05:30
Kumar Aditya
7dc41ad6a7
gh-128002: fix asyncio.all_tasks
against concurrent deallocations of tasks ( #128541 )
2025-01-09 21:26:00 +05:30
Mark Shannon
f826beca0c
GH-128375: Better instrument for FOR_ITER
(GH-128445)
2025-01-06 17:54:47 +00:00
Jelle Zijlstra
d50fa0541b
gh-128089: Add PYC magic number for VALUE_WITH_FAKE_GLOBALS ( #128097 )
...
Assign 3610 PYC magic number to VALUE_WITH_FAKE_GLOBALS
format of annotationlib.
2025-01-06 10:30:42 +00:00
Ken Jin
7ef4907412
gh-128262: Allow specialization of calls to classes with __slots__ (GH-128263)
2024-12-31 12:24:17 +08:00
T. Wouters
180d417e9f
gh-114203: Optimise simple recursive critical sections ( #128126 )
...
Add a fast path to (single-mutex) critical section locking _iff_ the mutex
is already held by the currently active, top-most critical section of this
thread. This can matter a lot for indirectly recursive critical sections
without intervening critical sections.
2024-12-23 13:31:33 +01:00
Mark Shannon
128cc47fbd
GH-127705: Add debug mode for _PyStackRef
s inspired by HPy debug mode (GH-128121)
2024-12-20 16:52:20 +00:00
Mark Shannon
df46c780fe
GH-122548: Correct magic number comment (GH-128115)
...
Correct magic number comment
2024-12-20 11:57:44 +00:00