summaryrefslogtreecommitdiffstats
path: root/Modules/_opcode.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-115999: Implement thread-local bytecode and enable specialization for ↵mpage2024-11-041-0/+3
| | | | | | | | | `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-121554: remove unnecessary internal functions in compile.c (#121555)Irit Katriel2024-07-101-18/+11
| | | Co-authored-by: Erlend E. Aasland <erlend@python.org>
* gh-120642: Move private PyCode APIs to the internal C API (#120643)Victor Stinner2024-06-261-5/+6
| | | | | | | | | | | | | | | * 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-120780: Show attribute name for LOAD_SPECIAL in dis output (#120781)Jelle Zijlstra2024-06-201-0/+28
|
* gh-116322: Add Py_mod_gil module slot (#116882)Brett Simmers2024-05-031-0/+1
| | | | | | | | | | | | | | This PR adds the ability to enable the GIL if it was disabled at interpreter startup, and modifies the multi-phase module initialization path to enable the GIL when loading a module, unless that module's spec includes a slot indicating it can run safely without the GIL. PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148. A warning will be issued up to once per interpreter for the first GIL-using module that is loaded. If `-v` is given, a shorter message will be printed to stderr every time a GIL-using module is loaded (including the first one that issues a warning).
* gh-118335: Configure Tier 2 interpreter at build time (#118339)Guido van Rossum2024-05-011-0/+6
| | | | | | | | | | | | | | | | | | | | | | The code for Tier 2 is now only compiled when configured with `--enable-experimental-jit[=yes|interpreter]`. We drop support for `PYTHON_UOPS` and -`Xuops`, but you can disable the interpreter or JIT at runtime by setting `PYTHON_JIT=0`. You can also build it without enabling it by default using `--enable-experimental-jit=yes-off`; enable with `PYTHON_JIT=1`. On Windows, the `build.bat` script supports `--experimental-jit`, `--experimental-jit-off`, `--experimental-interpreter`. In the C code, `_Py_JIT` is defined as before when the JIT is enabled; the new variable `_Py_TIER2` is defined when the JIT *or* the interpreter is enabled. It is actually a bitmask: 1: JIT; 2: default-off; 4: interpreter.
* gh-112383: teach dis how to interpret ENTER_EXECUTOR (#117171)Irit Katriel2024-03-231-0/+23
|
* gh-107149: make new opcode util functions private rather than public and ↵Irit Katriel2023-11-141-17/+18
| | | | unstable (#112042)
* gh-110093: Replace trivial Py_BuildValue() with direct C API call (GH-110094)Serhiy Storchaka2023-10-201-2/+1
|
* gh-107149: Rename _PyUnstable_GetUnaryIntrinsicName() function (#108441)Victor Stinner2023-08-281-2/+2
| | | | | | * Rename _PyUnstable_GetUnaryIntrinsicName() to PyUnstable_GetUnaryIntrinsicName() * Rename _PyUnstable_GetBinaryIntrinsicName() to PyUnstable_GetBinaryIntrinsicName().
* gh-108220: Internal header files require Py_BUILD_CORE to be defined (#108221)Victor Stinner2023-08-211-0/+4
| | | | | | | | | * pycore_intrinsics.h does nothing if included twice (add #ifndef and #define). * Update Tools/cases_generator/generate_cases.py to generate the Py_BUILD_CORE test. * _bz2, _lzma, _opcode and zlib extensions now define the Py_BUILD_CORE_MODULE macro to use internal headers (pycore_code.h, pycore_intrinsics.h and pycore_blocks_output_buffer.h).
* gh-105481: opcode.h is no longer generated during the build (#108080)Irit Katriel2023-08-171-0/+70
|
* gh-105481: the ENABLE_SPECIALIZATION flag does not need to be generated by ↵Irit Katriel2023-08-011-0/+9
| | | | the build script, or exposed in opcode.py (#107534)
* gh-105481: do not auto-generate pycore_intrinsics.h (#106913)Irit Katriel2023-07-201-0/+57
|
* gh-105481: Generate the opcode lists in dis from data extracted from ↵Irit Katriel2023-07-181-0/+60
| | | | bytecodes.c (#106758)
* gh-105481: expose opcode metadata via the _opcode module (#106688)Irit Katriel2023-07-141-0/+91
|
* gh-105481: remove HAS_ARG, HAS_CONST, IS_JUMP_OPCODE, IS_PSEUDO_OPCODE and ↵Irit Katriel2023-06-171-16/+6
| | | | replace by their new versions (#105865)
* gh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104205)Eric Snow2023-05-051-1/+7
| | | Here we are doing no more than adding the value for Py_mod_multiple_interpreters and using it for stdlib modules. We will start checking for it in gh-104206 (once PyInterpreterState.ceval.own_gil is added in gh-104204).
* gh-94216: add pseudo instructions to the dis/opcodes modules (GH-94241)Irit Katriel2022-07-011-6/+1
|
* bpo-46072: Add --with-pystats configure option to simplify gathering of VM ↵Mark Shannon2021-12-151-1/+1
| | | | | | | | | stats (GH-30116) * Simplify specialization stats collection macros. * Add --enable-pystats option to configure. * Update specialization summary script to handle larger number of kinds
* bpo-44890: collect specialization stats if Py_DEBUG (GH-27731)Irit Katriel2021-08-121-1/+1
|
* bpo-44725 : expose specialization stats in python (GH-27192)Irit Katriel2021-07-291-0/+20
|
* bpo-40222: "Zero cost" exception handling (GH-25729)Mark Shannon2021-05-071-1/+6
| | | | | | | | "Zero cost" exception handling. * Uses a lookup table to determine how to handle exceptions. * Removes SETUP_FINALLY and POP_TOP block instructions, eliminating (most of) the runtime overhead of try statements. * Reduces the size of the frame object by about 60%.
* bpo-1635741: Port _opcode module to multi-phase init (PEP 489) (GH-22050)Mohamed Koubaa2020-09-071-14/+7
|
* bpo-32455: Add jump parameter to dis.stack_effect(). (GH-6610)Serhiy Storchaka2018-09-181-3/+21
| | | | Add C API function PyCompile_OpcodeStackEffectWithJump().
* Issue #27332: Fixed the type of the first argument of module-level functionsSerhiy Storchaka2016-07-071-2/+2
| | | | generated by Argument Clinic. Patch by Petr Viktorin.
* Issue #23501: Argumen Clinic now generates code into separate files by default.Serhiy Storchaka2015-04-031-34/+3
|
* Issue #20530: Argument Clinic's signature format has been revised again.Larry Hastings2014-02-091-2/+4
| | | | | | | The new syntax is highly human readable while still preventing false positives. The syntax also extends Python syntax to denote "self" and positional-only parameters, allowing inspect.Signature objects to be totally accurate for all supported builtins in Python 3.4.
* remove code which does nothing but cause refleaksBenjamin Peterson2014-02-031-4/+0
|
* #Issue 20456: Several improvements and bugfixes for Argument Clinic,Larry Hastings2014-02-011-28/+22
| | | | | including correctly generating code for Clinic blocks inside C preprocessor conditional blocks.
* Issue #20326: Argument Clinic now uses a simple, unique signature toLarry Hastings2014-01-281-2/+2
| | | | | | | | | | annotate text signatures in docstrings, resulting in fewer false positives. "self" parameters are also explicitly marked, allowing inspect.Signature() to authoritatively detect (and skip) said parameters. Issue #20326: Argument Clinic now generates separate checksums for the input and output sections of the block, allowing external tools to verify that the input has not changed (and thus the output is not out-of-date).
* Issue #20189: Four additional builtin types (PyTypeObject,Larry Hastings2014-01-241-2/+2
| | | | | | PyMethodDescr_Type, _PyMethodWrapper_Type, and PyWrapperDescr_Type) have been modified to provide introspection information for builtins. Also: many additional Lib, test suite, and Argument Clinic fixes.
* Two minor Argument Clinic bugfixes: use the name of the class in theLarry Hastings2014-01-221-4/+4
| | | | | docstring for __new__ and __init__, and always use "goto exit" instead of returning "NULL" for failure to parse (as _new__ and __init__ return ints).
* Issue #20226: Major improvements to Argument Clinic.Larry Hastings2014-01-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | * You may now specify an expression as the default value for a parameter! Example: "sys.maxsize - 1". This support is intentionally quite limited; you may only use values that can be represented as static C values. * Removed "doc_default", simplified support for "c_default" and "py_default". (I'm not sure we still even need "py_default", but I'm leaving it in for now in case a use presents itself.) * Parameter lines support a trailing '\\' as a line continuation character, allowing you to break up long lines. * The argument parsing code generated when supporting optional groups now uses PyTuple_GET_SIZE instead of PyTuple_GetSize, leading to a 850% speedup in parsing. (Just kidding, this is an unmeasurable difference.) * A bugfix for the recent regression where the generated prototype from pydoc for builtins would be littered with unreadable "=<object ...>"" default values for parameters that had no default value. * Converted some asserts into proper failure messages. * Many doc improvements and fixes.
* Issue #19273: The marker comments Argument Clinic uses have been changedLarry Hastings2014-01-071-7/+7
| | | | to improve readability.
* Issue #19674: inspect.signature() now produces a correct signatureLarry Hastings2013-11-231-9/+10
| | | | for some builtins.
* Issue #19722: Added opcode.stack_effect(), which accuratelyLarry Hastings2013-11-231-0/+116
computes the stack effect of bytecode instructions.