summaryrefslogtreecommitdiffstats
path: root/Include/cpython
Commit message (Collapse)AuthorAgeFilesLines
...
* gh-111140: PyLong_From/AsNativeBytes: Take *flags* rather than just ↵Steve Dower2024-04-051-5/+19
| | | | *endianness* (GH-116053)
* gh-116968: Reimplement Tier 2 counters (#117144)Guido van Rossum2024-04-042-14/+12
| | | | | | | | | | | | Introduce a unified 16-bit backoff counter type (``_Py_BackoffCounter``), shared between the Tier 1 adaptive specializer and the Tier 2 optimizer. The API used for adaptive specialization counters is changed but the behavior is (supposed to be) identical. The behavior of the Tier 2 counters is changed: - There are no longer dynamic thresholds (we never varied these). - All counters now use the same exponential backoff. - The counter for ``JUMP_BACKWARD`` starts counting down from 16. - The ``temperature`` in side exits starts counting down from 64.
* GH-115776: Embed the values array into the object, for "normal" Python ↵Mark Shannon2024-04-021-2/+1
| | | | objects. (GH-116115)
* gh-117411: move PyFutureFeatures to pycore_symtable.h and make it private ↵Irit Katriel2024-04-021-20/+0
| | | | (#117412)
* GH-116422: Tier2 hot/cold splitting (GH-116813)Mark Shannon2024-03-261-2/+49
| | | | | 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-251-2/+2
| | | | Fixes a compilation error when configured with `--enable-pystats`, an array size issue, and an unused variable.
* gh-116936: Add PyType_GetModuleByDef() to the limited C API (#116937)Victor Stinner2024-03-251-1/+0
|
* gh-117008: Fix functools test_recursive_pickle() (#117009)Victor Stinner2024-03-231-0/+2
| | | | | | | Use support.infinite_recursion() in test_recursive_pickle() of test_functools to prevent a stack overflow on "ARM64 Windows Non-Debug" buildbot. Lower Py_C_RECURSION_LIMIT to 1,000 frames on Windows ARM64.
* gh-113024: C API: Add PyObject_GenericHash() function (GH-113025)Serhiy Storchaka2024-03-221-0/+1
|
* gh-71052: Add Android build script and instructions (#116426)Malcolm Smith2024-03-211-0/+4
|
* gh-116996: Add pystats about _Py_uop_analyse_and_optimize (GH-116997)Michael Droettboom2024-03-211-1/+6
|
* gh-76785: Drop PyInterpreterID_Type (gh-117101)Eric Snow2024-03-211-14/+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-76785: Clean Up Interpreter ID Conversions (gh-117048)Eric Snow2024-03-211-1/+4
| | | 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-115756: make PyCode_GetFirstFree an unstable API (GH-115781)Bogdan Romanyuk2024-03-191-1/+5
|
* gh-116941: Fix pyatomic_std.h syntax errors (#116967)Sam Gross2024-03-181-0/+2
|
* gh-116869: Make C API compatible with ISO C90 (#116950)Victor Stinner2024-03-181-1/+2
| | | | Make the C API compatible with -Werror=declaration-after-statement compiler flag again.
* gh-116869: Fix redefinition of the _PyOptimizerObject type (#116963)Victor Stinner2024-03-181-2/+2
| | | | | | | | | | | | | | | Defining a type twice is a C11 feature and so makes the C API incompatible with C99. Fix the issue by only defining the type once. Example of warning (treated as an error): In file included from Include/Python.h:122: Include/cpython/optimizer.h:77:3: error: redefinition of typedef '_PyOptimizerObject' is a C11 feature [-Werror,-Wtypedef-redefinition] } _PyOptimizerObject; ^ build/Include/cpython/optimizer.h:60:35: note: previous definition is here typedef struct _PyOptimizerObject _PyOptimizerObject; ^
* gh-116809: Restore removed _PyErr_ChainExceptions1() function (#116900)Victor Stinner2024-03-161-0/+4
|
* gh-114271: Fix race in `Thread.join()` (#114839)mpage2024-03-161-26/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-116167: Allow disabling the GIL with `PYTHON_GIL=0` or `-X gil=0` (#116338)Brett Simmers2024-03-111-0/+3
| | | | | | | | | In free-threaded builds, running with `PYTHON_GIL=0` will now disable the GIL. Follow-up issues track work to re-enable the GIL when loading an incompatible extension, and to disable the GIL by default. In order to support re-enabling the GIL at runtime, all GIL-related data structures are initialized as usual, and disabling the GIL simply sets a flag that causes `take_gil()` and `drop_gil()` to return early.
* gh-111389: expose PyHASH_INF/BITS/MODULUS/IMAG macros as public (#111418)Sergey B Kirpichev2024-03-091-5/+11
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* chore: fix typos (#116345)cui fliter2024-03-051-1/+1
| | | Signed-off-by: cui fliter <imcusg@gmail.com>
* GH-115802: JIT "small" code for Windows (GH-115964)Brandt Bucher2024-02-291-3/+0
|
* gh-115168: Add pystats counter for invalidated executors (GH-115169)Michael Droettboom2024-02-262-2/+3
|
* gh-113706: Update comment about long int representation (#113707)Michael Droettboom2024-02-261-10/+21
|
* gh-112075: Make PyDictKeysObject thread-safe (#114741)Dino Viehland2024-02-214-1/+53
| | | Adds locking for shared PyDictKeysObject's for dictionaries
* gh-112175: Add `eval_breaker` to `PyThreadState` (#115194)Brett Simmers2024-02-201-0/+5
| | | | | | | | | | | This change adds an `eval_breaker` field to `PyThreadState`. The primary motivation is for performance in free-threaded builds: with thread-local eval breakers, we can stop a specific thread (e.g., for an async exception) without interrupting other threads. The source of truth for the global instrumentation version is stored in the `instrumentation_version` field in PyInterpreterState. Threads usually read the version from their local `eval_breaker`, where it continues to be colocated with the eval breaker bits.
* GH-112354: Initial implementation of warm up on exits and trace-stitching ↵Mark Shannon2024-02-202-6/+21
| | | | (GH-114142)
* gh-115103: Implement delayed memory reclamation (QSBR) (#115180)Sam Gross2024-02-164-1/+57
| | | | | | This adds a safe memory reclamation scheme based on FreeBSD's "GUS" and quiescent state based reclamation (QSBR). The API provides a mechanism for callers to detect when it is safe to free memory that may be concurrently accessed by readers.
* gh-114271: Make `thread._rlock` thread-safe in free-threaded builds (#115102)mpage2024-02-164-0/+46
| | | | | | | | | The ID of the owning thread (`rlock_owner`) may be accessed by multiple threads without holding the underlying lock; relaxed atomics are used in place of the previous loads/stores. The number of times that the lock has been acquired (`rlock_count`) is only ever accessed by the thread that holds the lock; we do not need to use atomics to access it.
* gh-102013: Move PyUnstable_GC_VisitObjects() to Include/cpython/objimpl.h ↵Victor Stinner2024-02-161-0/+17
| | | | | | (#115560) Include/objimpl.h must only contain the limited C API, whereas PyUnstable_GC_VisitObjects() is excluded from the limited C API.
* gh-113743: Make the MRO cache thread-safe in free-threaded builds (#113930)Dino Viehland2024-02-154-0/+24
| | | | | | | Makes _PyType_Lookup thread safe, including: Thread safety of the underlying cache. Make mutation of mro and type members thread safe Also _PyType_GetMRO and _PyType_GetBases are currently returning borrowed references which aren't safe.
* gh-114570: Add PythonFinalizationError exception (#115352)Victor Stinner2024-02-141-0/+2
| | | | | | | | | | | | | | | | | Add PythonFinalizationError exception. This exception derived from RuntimeError is raised when an operation is blocked during the Python finalization. The following functions now raise PythonFinalizationError, instead of RuntimeError: * _thread.start_new_thread() * subprocess.Popen * os.fork() * os.fork1() * os.forkpty() Morever, _winapi.Overlapped finalizer now logs an unraisable PythonFinalizationError, instead of an unraisable RuntimeError.
* GH-113710: Backedge counter improvements. (GH-115166)Mark Shannon2024-02-131-3/+7
|
* gh-114058: Foundations of the Tier2 redundancy eliminator (GH-115085)Ken Jin2024-02-131-0/+3
| | | | | | | --------- Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com> Co-authored-by: Jules <57632293+JuliaPoo@users.noreply.github.com> Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com>
* gh-111140: Adds PyLong_AsNativeBytes and PyLong_FromNative[Unsigned]Bytes ↵Steve Dower2024-02-121-1/+35
| | | | functions (GH-114886)
* gh-110850: Add PyTime_t C API (GH-115215)Petr Viktorin2024-02-121-0/+23
| | | | | | | | | | | | * gh-110850: Add PyTime_t C API Add PyTime_t API: * PyTime_t type. * PyTime_MIN and PyTime_MAX constants. * PyTime_AsSecondsDouble(), PyTime_Monotonic(), PyTime_PerfCounter() and PyTime_GetSystemClock() functions. Co-authored-by: Victor Stinner <vstinner@python.org>
* GH-113710: Fix updating of dict version tag and add watched dict stats ↵Mark Shannon2024-02-121-0/+3
| | | | (GH-115221)
* GH-114695: Add `sys._clear_internal_caches` (GH-115152)Brandt Bucher2024-02-121-1/+2
|
* gh-112066: Add `PyDict_SetDefaultRef` function. (#112123)Sam Gross2024-02-061-0/+10
| | | | | | | The `PyDict_SetDefaultRef` function is similar to `PyDict_SetDefault`, but returns a strong reference through the optional `**result` pointer instead of a borrowed reference. Co-authored-by: Petr Viktorin <encukou@gmail.com>
* GH-113462: Limit the number of versions that a single class can use. (GH-114900)Mark Shannon2024-02-051-0/+1
|
* GH-113710: Add a "globals to constants" pass (GH-114592)Mark Shannon2024-02-022-1/+10
| | | Converts specializations of `LOAD_GLOBAL` into constants during tier 2 optimization.
* GH-113655 Lower C recursion limit from 4000 to 3000 on Windows. (GH-114896)Mark Shannon2024-02-021-1/+1
|
* GH-113464: Add a JIT backend for tier 2 (GH-113465)Brandt Bucher2024-01-291-0/+2
| | | | | | | Add an option (--enable-experimental-jit for configure-based builds or --experimental-jit for PCbuild-based ones) to build an *experimental* just-in-time compiler, based on copy-and-patch (https://fredrikbk.com/publications/copy-and-patch.pdf). See Tools/jit/README.md for more information on how to install the required build-time tooling.
* gh-112087: Make list_repr and list_length to be thread-safe (gh-114582)Donghee Na2024-01-261-0/+4
|
* gh-114312: Collect stats for unlikely events (GH-114493)Michael Droettboom2024-01-251-0/+14
|
* GH-114456: lower the recursion limit under WASI for debug builds (GH-114457)Brett Cannon2024-01-231-4/+7
| | | Testing under wasmtime 16.0.0 w/ code from https://github.com/python/cpython/issues/114413 is how the value was found.
* gh-111964: Implement stop-the-world pauses (gh-112471)Sam Gross2024-01-231-1/+1
| | | | | | | | | | | | | | | | | The `--disable-gil` builds occasionally need to pause all but one thread. Some examples include: * Cyclic garbage collection, where this is often called a "stop the world event" * Before calling `fork()`, to ensure a consistent state for internal data structures * During interpreter shutdown, to ensure that daemon threads aren't accessing Python objects This adds the following functions to implement global and per-interpreter pauses: * `_PyEval_StopTheWorldAll()` and `_PyEval_StartTheWorldAll()` (for the global runtime) * `_PyEval_StopTheWorld()` and `_PyEval_StartTheWorld()` (per-interpreter) (The function names may change.) These functions are no-ops outside of the `--disable-gil` build.
* GH-113655: Lower the C recursion limit on various platforms (GH-113944)Mark Shannon2024-01-161-2/+6
|
* GH-113860: Get rid of `_PyUOpExecutorObject` (GH-113954)Brandt Bucher2024-01-121-1/+8
|