summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
...
* gh-110481: Fix biased reference counting queue initialization. (#117271)Sam Gross2024-03-282-6/+18
| | | | | The biased reference counting queue must be initialized from the bound (active) thread because it uses `_Py_ThreadId()` as the key in a hash table.
* gh-117266: Fix crashes on user-created AST subclasses (GH-117276)Jelle Zijlstra2024-03-281-2/+13
| | | Fix crashes on user-created AST subclasses
* gh-114099: Additions to standard library to support iOS (GH-117052)Russell Keith-Magee2024-03-282-3/+11
| | | | | Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Malcolm Smith <smith@chaquo.com> Co-authored-by: Ned Deily <nad@python.org>
* gh-117288: Allocate fewer label IDs in _PyCfg_ToInstructionSequence (#117290)Irit Katriel2024-03-273-6/+36
|
* gh-115775: Compiler adds __static_attributes__ field to classes (#115913)Irit Katriel2024-03-261-1/+53
|
* GH-117108: Set the "old space bit" to "visited" for all young objects (#117213)Mark Shannon2024-03-261-17/+37
| | | | Change old space bit of young objects from 0 to gcstate->visited_space. This ensures that any object created *and* collected during cycle GC has the bit set correctly.
* GH-116422: Tier2 hot/cold splitting (GH-116813)Mark Shannon2024-03-269-751/+834
| | | | | Splits the "cold" path, deopts and exits, from the "hot" path, reducing the size of most jitted instructions, at the cost of slower exits.
* A few minor tweaks to get stats working and compiling cleanly. (#117219)Mark Shannon2024-03-252-6/+3
| | | | Fixes a compilation error when configured with `--enable-pystats`, an array size issue, and an unused variable.
* gh-117176: Fix compiler warning in Python/optimizer_bytecodes.c (GH-117199)Kirill Podoprigora2024-03-242-2/+2
|
* gh-117180: Complete call sequence when trace stack overflow (GH-117184)Ken Jin2024-03-231-0/+1
| | | | | | | --------- Co-authored-by: Peter Lazorchak <lazorchakp@gmail.com> Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com> Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
* GH-117108: Change the size of the GC increment to about 1% of the total heap ↵Mark Shannon2024-03-222-16/+16
| | | | size. (GH-117120)
* gh-113024: C API: Add PyObject_GenericHash() function (GH-113025)Serhiy Storchaka2024-03-221-1/+7
|
* gh-105716: Fix _PyInterpreterState_IsRunningMain() For Embedders (gh-117140)Eric Snow2024-03-222-20/+19
| | | | | When I added _PyInterpreterState_IsRunningMain() and friends last year, I tried to accommodate applications that embed Python but don't call _PyInterpreterState_SetRunningMain() (not that they're expected to). That mostly worked fine until my recent changes in gh-117049, where the subtleties with the fallback code led to failures; the change ended up breaking test_tools.test_freeze, which exercises a basic embedding situation. The simplest fix is to drop the fallback code I originally added to _PyInterpreterState_IsRunningMain() (and later to _PyThreadState_IsRunningMain()). I've kept the fallback in the _xxsubinterpreters module though. I've also updated Py_FrozenMain() to call _PyInterpreterState_SetRunningMain().
* gh-117045: Add code object to function version cache (#117028)Guido van Rossum2024-03-214-38/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | Changes to the function version cache: - In addition to the function object, also store the code object, and allow the latter to be retrieved even if the function has been evicted. - Stop assigning new function versions after a critical attribute (e.g. `__code__`) has been modified; the version is permanently reset to zero in this case. - Changes to `__annotations__` are no longer considered critical. (This fixes gh-109998.) Changes to the Tier 2 optimization machinery: - If we cannot map a function version to a function, but it is still mapped to a code object, we continue projecting the trace. The operand of the `_PUSH_FRAME` and `_POP_FRAME` opcodes can be either NULL, a function object, or a code object with the lowest bit set. This allows us to trace through code that calls an ephemeral function, i.e., a function that may not be alive when we are constructing the executor, e.g. a generator expression or certain nested functions. We will lose globals removal inside such functions, but we can still do other peephole operations (and even possibly [call inlining](https://github.com/python/cpython/pull/116290), if we decide to do it), which only need the code object. As before, if we cannot retrieve the code object from the cache, we stop projecting.
* gh-116522: Refactor `_PyThreadState_DeleteExcept` (#117131)Sam Gross2024-03-213-22/+31
| | | | | | | | | | | Split `_PyThreadState_DeleteExcept` into two functions: - `_PyThreadState_RemoveExcept` removes all thread states other than one passed as an argument. It returns the removed thread states as a linked list. - `_PyThreadState_DeleteList` deletes those dead thread states. It may call destructors, so we want to "start the world" before calling `_PyThreadState_DeleteList` to avoid potential deadlocks.
* gh-116996: Add pystats about _Py_uop_analyse_and_optimize (GH-116997)Michael Droettboom2024-03-212-2/+22
|
* gh-76785: Drop PyInterpreterID_Type (gh-117101)Eric Snow2024-03-211-5/+0
| | | I added it quite a while ago as a strategy for managing interpreter lifetimes relative to the PEP 554 (now 734) implementation. Relatively recently I refactored that implementation to no longer rely on InterpreterID objects. Thus now I'm removing it.
* gh-115754: Add Py_GetConstant() function (#116883)Victor Stinner2024-03-211-0/+4
| | | | | | | | | | | | Add Py_GetConstant() and Py_GetConstantBorrowed() functions. In the limited C API version 3.13, getting Py_None, Py_False, Py_True, Py_Ellipsis and Py_NotImplemented singletons is now implemented as function calls at the stable ABI level to hide implementation details. Getting these constants still return borrowed references. Add _testlimitedcapi/object.c and test_capi/test_object.py to test Py_GetConstant() and Py_GetConstantBorrowed() functions.
* gh-105716: Update interp->threads.main After Fork (gh-117049)Eric Snow2024-03-212-0/+39
| | | | | I missed this in gh-109921. We also update Py_Exit() to call _PyInterpreterState_SetNotRunningMain(), if necessary.
* gh-76785: Clean Up Interpreter ID Conversions (gh-117048)Eric Snow2024-03-211-24/+79
| | | Mostly we unify the two different implementations of the conversion code (from PyObject * to int64_t. We also drop the PyArg_ParseTuple()-style converter function, as well as rename and move PyInterpreterID_LookUp().
* gh-116522: Stop the world before fork() and during shutdown (#116607)Sam Gross2024-03-212-0/+9
| | | | | | | | | | | This changes the free-threaded build to perform a stop-the-world pause before deleting other thread states when forking and during shutdown. This fixes some crashes when using multiprocessing and during shutdown when running with `PYTHON_GIL=0`. This also changes `PyOS_BeforeFork` to acquire the runtime lock (i.e., `HEAD_LOCK(&_PyRuntime)`) before forking to ensure that data protected by the runtime lock (and not just the GIL or stop-the-world) is in a consistent state before forking.
* GH-117066: Tier 2 optimizer: Don't throw away good traces if we can't ↵Mark Shannon2024-03-203-8/+16
| | | | optimize them perfectly. (GH-117067)
* gh-116908: Only write to `_pending_calls.calls_to_do` with atomic operations ↵Brett Simmers2024-03-201-2/+2
| | | | | | (#117044) These writes to `pending->calls_to_do` need to be atomic, because other threads can read (atomically) from `calls_to_do` without holding `pending->mutex`.
* GH-108362: Incremental Cycle GC (GH-116206)Mark Shannon2024-03-204-321/+512
|
* gh-117041: Add "-X gil" in the Python CLI help (GH-117042)Serhiy Storchaka2024-03-191-0/+5
|
* gh-90300: Improve the Python CLI help output (GH-115853)Serhiy Storchaka2024-03-191-78/+40
| | | | | | | | | * document equivalent command-line options for all environment variables * document equivalent environment variables for all command-line options * reduce the size of variable and option descriptions to minimum * remove the ending period in single-sentence descriptions Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* GH-116017: Put JIT code and data on the same page (GH-116845)Brandt Bucher2024-03-191-29/+23
|
* gh-116808: Fix optimized trace length histogram (GH-116827)Michael Droettboom2024-03-191-1/+2
|
* gh-115756: make PyCode_GetFirstFree an unstable API (GH-115781)Bogdan Romanyuk2024-03-192-2/+2
|
* gh-108716: Cleanup remaining deepfreeze infrastructure (#116919)Guido van Rossum2024-03-182-34/+0
| | | | | Keep Tools/build/deepfreeze.py around (we may repurpose it for deepfreezing non-code objects), and keep basic "clean" targets that remove the output of former deep-freeze activities, to keep the build directories of current devs clean.
* gh-116916: Remove separate next_func_version counter (#116918)Guido van Rossum2024-03-181-1/+0
| | | | | Somehow we ended up with two separate counter variables tracking "the next function version". Most likely this was a historical accident where an old branch was updated incorrectly. This PR merges the two counters into a single one: `interp->func_state.next_version`.
* Cleanup tier2 debug output (#116920)Guido van Rossum2024-03-185-22/+50
| | | Various tweaks, including a slight refactor of the special cases for `_PUSH_FRAME`/`_POP_FRAME` to show the actual operand emitted.
* gh-63207: Use GetSystemTimePreciseAsFileTime() in time.time() (#116822)Victor Stinner2024-03-181-16/+22
|
* gh-116664: Ensure thread-safe dict access in _warnings (#116768)Erlend E. Aasland2024-03-181-29/+32
| | | Replace _PyDict_GetItemWithError() with PyDict_GetItemRef().
* gh-114271: Fix race in `Thread.join()` (#114839)mpage2024-03-162-48/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a race between when `Thread._tstate_lock` is released[^1] in `Thread._wait_for_tstate_lock()` and when `Thread._stop()` asserts[^2] that it is unlocked. Consider the following execution involving threads A, B, and C: 1. A starts. 2. B joins A, blocking on its `_tstate_lock`. 3. C joins A, blocking on its `_tstate_lock`. 4. A finishes and releases its `_tstate_lock`. 5. B acquires A's `_tstate_lock` in `_wait_for_tstate_lock()`, releases it, but is swapped out before calling `_stop()`. 6. C is scheduled, acquires A's `_tstate_lock` in `_wait_for_tstate_lock()` but is swapped out before releasing it. 7. B is scheduled, calls `_stop()`, which asserts that A's `_tstate_lock` is not held. However, C holds it, so the assertion fails. The race can be reproduced[^3] by inserting sleeps at the appropriate points in the threading code. To do so, run the `repro_join_race.py` from the linked repo. There are two main parts to this PR: 1. `_tstate_lock` is replaced with an event that is attached to `PyThreadState`. The event is set by the runtime prior to the thread being cleared (in the same place that `_tstate_lock` was released). `Thread.join()` blocks waiting for the event to be set. 2. `_PyInterpreterState_WaitForThreads()` provides the ability to wait for all non-daemon threads to exit. To do so, an `is_daemon` predicate was added to `PyThreadState`. This field is set each time a thread is created. `threading._shutdown()` now calls into `_PyInterpreterState_WaitForThreads()` instead of waiting on `_tstate_lock`s. [^1]: https://github.com/python/cpython/blob/441affc9e7f419ef0b68f734505fa2f79fe653c7/Lib/threading.py#L1201 [^2]: https://github.com/python/cpython/blob/441affc9e7f419ef0b68f734505fa2f79fe653c7/Lib/threading.py#L1115 [^3]: https://github.com/mpage/cpython/commit/81946532792f938cd6f6ab4c4ff92a4edf61314f --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Antoine Pitrou <antoine@python.org>
* gh-112536: Add TSAN builds on Github Actions (#116872)Donghee Na2024-03-161-0/+4
|
* GH-115802: Reduce the size of _INIT_CALL_PY_EXACT_ARGS. (GH-116856)Mark Shannon2024-03-153-72/+54
|
* gh-116735: Use `MISSING` for `CALL` event if argument is absent (GH-116737)Tian Gao2024-03-152-2/+2
|
* GH-116422: Modify a few uops so that they can be supported by tier 2 with ↵Mark Shannon2024-03-153-53/+45
| | | | hot/cold splitting (GH-116832)
* gh-111696, PEP 737: Add PyType_GetModuleName() function (#116824)Victor Stinner2024-03-141-2/+1
| | | Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* GH-116422: Factor out eval breaker checks at end of calls into its own ↵Mark Shannon2024-03-144-227/+327
| | | | micro-op. (GH-116817)
* gh-88494: Use QueryPerformanceCounter() for time.monotonic() (#116781)Victor Stinner2024-03-141-138/+73
| | | | | On Windows, time.monotonic() now uses the QueryPerformanceCounter() clock to have a resolution better than 1 us, instead of the gGetTickCount64() clock which has a resolution of 15.6 ms.
* gh-90300: Fix undocumented envvars in the Python CLI help (GH-116765)Serhiy Storchaka2024-03-141-0/+3
|
* Docs: fix spelling of the word 'transferring' (#116641)guangwu2024-03-131-3/+3
|
* gh-116760: Fix pystats for trace attempts (GH-116761)Michael Droettboom2024-03-133-2/+1
| | | | | | | | There are now at least two bytecodes that may attempt to optimize, JUMP_BACK, and more recently, COLD_EXIT. Only the JUMP_BACK was counting the attempt in the stats. This moves that counter to uop_optimize itself so it should always happen no matter where it is called from.
* gh-90300: Document equivalent -X options for envvars in the Python CLI help ↵Serhiy Storchaka2024-03-131-29/+31
| | | | (GH-116756)
* gh-90300: Sort the -X options and some envvars in the Python CLI help ↵Serhiy Storchaka2024-03-131-40/+43
| | | | (GH-116739)
* gh-90300: Fix cmdline.rst (GH-116721)Serhiy Storchaka2024-03-131-2/+2
| | | | * Fix the description of the "-b" option. * Add references to environment variables for "-s" and "-X dev" options.
* gh-115419: Change default sym to not_null (GH-116562)Ken Jin2024-03-132-90/+100
|
* gh-116626: Emit `CALL` events for all `INSTRUMENTED_CALL_FUNCTION_EX` ↵Tian Gao2024-03-132-28/+29
| | | | (GH-116627)