summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
Commit message (Collapse)AuthorAgeFilesLines
* GH-103082: Filter LINE events in VM, to simplify tool implementation. ↵Mark Shannon2023-05-121-0/+35
| | | | | | | | (GH-104387) When monitoring LINE events, instrument all instructions that can have a predecessor on a different line. Then check that the a new line has been hit in the instrumentation code. This brings the behavior closer to that of 3.11, simplifying implementation and porting of tools.
* GH-96803: Add three C-API functions to make _PyInterpreterFrame less opaque ↵Mark Shannon2023-05-051-1/+2
| | | | for users of PEP 523. (GH-96849)
* gh-98003: Inline call frames for CALL_FUNCTION_EX (GH-98004)Ken Jin2023-04-301-0/+46
|
* gh-87729: add LOAD_SUPER_ATTR instruction for faster super() (#103497)Carl Meyer2023-04-241-0/+1
| | | | | This speeds up `super()` (by around 85%, for a simple one-level `super().meth()` microbenchmark) by avoiding allocation of a new single-use `super()` object on each use.
* gh-84436: Implement Immortal Objects (gh-19474)Eddie Elizondo2023-04-221-2/+8
| | | | | | | | | This is the implementation of PEP683 Motivation: The PR introduces the ability to immortalize instances in CPython which bypasses reference counting. Tagging objects as immortal allows up to skip certain operations when we know that the object will be around for the entire execution of the runtime. Note that this by itself will bring a performance regression to the runtime due to the extra reference count checks. However, this brings the ability of having truly immutable objects that are useful in other contexts such as immutable data sharing between sub-interpreters.
* GH-100530: Change the error message for non-class class patterns (GH-103576)Nikita Sobolev2023-04-181-1/+1
|
* GH-103488: Use return-offset, not yield-offset. (GH-103502)Mark Shannon2023-04-131-1/+2
| | | | * Use return-offset, not yield-offset, so that instruction pointer is correct when sending to a generator or coroutine.
* GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython ↵Mark Shannon2023-04-121-537/+98
| | | | | | | | | | (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-100987: Don't cache references to the names and consts array in ↵Mark Shannon2023-03-131-7/+0
| | | | | | | `_PyEval_EvalFrameDefault`. (#102640) * Rename local variables, names and consts, from the interpeter loop. Will allow non-code objects in frames for better introspection of C builtins and extensions. * Remove unused dummy variables.
* gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives ↵Irit Katriel2023-03-131-23/+19
| | | | (#102631)
* gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives ↵Irit Katriel2023-02-281-33/+16
| | | | (in Python/) (#102193)
* gh-101101: Unstable C API tier (PEP 689) (GH-101102)Petr Viktorin2023-02-281-1/+1
|
* GH-100719: Remove redundant `gi_code` field from generator object. (GH-100749)Mark Shannon2023-02-231-37/+36
|
* gh-101903: Remove obsolete undefs for previously removed macros ↵Owain Davies2023-02-211-4/+0
| | | | Py_EnterRecursiveCall and Py_LeaveRecursiveCall (#101923)
* gh-101907: Stop using `_Py_OPCODE` and `_Py_OPARG` macros (GH-101912)Steve Dower2023-02-201-6/+6
| | | | | | * gh-101907: Removes use of non-standard C++ extension from Include/cpython/code.h * Make cases_generator correct on Windows
* gh-101967: add a missing error check (#101968)Eclips42023-02-181-1/+3
|
* gh-101758: Clean Up Uses of Import State (gh-101919)Eric Snow2023-02-151-1/+1
| | | | | | | | | | | | | | | This change is almost entirely moving code around and hiding import state behind internal API. We introduce no changes to behavior, nor to non-internal API. (Since there was already going to be a lot of churn, I took this as an opportunity to re-organize import.c into topically-grouped sections of code.) The motivation is to simplify a number of upcoming changes. Specific changes: * move existing import-related code to import.c, wherever possible * add internal API for interacting with import state (both global and per-interpreter) * use only API outside of import.c (to limit churn there when changing the location, etc.) * consolidate the import-related state of PyInterpreterState into a single struct field (this changes layout slightly) * add macros for import state in import.c (to simplify changing the location) * group code in import.c into sections *remove _PyState_AddModule() https://github.com/python/cpython/issues/101758
* gh-98831: Modernize CALL and family (#101508)Guido van Rossum2023-02-081-6/+0
| | | Includes a slight improvement to `DECREF_INPUTS()`.
* GH-101578: Normalize the current exception (GH-101607)Mark Shannon2023-02-081-7/+5
| | | | | | | | | | * Make sure that the current exception is always normalized. * Remove redundant type and traceback fields for the current exception. * Add new API functions: PyErr_GetRaisedException, PyErr_SetRaisedException * Add new API functions: PyException_GetArgs, PyException_SetArgs
* gh-101072: support default and kw default in PyEval_EvalCodeEx for 3.11+ ↵Matthieu Dartiailh2023-02-071-3/+0
| | | | | (#101127) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* Fix some comments in ceval.c and fix lltrace output (#101297)Guido van Rossum2023-01-241-6/+4
| | | | | The comment at the top was rather outdated. :-) Also added a note about the dangers of dump_stack().
* gh-98831: rewrite CHECK_EG_MATCH opcode in the instruction definition DSL ↵Irit Katriel2023-01-241-1/+1
| | | | (#101269)
* GH-98831: Move assorted macros from ceval.h to a new header (#101116)Guido van Rossum2023-01-181-348/+1
|
* GH-100892: consolidate `HEAD_LOCK/HEAD_UNLOCK` macros (#100953)Kumar Aditya2023-01-151-5/+0
|
* GH-100126: Skip incomplete frames in more places (GH-100613)Brandt Bucher2023-01-091-7/+4
|
* gh-100758: Refactor initialisation of frame headers into a single function ↵Irit Katriel2023-01-061-4/+1
| | | | (_PyFrame_Initialize) (GH-100759)
* GH-99005: Add `CALL_INTRINSIC_1` instruction (GH-100771)Mark Shannon2023-01-051-90/+1
| | | | | | | | * Remove PRINT_EXPR instruction * Remove STOPITERATION_ERROR instruction * Remove IMPORT_STAR instruction
* GH-100719: Remove the `co_nplaincellvars` field from code objects. (GH-100721)Mark Shannon2023-01-041-1/+1
|
* GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code ↵Mark Shannon2022-12-141-2/+2
| | | | unit. (GH-100223)
* GH-99729: Unlink frames before clearing them (GH-100030)Brandt Bucher2022-12-061-9/+4
|
* gh-88226: Emit TARGET labels in Python/ceval.c when debugging, even if ↵Skip Montanaro2022-11-221-4/+21
| | | | | | | computed gotos aren't enabled (GH-98265) Keep target labels when debugging, but don't warn about lack of use. Co-authored-by: Eryk Sun <eryksun@gmail.com>
* Add a macro for "inlining" new frames (GH-99490)Brandt Bucher2022-11-171-0/+10
|
* GH-96421: Insert shim frame on entry to interpreter (GH-96319)Mark Shannon2022-11-101-39/+41
| | | | | | * Adds EXIT_INTERPRETER instruction to exit PyEval_EvalDefault() * Simplifies RETURN_VALUE, YIELD_VALUE and RETURN_GENERATOR instructions as they no longer need to check for entry frames.
* gh-99300: Use Py_NewRef() in Python/ceval.c (#99318)Victor Stinner2022-11-101-16/+8
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in Python/ceval.c and related files.
* GH-98686: Get rid of "adaptive" and "quick" instructions (GH-99182)Brandt Bucher2022-11-091-34/+64
|
* GH-98831: Simple input-output stack effects for bytecodes.c (#99120)Guido van Rossum2022-11-081-0/+9
|
* GH-96793: Specialize FOR_ITER for generators. (GH-98772)Mark Shannon2022-11-071-3/+36
|
* GH-98686: Fix compiler warning for HAS_ARG (GH-99106)Brandt Bucher2022-11-041-1/+1
|
* GH-98831: "Generate" the interpreter (#98830)Guido van Rossum2022-11-031-3850/+1
| | | | | | | | | | | The switch cases (really TARGET(opcode) macros) have been moved from ceval.c to generated_cases.c.h. That file is generated from instruction definitions in bytecodes.c (which impersonates a C file so the C code it contains can be edited without custom support in e.g. VS Code). The code generator lives in Tools/cases_generator (it has a README.md explaining how it works). The DSL used to describe the instructions is a work in progress, described in https://github.com/faster-cpython/ideas/blob/main/3.12/interpreter_definition.md. This is surely a work-in-progress. An easy next step could be auto-generating super-instructions. **IMPORTANT: Merge Conflicts** If you get a merge conflict for instruction implementations in ceval.c, your best bet is to port your changes to bytecodes.c. That file looks almost the same as the original cases, except instead of `TARGET(NAME)` it uses `inst(NAME)`, and the trailing `DISPATCH()` call is omitted (the code generator adds it automatically).
* GH-98686: Quicken everything (GH-98687)Brandt Bucher2022-11-021-21/+9
|
* Rename JUMP_TO_INSTRUCTION to GO_TO_INSTRUCTION (#98934)Guido van Rossum2022-11-011-14/+14
| | | | | | This reduces confusion between jumps at the bytecode level (e.g. JUMPTO(), JUMPBY(), and various JUMP_*() opcodes) and jumps in the C code (which are 'goto' statements).
* gh-98879: Remove unreachable error case from COMPARE_OP_STR_JUMP (GH-98882)Dennis Sweeney2022-10-301-3/+0
| | | Thanks to PEP 623 changes, the comparison cannot fail.
* gh-98789: Fix FOR_ITER assert on big-endian (GH-98792)Dennis Sweeney2022-10-281-1/+1
| | | Fix FOR_ITER assertion syntax
* GH-96793: Change `FOR_ITER` to not pop the iterator on exhaustion. (GH-96801)Mark Shannon2022-10-271-3/+13
| | | | Change FOR_ITER to have the same stack effect regardless of whether it branches or not. Performance is unchanged as FOR_ITER (and specialized forms jump over the cleanup code).
* gh-91058: Add error suggestions to 'import from' import errors (#98305)Pablo Galindo Salgado2022-10-251-2/+2
|
* gh-98257: Make _PyEval_SetTrace() reentrant (#98258)Victor Stinner2022-10-191-44/+13
| | | | | | | | | | Make sys.setprofile() and sys.settrace() functions reentrant. They can no long fail with: RuntimeError("Cannot install a trace function while another trace function is being installed"). Make _PyEval_SetTrace() and _PyEval_SetProfile() functions reentrant, rather than detecting and rejecting reentrant calls. Only delete the reference to function arguments once the new function is fully set, when a reentrant call is safe. Call also _PySys_Audit() earlier.
* Fix some incorrect indentation around the main switch (#98177)Guido van Rossum2022-10-111-21/+20
| | | | | | The `}` marked with `/* End instructions */` is the end of the switch. There is another pair of `{}` around the switch, which is vestigial from ancient times when it was `for (;;) { switch (opcode) { ... } }`. All `DISPATCH` macro calls should be inside that pair.
* GH-91052: Add C API for watching dictionaries (GH-31787)Carl Meyer2022-10-071-1/+4
|
* GH-91079: Decouple C stack overflow checks from Python recursion checks. ↵Mark Shannon2022-10-051-24/+57
| | | | (GH-96510)
* gh-97670: Remove sys.getdxp() and analyze_dxp.py script (#97671)Victor Stinner2022-10-041-55/+0
| | | | | | | Remove the sys.getdxp() function and the Tools/scripts/analyze_dxp.py script. DXP stands for "dynamic execution pairs". They were related to DYNAMIC_EXECUTION_PROFILE and DXPAIRS macros which have been removed in Python 3.11. Python can now be built with "./configure --enable-pystats" to gather statistics on Python opcodes.