summaryrefslogtreecommitdiffstats
path: root/Include/cpython/code.h
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-120642: Move private PyCode APIs to the internal C API (#120643) ↵Victor Stinner2024-06-261-52/+0
| | | | | | | | | | | | | | | | | | | | | (#121043) gh-120642: Move private PyCode APIs to the internal C API (#120643) * 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() (cherry picked from commit 9e4a81f00fef689c6e18a64245aa064eaadc7ac7)
* gh-116767: fix crash on 'async with' with many context managers (GH-118348)Irit Katriel2024-05-011-1/+1
| | | | | | | Account for `add_stopiteration_handler` pushing a block for `async with`. To allow generator functions that previously almost hit the `CO_MAXBLOCKS` limit by nesting non-async blocks, the limit is increased by 1. This increase allows one more block in non-generator functions.
* gh-116968: Reimplement Tier 2 counters (#117144)Guido van Rossum2024-04-041-0/+11
| | | | | | | | | | | | 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-115756: make PyCode_GetFirstFree an unstable API (GH-115781)Bogdan Romanyuk2024-03-191-1/+5
|
* chore: fix typos (#116345)cui fliter2024-03-051-1/+1
| | | Signed-off-by: cui fliter <imcusg@gmail.com>
* GH-113486: Do not emit spurious PY_UNWIND events for optimized calls to ↵Mark Shannon2024-01-051-0/+2
| | | | classes. (GH-113680)
* GH-109369: Merge all eval-breaker flags and monitoring version into one ↵Mark Shannon2023-10-041-1/+1
| | | | word. (GH-109846)
* GH-108390: Prevent non-local events being set with ↵Mark Shannon2023-09-051-6/+11
| | | | `sys.monitoring.set_local_events()` (GH-108420)
* GH-106897: Add `RERAISE` event to `sys.monitoring`. (GH-107291)Mark Shannon2023-07-271-2/+2
| | | * Ensures that exception handling events are balanced. Each [re]raise event has a matching unwind/handled event.
* GH-103082: Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS (#107069)Victor Stinner2023-07-221-3/+3
| | | | | | Rename private C API constants: * Rename PY_MONITORING_UNGROUPED_EVENTS to _PY_MONITORING_UNGROUPED_EVENTS * Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS
* GH-104584: Plugin optimizer API (GH-105100)Mark Shannon2023-06-021-0/+8
|
* GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython ↵Mark Shannon2023-04-121-2/+43
| | | | | | | | | | (GH-103083) * The majority of the monitoring code is in instrumentation.c * The new instrumentation bytecodes are in bytecodes.c * legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
* gh-102381: don't call watcher callback with dead object (#102382)Carl Meyer2023-03-081-4/+9
| | | Co-authored-by: T. Wouters <thomas@python.org>
* gh-101101: Unstable C API tier (PEP 689) (GH-101102)Petr Viktorin2023-02-281-8/+39
|
* gh-101907: Stop using `_Py_OPCODE` and `_Py_OPARG` macros (GH-101912)Steve Dower2023-02-201-7/+21
| | | | | | * gh-101907: Removes use of non-standard C++ extension from Include/cpython/code.h * Make cases_generator correct on Windows
* GH-100719: Remove the `co_nplaincellvars` field from code objects. (GH-100721)Mark Shannon2023-01-041-1/+5
|
* GH-100222: fix typo _py_set_opocde -> _py_set_opcode (GH-100259)Carl Meyer2022-12-151-1/+1
| | | | | Typo introduced in #100223. Automerge-Triggered-By: GH:brandtbucher
* GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code ↵Mark Shannon2022-12-141-14/+17
| | | | unit. (GH-100223)
* GH-98522: Add version number to code objects. (GH-98525)Mark Shannon2022-12-091-0/+1
| | | | | | * Add version number to code object for better versioning of functions. * Improves specialization for closures and list comprehensions.
* GH-91054: Add code object watchers API (GH-99859)Itamar Ostricher2022-12-021-0/+35
| | | | | | * Add API to allow extensions to set callback function on creation and destruction of PyCodeObject Co-authored-by: Ye11ow-Flash <janshah@cs.stonybrook.edu>
* Use _Py_RVALUE() in macros (#99844)Victor Stinner2022-11-281-1/+1
| | | | | | | | | | | | | | The following macros are modified to use _Py_RVALUE(), so they can no longer be used as l-value: * DK_LOG_SIZE() * _PyCode_CODE() * _PyList_ITEMS() * _PyTuple_ITEMS() * _Py_SLIST_HEAD() * _Py_SLIST_ITEM_NEXT() _PyCode_CODE() is private and other macros are part of the internal C API.
* gh-89653: PEP 670: Convert macros to functions (#99843)Victor Stinner2022-11-281-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert macros to static inline functions to avoid macro pitfalls, like duplication of side effects: * DK_ENTRIES() * DK_UNICODE_ENTRIES() * PyCode_GetNumFree() * PyFloat_AS_DOUBLE() * PyInstanceMethod_GET_FUNCTION() * PyMemoryView_GET_BASE() * PyMemoryView_GET_BUFFER() * PyMethod_GET_FUNCTION() * PyMethod_GET_SELF() * PySet_GET_SIZE() * _PyHeapType_GET_MEMBERS() Changes: * PyCode_GetNumFree() casts PyCode_GetNumFree.co_nfreevars from int to Py_ssize_t to be future proof, and because Py_ssize_t is commonly used in the C API. * PyCode_GetNumFree() doesn't cast its argument: the replaced macro already required the exact type PyCodeObject*. * Add assertions in some functions using "CAST" macros to check the arguments type when Python is built with assertions (debug build). * Remove an outdated comment in unicodeobject.h.
* GH-98686: Quicken everything (GH-98687)Brandt Bucher2022-11-021-1/+0
|
* gh-95756: Lazily created cached co_* attrs (GH-97791)Ken Jin2022-10-111-1/+8
|
* gh-94936: C getters: co_varnames, co_cellvars, co_freevars (#95008)Ken Jin2022-08-041-0/+6
|
* gh-93382: Sync up `co_code` changes with 3.11 (GH-94227)Ken Jin2022-06-241-1/+1
| | | Sync up co_code changes with 3.11 commit 852b4d4bcd12b0b6839a015a262ce976b134f6f3.
* gh-87347: Add parenthesis around macro arguments (#93915)Victor Stinner2022-06-201-1/+2
| | | Add unit test on Py_MEMBER_SIZE() and some other macros.
* GH-93516: Speedup line number checks when tracing. (GH-93763)Mark Shannon2022-06-201-1/+3
| | | | * Use a lookup table to reduce overhead of getting line numbers during tracing.
* GH-93897: Store frame size in code object and de-opt if insufficient space ↵Mark Shannon2022-06-201-2/+2
| | | | on thread frame stack. (GH-93908)
* gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815)Victor Stinner2022-06-161-1/+1
|
* GH-93516: Store offset of first traceable instruction in code object (GH-93769)Mark Shannon2022-06-141-0/+1
|
* gh-93382: Cache result of `PyCode_GetCode` in codeobject (GH-93383)Ken Jin2022-06-031-0/+1
| | | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
* gh-92154: Expose PyCode_GetCode in the C API (GH-92168)Ken Jin2022-05-031-0/+3
|
* GH-88116: Use a compact format to represent end line and column offsets. ↵Mark Shannon2022-04-211-13/+19
| | | | | | | | | | | | (GH-91666) * Stores all location info in linetable to conform to PEP 626. * Remove column table from code objects. * Remove end-line table from code objects. * Document new location table format
* bpo-35134: Remove the Include/code.h header file (GH-32385)Victor Stinner2022-04-071-2/+13
| | | | | | Remove the Include/code.h header file. C extensions should only include the main <Python.h> header file. Python.h includes directly Include/cpython/code.h instead.
* bpo-46841: Quicken code in-place (GH-31888)Brandt Bucher2022-03-211-83/+74
| | | | | | | | | | | | | | | | | | | * Moves the bytecode to the end of the corresponding PyCodeObject, and quickens it in-place. * Removes the almost-always-unused co_varnames, co_freevars, and co_cellvars member caches * _PyOpcode_Deopt is a new mapping from all opcodes to their un-quickened forms. * _PyOpcode_InlineCacheEntries is renamed to _PyOpcode_Caches * _Py_IncrementCountAndMaybeQuicken is renamed to _PyCode_Warmup * _Py_Quicken is renamed to _PyCode_Quicken * _co_quickened is renamed to _co_code_adaptive (and is now a read-only memoryview). * Do not emit unused nonzero opargs anymore in the compiler.
* bpo-46841: Add a _Py_SET_OPCODE macro (GH-31780)Brandt Bucher2022-03-121-0/+3
|
* bpo-46841: Use inline caching for calls (GH-31709)Brandt Bucher2022-03-071-1/+1
|
* bpo-45316: Move private PyCode C API to internal C API (GH-31576)Victor Stinner2022-02-251-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Rename private functions (no exported), add an underscore prefix: * PyLineTable_InitAddressRange() => _PyLineTable_InitAddressRange() * PyLineTable_NextAddressRange() => _PyLineTable_NextAddressRange() * PyLineTable_PreviousAddressRange() => _PyLineTable_PreviousAddressRange() Move private functions to the internal C API: * _PyCode_Addr2EndLine() * _PyCode_Addr2EndOffset() * _PyCode_Addr2Offset() * _PyCode_InitAddressRange() * _PyCode_InitEndAddressRange( * _PyLineTable_InitAddressRange() * _PyLineTable_NextAddressRange() * _PyLineTable_PreviousAddressRange() No longer export the following internal functions: * _PyCode_GetVarnames() * _PyCode_GetCellvars() * _PyCode_GetFreevars() * _Py_GetSpecializationStats() Add "extern" to pycore_code.h functions to identify them more easiliy (they are still not exported).
* bpo-46841: Use *inline* caching for `BINARY_OP` (GH-31543)Brandt Bucher2022-02-251-1/+1
|
* Remove legacy opcache structs (GH-27164)Ken Jin2021-07-161-2/+0
|
* bpo-44530: Add co_qualname field to PyCodeObject (GH-26941)Gabriele N. Tornetta2021-07-071-4/+5
|
* bpo-43950: Add code.co_positions (PEP 657) (GH-26955)Pablo Galindo2021-07-021-4/+21
| | | | | | | | | | | | | | | This PR is part of PEP 657 and augments the compiler to emit ending line numbers as well as starting and ending columns from the AST into compiled code objects. This allows bytecodes to be correlated to the exact source code ranges that generated them. This information is made available through the following public APIs: * The `co_positions` method on code objects. * The C API function `PyCode_Addr2Location`. Co-authored-by: Batuhan Taskaya <isidentical@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
* bpo-43693 Get rid of CO_NOFREE -- it's unused (GH-26839)Guido van Rossum2021-06-231-6/+0
| | | | | | All uses of this flag are either setting it or in doc or tests for it. So we should be able to get rid of it completely.
* bpo-43693: Turn localspluskinds into an object (GH-26749)Guido van Rossum2021-06-211-5/+1
| | | Managing it as a bare pointer to malloc'ed bytes is just too awkward in a few places.
* bpo-43693: Eliminate unused "fast locals". (gh-26587)Eric Snow2021-06-151-6/+2
| | | | | Currently, if an arg value escapes (into the closure for an inner function) we end up allocating two indices in the fast locals even though only one gets used. Additionally, using the lower index would be better in some cases, such as with no-arg `super()`. To address this, we update the compiler to fix the offsets so each variable only gets one "fast local". As a consequence, now some cell offsets are interspersed with the locals (only when an arg escapes to an inner function). https://bugs.python.org/issue43693
* bpo-44338: Port LOAD_GLOBAL to PEP 659 adaptive interpreter (GH-26638)Mark Shannon2021-06-141-14/+0
| | | | | | | | | | * Add specializations of LOAD_GLOBAL. * Add more stats. * Remove old opcache; it is no longer used. * Add NEWS
* Add more const modifiers. (GH-26691)Serhiy Storchaka2021-06-121-3/+3
|
* bpo-43693: Un-revert commit f3fa63e. (#26609)Eric Snow2021-06-081-2/+9
| | | | | | | | | This was reverted in GH-26596 (commit 6d518bb) due to some bad memory accesses. * Add the MAKE_CELL opcode. (gh-26396) The memory accesses have been fixed. https://bugs.python.org/issue43693
* Revert "bpo-43693: Add the MAKE_CELL opcode and interleave fast locals ↵Pablo Galindo2021-06-081-9/+2
| | | | | offsets. (gh-26396)" (GH-26597) This reverts commit 631f9938b1604d4f893417ec339b9e0fa9196fb1.