summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* gh-115178: Add Counts of UOp Pairs to pystats (GH-115181)Jeff Glass2024-04-162-0/+11
|
* gh-117657: Quiet more TSAN warnings due to incorrect modeling of ↵mpage2024-04-151-2/+2
| | | | compare/exchange (#117830)
* gh-117657: Quiet TSAN warning about a data race between `start_the_world()` ↵mpage2024-04-151-1/+2
| | | | | | | | and `tstate_try_attach()` (#117828) TSAN erroneously reports a data race between the `_Py_atomic_compare_exchange_int` on `tstate->state` in `tstate_try_attach()` and the non-atomic load of `tstate->state` in `start_the_world`. The `_Py_atomic_compare_exchange_int` fails, but TSAN erroneously treats it as a store.
* gh-117376: Partial implementation of deferred reference counting (#117696)Sam Gross2024-04-121-1/+18
| | | | | This marks objects as using deferred refrence counting using the `ob_gc_bits` field in the free-threaded build and collects those objects during GC.
* gh-117764: Fix and add signatures for many builtins (GH-117769)Serhiy Storchaka2024-04-124-17/+17
|
* gh-117764: Add signatures for some functions in the sys module (GH-117770)Serhiy Storchaka2024-04-122-35/+73
| | | Use Argument Clinic if possible.
* gh-76785: Handle Legacy Interpreters Properly (gh-117490)Eric Snow2024-04-112-14/+30
| | | This is similar to the situation with threading._DummyThread. The methods (incl. __del__()) of interpreters.Interpreter objects must be careful with interpreters not created by interpreters.create(). The simplest thing to start with is to disable any method that modifies or runs in the interpreter. As part of this, the runtime keeps track of where an interpreter was created. We also handle interpreter "refcounts" properly.
* gh-117649: Raise ImportError for unsupported modules in free-threaded build ↵Sam Gross2024-04-112-1/+19
| | | | | | | | | | (#117651) The free-threaded build does not currently support the combination of single-phase init modules and non-isolated subinterpreters. Ensure that `check_multi_interp_extensions` is always `True` for subinterpreters in the free-threaded build so that importing these modules raises an `ImportError`.
* gh-76785: Add More Tests to test_interpreters.test_api (gh-117662)Eric Snow2024-04-114-15/+299
| | | In addition to the increase test coverage, this is a precursor to sorting out how we handle interpreters created directly via the C-API.
* gh-107674: Remove some unnecessary code in instrumentation code (GH-117393)Tian Gao2024-04-091-1/+1
|
* gh-117439: Make refleak checking thread-safe without the GIL (#117469)Sam Gross2024-04-082-2/+10
| | | | | This keeps track of the per-thread total reference count operations in PyThreadState in the free-threaded builds. The count is merged into the interpreter's total when the thread exits.
* gh-111926: Make weakrefs thread-safe in free-threaded builds (#117168)mpage2024-04-081-0/+9
| | | | | | | | | Most mutable data is protected by a striped lock that is keyed on the referenced object's address. The weakref's hash is protected using the weakref's per-object lock. Note that this only affects free-threaded builds. Apart from some minor refactoring, the added code is all either gated by `ifdef`s or is a no-op (e.g. `Py_BEGIN_CRITICAL_SECTION`).
* GH-117512: Allow 64-bit JIT operands on 32-bit platforms (GH-117527)Brandt Bucher2024-04-061-28/+34
|
* gh-117457: Regen executor cases post PR #117477 (#117559)Erlend E. Aasland2024-04-051-2/+8
|
* GH-117457: Correct pystats uop "miss" counts (GH-117477)Michael Droettboom2024-04-042-136/+536
|
* gh-112075: Make _PyDict_LoadGlobal thread safe (#117529)Dino Viehland2024-04-043-3/+0
| | | Make _PyDict_LoadGlobal threadsafe
* gh-117494: extract the Instruction Sequence data structure into a separate ↵Irit Katriel2024-04-044-180/+196
| | | | file (#117496)
* gh-116968: Reimplement Tier 2 counters (#117144)Guido van Rossum2024-04-048-171/+117
| | | | | | | | | | | | 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-116168: Remove extra `_CHECK_STACK_SPACE` uops (#117242)Peter Lazorchak2024-04-034-17/+104
| | | This merges all `_CHECK_STACK_SPACE` uops in a trace into a single `_CHECK_STACK_SPACE_OPERAND` uop that checks whether there is enough stack space for all calls included in the entire trace.
* gh-76785: Raise InterpreterError, Not RuntimeError (gh-117489)Eric Snow2024-04-033-6/+22
| | | | | I had meant to switch everything to InterpreterError when I added it a while back. At the time I missed a few key spots. As part of this, I've added print-the-exception to _PyXI_InitTypes() and fixed an error case in `_PyStaticType_InitBuiltin().
* gh-76785: Fix a Refleak in _interpreters.new_config() (gh-117491)Eric Snow2024-04-031-0/+2
| | | This is a follow-up to gh-117170 and gh-117485.
* gh-76785: Add PyInterpreterConfig Helpers (gh-117170)Eric Snow2024-04-023-22/+305
| | | These helpers make it easier to customize and inspect the config used to initialize interpreters. This is especially valuable in our tests. I found inspiration from the PyConfig API for the PyInterpreterConfig dict conversion stuff. As part of this PR I've also added a bunch of tests.
* Fix successor opcode name printing in Tier 2 DEOPT debug message (#117471)Guido van Rossum2024-04-021-1/+1
|
* GH-115776: Embed the values array into the object, for "normal" Python ↵Mark Shannon2024-04-027-110/+106
| | | | objects. (GH-116115)
* gh-117411: move PyFutureFeatures to pycore_symtable.h and make it private ↵Irit Katriel2024-04-026-15/+16
| | | | (#117412)
* Silence compiler warnings in gc.c (#117422)Guido van Rossum2024-04-011-0/+3
|
* gh-91565: Replace bugs.python.org links with Devguide/GitHub ones (GH-91568)Steve (Gadget) Barnes2024-04-011-1/+1
| | | | | | Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
* gh-117303: Don't detach in `PyThreadState_DeleteCurrent()` (#117304)Sam Gross2024-03-291-2/+0
| | | | | | | | | | | This fixes a crash in `test_threading.test_reinit_tls_after_fork()` when running with the GIL disabled. We already properly handle the case where the thread state is `_Py_THREAD_ATTACHED` in `tstate_delete_common()` -- we just need to remove an assertion. Keeping the thread attached means that a stop-the-world pause, such as for a `fork()`, won't commence until we remove our thread state from the interpreter's linked list. This prevents a crash when the child process tries to clean up the dead thread states.
* gh-116664: In _warnings.c, make filters_version access thread-safe (#117374)Erlend E. Aasland2024-03-291-6/+9
| | | | - assert that the lock is held in already_warned() - protect 'filters_version' increment in warnings_filters_mutated_impl()
* gh-117300: Use stop the world to make `sys._current_frames` and ↵Sam Gross2024-03-291-0/+4
| | | | | | | | | | `sys._current_exceptions` thread-safe. (#117301) This adds a stop the world pause to make the two functions thread-safe when the GIL is disabled in the free-threaded build. Additionally, the main test thread may call `sys._current_exceptions()` as soon as `g_raised.set()` is called. The background thread may not yet reach the `leave_g.wait()` line.
* gh-117323: Make `cell` thread-safe in free-threaded builds (#117330)Sam Gross2024-03-294-36/+23
| | | Use critical sections to lock around accesses to cell contents. The critical sections are no-ops in the default (with GIL) build.
* gh-112529: Don't untrack tuples or dicts with zero refcount (#117370)Sam Gross2024-03-291-15/+18
| | | | | | | | The free-threaded GC sometimes sees objects with zero refcount. This can happen due to the delay in merging biased reference counting fields, and, in the future, due to deferred reference counting. We should not untrack these objects or they will never be collected. This fixes the refleaks in the free-threaded build.
* gh-116664: Fix unused var warnings in _warnings.c in non-free-threaded ↵Erlend E. Aasland2024-03-291-0/+8
| | | | | builds (#117373) The warnings were introduced by commit c1712ef06.
* GH-117121: Add pystats to JIT builds (GH-117346)Michael Droettboom2024-03-282-1/+3
|
* gh-116664: Make module state Py_SETREF's in _warnings thread-safe (#116959)Erlend E. Aasland2024-03-281-21/+37
| | | | | | Mark the swap operations as critical sections. Add an internal Py_BEGIN_CRITICAL_SECTION_MUT API that takes a PyMutex pointer instead of a PyObject pointer.
* 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.