summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_code.h
Commit message (Collapse)AuthorAgeFilesLines
* Revert "gh-133395: add option for extension modules to specialize ↵Irit Katriel2025-05-061-7/+2
| | | | BINARY_OP/SUBSCR, apply to arrays (#133396)" (#133498)
* gh-132775: Revert "gh-132775: Add _PyCode_VerifyStateless() (gh-133221)" ↵Petr Viktorin2025-05-061-41/+0
| | | | (#133497)
* Remove duplicate includes: Include/internal/ (#132624)Adam Turner2025-05-061-2/+0
|
* gh-132775: Add _PyCode_VerifyStateless() (gh-133221)Eric Snow2025-05-051-0/+41
| | | | | | | | "Stateless" code is a function or code object which does not rely on external state or internal state. It may rely on arguments and builtins, but not globals or a closure. I've left a comment in pycore_code.h that provides more detail. We also add _PyFunction_VerifyStateless(). The new functions will be used in several later changes that facilitate "sharing" functions and code objects between interpreters.
* gh-132775: Unrevert "Add _PyCode_GetVarCounts()" (gh-133265)Eric Snow2025-05-051-0/+51
| | | | | | This reverts commit 811edcf (gh-133232), which itself reverted the original commit 811edcf (gh-133128). We reverted the original change due to failing s390 builds (a big-endian architecture). It ended up that I had not accommodated op caches.
* gh-133395: add option for extension modules to specialize BINARY_OP/SUBSCR, ↵Irit Katriel2025-05-051-2/+7
| | | | apply to arrays (#133396)
* Revert "gh-132775: Add _PyCode_GetVarCounts() (gh-133128)" (gh-133232)Eric Snow2025-05-011-51/+0
| | | | | The change broke the s390 builds, so I'm reverting it while I investigate. This reverts commit 94b4fcd806e7b692955173d309ea3b70a193ad96.
* gh-132775: Add _PyCode_GetVarCounts() (gh-133128)Eric Snow2025-04-301-0/+51
| | | | | | | This helper is useful in a variety of ways, including in demonstrating how the different counts relate to one another. It will be used in a later change to help identify if a function is "stateless", meaning it doesn't have any free vars or globals. Note that a majority of this change is tests.
* GH-132554: Add stats for GET_ITER (GH-132592)Mark Shannon2025-04-291-0/+1
| | | | | | | * Add stats for GET_ITER * Look for common iterable types, not iterator types * Add stats for self iter and fix naming in summary
* gh-87859: Track Code Object Local Kinds For Arguments (gh-132980)Eric Snow2025-04-291-6/+8
| | | | | Doing this was always the intention. I was finally motivated to find the time to do it. See #87859 (comment).
* gh-132775: Add _PyCode_ReturnsOnlyNone() (gh-132981)Eric Snow2025-04-291-0/+4
| | | | | The function indicates whether or not the function has a return statement. This is used by a later change related treating some functions like scripts.
* gh-131238: Remove includes from pycore_interp.h (#131495)Victor Stinner2025-03-201-2/+1
| | | Remove also now unused includes in C files.
* gh-131238: Remove pycore_lock.h includes (#131483)Victor Stinner2025-03-191-1/+0
| | | | PyMutex type is now part of <Python.h>, it's no longer needed to include <pycore_lock.h> to get it.
* GH-131238: More refactoring of core header files (GH-131351)Mark Shannon2025-03-171-62/+0
| | | | Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
* GH-131238: Core header refactor (GH-131250)Mark Shannon2025-03-171-32/+1
| | | | | * Moves most structs in pycore_ header files into pycore_structs.h and pycore_runtime_structs.h * Removes many cross-header dependencies
* gh-131306: Remove unused code related to `BINARY_SUBSCR` (#131307)Tomas R.2025-03-161-6/+0
|
* docs: internal notes have moved, correct references (#130762)Ned Batchelder2025-03-031-1/+1
|
* gh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR ↵Irit Katriel2025-02-071-2/+1
| | | | (#129700)
* GH-128842: Collect JIT memory stats (GH-128941)Diego Russo2025-02-021-0/+2
|
* Revert "GH-128914: Remove conditional stack effects from `bytecodes.c` and ↵Sam Gross2025-01-231-2/+0
| | | | | | | the code generators (GH-128918)" (GH-129202) The commit introduced a ~2.5-3% regression in the free threading build. This reverts commit ab61d3f4303d14a413bc9ae6557c730ffdf7579e.
* GH-128914: Remove conditional stack effects from `bytecodes.c` and the code ↵Mark Shannon2025-01-201-0/+2
| | | | generators (GH-128918)
* gh-100239: specialize long tail of binary operations (#128722)Irit Katriel2025-01-161-1/+12
|
* GH-122548: Implement branch taken and not taken events for sys.monitoring ↵Mark Shannon2024-12-191-0/+2
| | | | (GH-122564)
* gh-127411: Fix invalid conversion of load of TLBC array when compiled in C++ ↵mpage2024-12-021-1/+8
| | | | | (#127466) Cast the result of the load to the correct type
* gh-115999: Implement thread-local bytecode and enable specialization for ↵mpage2024-11-041-0/+41
| | | | | | | | | `BINARY_OP` (#123926) Each thread specializes a thread-local copy of the bytecode, created on the first RESUME, in free-threaded builds. All copies of the bytecode for a code object are stored in the co_tlbc array on the code object. Threads reserve a globally unique index identifying its copy of the bytecode in all co_tlbc arrays at thread creation and release the index at thread destruction. The first entry in every co_tlbc array always points to the "main" copy of the bytecode that is stored at the end of the code object. This ensures that no bytecode is copied for programs that do not use threads. Thread-local bytecode can be disabled at runtime by providing either -X tlbc=0 or PYTHON_TLBC=0. Disabling thread-local bytecode also disables specialization. Concurrent modifications to the bytecode made by the specializing interpreter and instrumentation use atomics, with specialization taking care not to overwrite an instruction that was instrumented concurrently.
* gh-123747: Avoid static_assert() in internal header files (#123779)Victor Stinner2024-09-061-2/+3
|
* GH-123197: Only count an instruction as deferred if it hasn't deopted first. ↵Mark Shannon2024-08-221-0/+2
| | | | | (GH-123222) Only count an instruction as deferred if hasn't deopted first.
* GH-118093: Make `CALL_ALLOC_AND_ENTER_INIT` suitable for tier 2. (GH-123140)Mark Shannon2024-08-201-0/+4
| | | | | * Convert CALL_ALLOC_AND_ENTER_INIT to micro-ops such that tier 2 supports it * Allow inexact arguments for CALL_ALLOC_AND_ENTER_INIT.
* GH-118093: Specialize `CALL_KW` (GH-123006)Mark Shannon2024-08-161-0/+3
|
* GH-122390: Replace `_Py_GetbaseOpcode` with `_Py_GetBaseCodeUnit` (GH-122942)Mark Shannon2024-08-131-1/+1
|
* gh-120642: Move _PyCode_CODE() to the internal C API (#121644)Victor Stinner2024-07-131-0/+3
| | | | Move _PyCode_CODE() and _PyCode_NBYTES() macros to the internal C API since they use _Py_CODEUNIT which is only part of the internal C API.
* GH-116017: Get rid of _COLD_EXITs (GH-120960)Brandt Bucher2024-07-011-1/+1
|
* gh-117139: Convert the evaluation stack to stack refs (#118450)Ken Jin2024-06-261-14/+15
| | | | | | | | | | | | | | | | | This PR sets up tagged pointers for CPython. The general idea is to create a separate struct _PyStackRef for everything on the evaluation stack to store the bits. This forces the C compiler to warn us if we try to cast things or pull things out of the struct directly. Only for free threading: We tag the low bit if something is deferred - that means we skip incref and decref operations on it. This behavior may change in the future if Mark's plans to defer all objects in the interpreter loop pans out. This implies a strict stack reference discipline is required. ALL incref and decref operations on stackrefs must use the stackref variants. It is unsafe to untag something then do normal incref/decref ops on it. The new incref and decref variants are called dup and close. They mimic a "handle" API operating on these stackrefs. Please read Include/internal/pycore_stackref.h for more information! --------- Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
* gh-120642: Move private PyCode APIs to the internal C API (#120643)Victor Stinner2024-06-261-0/+44
| | | | | | | | | | | | | | | * Move _Py_CODEUNIT and related functions to pycore_code.h. * Move _Py_BackoffCounter to pycore_backoff.h. * Move Include/cpython/optimizer.h content to pycore_optimizer.h. * Remove Include/cpython/optimizer.h. * Remove PyUnstable_Replace_Executor(). Rename functions: * PyUnstable_GetExecutor() => _Py_GetExecutor() * PyUnstable_GetOptimizer() => _Py_GetOptimizer() * PyUnstable_SetOptimizer() => _Py_SetTier2Optimizer() * PyUnstable_Optimizer_NewCounter() => _PyOptimizer_NewCounter() * PyUnstable_Optimizer_NewUOpOptimizer() => _PyOptimizer_NewUOpOptimizer()
* gh-118527: Intern code consts in free-threaded build (#118667)Sam Gross2024-05-071-0/+10
| | | | | | We already intern and immortalize most string constants. In the free-threaded build, other constants can be a source of reference count contention because they are shared by all threads running the same code objects.
* Remove more remnants of deepfreeze (#118159)Guido van Rossum2024-04-221-5/+0
|
* gh-115178: Add Counts of UOp Pairs to pystats (GH-115181)Jeff Glass2024-04-161-0/+8
|
* gh-116968: Reimplement Tier 2 counters (#117144)Guido van Rossum2024-04-041-37/+27
| | | | | | | | | | | | 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-1/+4
| | | | objects. (GH-116115)
* gh-116996: Add pystats about _Py_uop_analyse_and_optimize (GH-116997)Michael Droettboom2024-03-211-0/+2
|
* gh-116381: Specialize CONTAINS_OP (GH-116385)Ken Jin2024-03-061-0/+7
| | | | | | | | | | | * Specialize CONTAINS_OP * 📜🤖 Added by blurb_it. * Add PyAPI_FUNC for JIT --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-115999: Disable the specializing adaptive interpreter in free-threaded ↵Brett Simmers2024-03-011-0/+5
| | | | | builds (#116013) For now, disable all specialization when the GIL might be disabled.
* gh-76785: Improved Subinterpreters Compatibility with 3.12 (gh-115424)Eric Snow2024-02-131-0/+9
| | | | | For the most part, these changes make is substantially easier to backport subinterpreter-related code to 3.12, especially the related modules (e.g. _xxsubinterpreters). The main motivation is to support releasing a PyPI package with the 3.13 capabilities compiled for 3.12. A lot of the changes here involve either hiding details behind macros/functions or splitting up some files.
* gh-114312: Collect stats for unlikely events (GH-114493)Michael Droettboom2024-01-251-0/+2
|
* gh-106550: Fix sign conversion in pycore_code.h (#112613)Victor Stinner2023-12-041-10/+12
| | | | Fix sign conversion in pycore_code.h: use unsigned integers and cast explicitly when needed.
* gh-111652: Fix --enable-pystats build (GH-111653)Michael Droettboom2023-11-031-0/+2
|
* gh-109329: Count tier2 opcode misses (#110561)Michael Droettboom2023-10-311-2/+2
| | | This keeps a separate 'miss' counter for each micro-opcode, incremented whenever a guard uop takes a deoptimization side exit.
* GH-109329: Add tier 2 stats (GH-109913)Michael Droettboom2023-10-041-0/+15
|
* GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300)Brandt Bucher2023-09-131-1/+1
|
* GH-108716: Turn off deep-freezing of code objects. (GH-108722)Mark Shannon2023-09-081-2/+0
|