summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* gh-109923: set line number on the POP_TOP that follows a RETURN_GENERATOR ↵Irit Katriel2023-09-271-2/+4
| | | | (#109924)
* gh-109823: Adjust labels in compiler when removing an empty basic block ↵Irit Katriel2023-09-251-1/+8
| | | | which is a jump target (#109839)
* gh-109521: Fix obscure cases handling in PyImport_GetImporter() (GH-109522)Serhiy Storchaka2023-09-231-5/+21
| | | | | | | | PyImport_GetImporter() now sets RuntimeError if it fails to get sys.path_hooks or sys.path_importer_cache or they are not list and dict correspondingly. Previously it could return NULL without setting error in obscure cases, crash or raise SystemError if these attributes have wrong type.
* gh-109611: Add convenient C API function _PyFile_Flush() (GH-109612)Serhiy Storchaka2023-09-234-42/+13
|
* GH-107265: Add missing deoptimizations for ENTER_EXECUTOR's original opcode ↵Tian Gao2023-09-221-1/+1
| | | | (GH-109420)
* gh-109719: Fix missing jump target labels when compiler reorders cold/warm ↵Irit Katriel2023-09-221-0/+5
| | | | blocks (#109734)
* gh-109627: duplicated smalll exit blocks need to be assigned jump target ↵Irit Katriel2023-09-201-5/+17
| | | | labels (#109630)
* gh-109390: add dump_symtable utility under #if 0 (#109391)Carl Meyer2023-09-201-1/+110
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-76785: Use Pending Calls When Releasing Cross-Interpreter Data (gh-109556)Eric Snow2023-09-192-37/+62
| | | This fixes some crashes in the _xxinterpchannels module, due to a race between interpreters.
* gh-108724: Add PyMutex and _PyParkingLot APIs (gh-109344)Sam Gross2023-09-193-0/+672
| | | | | | | | | | | | | | | | | | | | | | | | | | PyMutex is a one byte lock with fast, inlineable lock and unlock functions for the common uncontended case. The design is based on WebKit's WTF::Lock. PyMutex is built using the _PyParkingLot APIs, which provides a cross-platform futex-like API (based on WebKit's WTF::ParkingLot). This internal API will be used for building other synchronization primitives used to implement PEP 703, such as one-time initialization and events. This also includes tests and a mini benchmark in Tools/lockbench/lockbench.py to compare with the existing PyThread_type_lock. Uncontended acquisition + release: * Linux (x86-64): PyMutex: 11 ns, PyThread_type_lock: 44 ns * macOS (arm64): PyMutex: 13 ns, PyThread_type_lock: 18 ns * Windows (x86-64): PyMutex: 13 ns, PyThread_type_lock: 38 ns PR Overview: The primary purpose of this PR is to implement PyMutex, but there are a number of support pieces (described below). * PyMutex: A 1-byte lock that doesn't require memory allocation to initialize and is generally faster than the existing PyThread_type_lock. The API is internal only for now. * _PyParking_Lot: A futex-like API based on the API of the same name in WebKit. Used to implement PyMutex. * _PyRawMutex: A word sized lock used to implement _PyParking_Lot. * PyEvent: A one time event. This was used a bunch in the "nogil" fork and is useful for testing the PyMutex implementation, so I've included it as part of the PR. * pycore_llist.h: Defines common operations on doubly-linked list. Not strictly necessary (could do the list operations manually), but they come up frequently in the "nogil" fork. ( Similar to https://man.freebsd.org/cgi/man.cgi?queue) --------- Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* Fix error handling in _PySys_UpdateConfig() (GH-109524)Serhiy Storchaka2023-09-181-2/+9
|
* gh-109371: Fix monitoring with instruction events set (gh-109385)Tian Gao2023-09-181-1/+4
|
* gh-108511: Add C API functions which do not silently ignore errors (GH-109025)Serhiy Storchaka2023-09-173-18/+11
| | | | | | | | | Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
* gh-106213: Make Emscripten trampolines work with JSPI (GH-106219)Hood Chatham2023-09-152-0/+87
| | | | | | | | | | | | | | | | | | | | | | | | There is a WIP proposal to enable webassembly stack switching which have been implemented in v8: https://github.com/WebAssembly/js-promise-integration It is not possible to switch stacks that contain JS frames so the Emscripten JS trampolines that allow calling functions with the wrong number of arguments don't work in this case. However, the js-promise-integration proposal requires the [type reflection for Wasm/JS API](https://github.com/WebAssembly/js-types) proposal, which allows us to actually count the number of arguments a function expects. For better compatibility with stack switching, this PR checks if type reflection is available, and if so we use a switch block to decide the appropriate signature. If type reflection is unavailable, we should use the current EMJS trampoline. We cache the function argument counts since when I didn't cache them performance was negatively affected. Co-authored-by: T. Wouters <thomas@python.org> Co-authored-by: Brett Cannon <brett@python.org>
* gh-109219: propagate free vars through type param scopes (#109377)Carl Meyer2023-09-141-3/+2
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-105658: fix excess trace events for except block ending with a ↵Irit Katriel2023-09-141-14/+2
| | | | conditional block (#109384)
* dump readable opcode names in flowgraph debug utility (#109392)Carl Meyer2023-09-141-3/+2
| | | Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* GH-104584: Don't call executors from JUMP_BACKWARD (GH-109347)Brandt Bucher2023-09-133-39/+22
|
* GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300)Brandt Bucher2023-09-1311-246/+444
|
* gh-109341: Fix crash on compiling invalid AST including TypeAlias (#109349)Jelle Zijlstra2023-09-131-0/+5
|
* gh-109351: Fix crash when compiling AST with invalid NamedExpr (#109352)Jelle Zijlstra2023-09-131-0/+5
|
* GH-109330: Dump and compare stats using opcode names, not numbers (GH-109335)Michael Droettboom2023-09-121-8/+8
|
* gh-106581: Honor 'always_exits' in write_components() (#109338)Guido van Rossum2023-09-121-14/+0
| | | | | | | | | | I must have overlooked this when refactoring the code generator. The Tier 1 interpreter contained a few silly things like ``` goto resume_frame; STACK_SHRINK(1); ``` (and other variations, some where the unconditional `goto` was hidden in a macro).
* gh-109256: allocate opcode IDs for internal opcodes in their own range (#109269)Irit Katriel2023-09-121-71/+71
|
* gh-109216: Fix possible memory leak in `BUILD_MAP` (#109257)Nikita Sobolev2023-09-123-9/+0
|
* gh-109118: Disallow nested scopes within PEP 695 scopes within classes (#109196)Jelle Zijlstra2023-09-121-0/+23
| | | | | Fixes #109118. Fixes #109194. Co-authored-by: Carl Meyer <carl@oddbird.net>
* gh-109195: fix source location for super load before LOAD_SUPER_ATTR (#109289)Carl Meyer2023-09-111-1/+1
|
* gh-109214: Rename SAVE_IP to _SET_IP, and similar (#109285)Guido van Rossum2023-09-115-70/+70
| | | | | | | | * Rename SAVE_IP to _SET_IP * Rename EXIT_TRACE to _EXIT_TRACE * Rename SAVE_CURRENT_IP to _SAVE_CURRENT_IP * Rename INSERT to _INSERT (This is for Ken Jin's abstract interpreter) * Rename IS_NONE to _IS_NONE * Rename JUMP_TO_TOP to _JUMP_TO_TOP
* gh-109039: Branch prediction for Tier 2 interpreter (#109038)Guido van Rossum2023-09-115-32/+125
| | | | | | | | | | | This adds a 16-bit inline cache entry to the conditional branch instructions POP_JUMP_IF_{FALSE,TRUE,NONE,NOT_NONE} and their instrumented variants, which is used to keep track of the branch direction. Each time we encounter these instructions we shift the cache entry left by one and set the bottom bit to whether we jumped. Then when it's time to translate such a branch to Tier 2 uops, we use the bit count from the cache entry to decided whether to continue translating the "didn't jump" branch or the "jumped" branch. The counter is initialized to a pattern of alternating ones and zeros to avoid bias. The .pyc file magic number is updated. There's a new test, some fixes for existing tests, and a few miscellaneous cleanups.
* gh-109179: Fix traceback display for SyntaxErrors with notes (#109197)Irit Katriel2023-09-111-13/+11
|
* gh-108987: Fix _thread.start_new_thread() race condition (#109135)Victor Stinner2023-09-112-25/+32
| | | | | | | | | | | | | Fix _thread.start_new_thread() race condition. If a thread is created during Python finalization, the newly spawned thread now exits immediately instead of trying to access freed memory and lead to a crash. thread_run() calls PyEval_AcquireThread() which checks if the thread must exit. The problem was that tstate was dereferenced earlier in _PyThreadState_Bind() which leads to a crash most of the time. Move _PyThreadState_CheckConsistency() from thread_run() to _PyThreadState_Bind().
* GH-108976. Keep monitoring data structures valid during de-optimization ↵Mark Shannon2023-09-111-55/+51
| | | | during callback. (GH-109131)
* gh-109207: Fix SystemError when printing symtable entry object. (GH-109225)云line2023-09-101-3/+2
|
* gh-109118: Fix runtime crash when NameError happens in PEP 695 function ↵Jelle Zijlstra2023-09-094-54/+109
| | | | (#109123)
* Check the result of PySet_Contains() for error in Python/symtable.c (GH-109146)Serhiy Storchaka2023-09-081-15/+57
|
* GH-108614: Unbreak emscripten build (GH-109132)Mark Shannon2023-09-084-10/+10
|
* gh-106922: Fix error location for constructs with spaces and parentheses ↵Pablo Galindo Salgado2023-09-081-0/+17
| | | | (#108959)
* gh-104690: thread_run() checks for tstate dangling pointer (#109056)Victor Stinner2023-09-082-18/+26
| | | | | | | | thread_run() of _threadmodule.c now calls _PyThreadState_CheckConsistency() to check if tstate is a dangling pointer when Python is built in debug mode. Rename ceval_gil.c is_tstate_valid() to _PyThreadState_CheckConsistency() to reuse it in _threadmodule.c.
* GH-91079: Rename C_RECURSION_LIMIT to Py_C_RECURSION_LIMIT (#108507)Victor Stinner2023-09-085-9/+9
| | | | | | | Symbols of the C API should be prefixed by "Py_" to avoid conflict with existing names in 3rd party C extensions on "#include <Python.h>". test.pythoninfo now logs Py_C_RECURSION_LIMIT constant and other _testcapi and _testinternalcapi constants.
* GH-108716: Turn off deep-freezing of code objects. (GH-108722)Mark Shannon2023-09-084-47/+31
|
* gh-109094: remove unnecessary updates of frame->prev_instr in ↵Irit Katriel2023-09-071-6/+2
| | | | instrumentation functions (#109076)
* GH-108614: Add `RESUME_CHECK` instruction (GH-108630)Mark Shannon2023-09-077-40/+58
|
* gh-108753: _Py_PrintSpecializationStats() uses Py_hexdigits (#109040)Victor Stinner2023-09-071-2/+2
|
* gh-107265: Remove all ENTER_EXECUTOR when execute _Py_Instrument (gh-108539)Dong-hee Na2023-09-071-32/+11
|
* GH-104584: Restore frame->stacktop on optimizer error (GH-108953)Brandt Bucher2023-09-061-0/+1
|
* gh-108753: Enhance pystats (#108754)Victor Stinner2023-09-066-55/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Statistics gathering is now off by default. Use the "-X pystats" command line option or set the new PYTHONSTATS environment variable to 1 to turn statistics gathering on at Python startup. Statistics are no longer dumped at exit if statistics gathering was off or statistics have been cleared. Changes: * Add PYTHONSTATS environment variable. * sys._stats_dump() now returns False if statistics are not dumped because they are all equal to zero. * Add PyConfig._pystats member. * Add tests on sys functions and on setting PyConfig._pystats to 1. * Add Include/cpython/pystats.h and Include/internal/pycore_pystats.h header files. * Rename '_py_stats' variable to '_Py_stats'. * Exclude Include/cpython/pystats.h from the Py_LIMITED_API. * Move pystats.h include from object.h to Python.h. * Add _Py_StatsOn() and _Py_StatsOff() functions. Remove '_py_stats_struct' variable from the API: make it static in specialize.c. * Document API in Include/pystats.h and Include/cpython/pystats.h. * Complete pystats documentation in Doc/using/configure.rst. * Don't write "all zeros" stats: if _stats_off() and _stats_clear() or _stats_dump() were called. * _PyEval_Fini() now always call _Py_PrintSpecializationStats() which does nothing if stats are all zeros. Co-authored-by: Michael Droettboom <mdboom@gmail.com>
* gh-108765: Cleanup #include in Python/*.c files (#108977)Victor Stinner2023-09-0617-48/+55
| | | Mention one symbol imported by each #include.
* GH-108390: Prevent non-local events being set with ↵Mark Shannon2023-09-052-61/+101
| | | | `sys.monitoring.set_local_events()` (GH-108420)
* gh-106320: Remove private _PyErr_WriteUnraisableMsg() (#108863)Victor Stinner2023-09-042-0/+2
| | | | | | Move the private _PyErr_WriteUnraisableMsg() functions to the internal C API (pycore_pyerrors.h). Move write_unraisable_exc() from _testcapi to _testinternalcapi.
* GH-108614: Remove `TIER_ONE` and `TIER_TWO` from `_PUSH_FRAME` (GH-108725)Mark Shannon2023-09-044-37/+44
|