aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python
Commit message (Collapse)AuthorAge
* gh-105716: Support Background Threads in Subinterpreters Consistently ↵Eric Snow2023-10-02
| | | | | | | (gh-109921) The existence of background threads running on a subinterpreter was preventing interpreters from getting properly destroyed, as well as impacting the ability to run the interpreter again. It also affected how we wait for non-daemon threads to finish. We add PyInterpreterState.threads.main, with some internal C-API functions.
* gh-109853: Fix sys.path[0] For Subinterpreters (gh-109994)Eric Snow2023-10-02
| | | This change makes sure sys.path[0] is set properly for subinterpreters. Before, it wasn't getting set at all. This PR does not address the broader concerns from gh-109853.
* gh-110014: Fix bootstrap_hash.c: remove debug code (#110161)Victor Stinner2023-09-30
| | | Oops, I commited debug code by mistake, sorry about that.
* gh-110014: Include explicitly <unistd.h> header (#110155)Victor Stinner2023-09-30
| | | | | | | | | | | * Remove unused <locale.h> includes. * Remove unused <fcntl.h> include in traceback.h. * Remove redundant <assert.h> and <stddef.h> includes. They are already included by "Python.h". * Remove <object.h> include in faulthandler.c. Python.h already includes it. * Add missing <stdbool.h> in pycore_pythread.h if HAVE_PTHREAD_STUBS is defined. * Fix also warnings in pthread_stubs.h: don't redefine macros if they are already defined, like the __NEED_pthread_t macro.
* gh-110014: Fix _POSIX_THREADS and _POSIX_SEMAPHORES usage (#110139)Victor Stinner2023-09-30
| | | | | | | | | | | | | | | | * pycore_pythread.h is now the central place to make sure that _POSIX_THREADS and _POSIX_SEMAPHORES macros are defined if available. * Make sure that pycore_pythread.h is included when _POSIX_THREADS and _POSIX_SEMAPHORES macros are tested. * PY_TIMEOUT_MAX is now defined as a constant, since its value depends on _POSIX_THREADS, instead of being defined as a macro. * Prevent integer overflow in the preprocessor when computing PY_TIMEOUT_MAX_VALUE on Windows: replace "0xFFFFFFFELL * 1000 < LLONG_MAX" with "0xFFFFFFFELL < LLONG_MAX / 1000". * Document the change and give hints how to fix affected code. * Add an exception for PY_TIMEOUT_MAX name to smelly.py * Add PY_TIMEOUT_MAX to the stable ABI
* gh-107954: Refactor initconfig.c: add CONFIG_SPEC (#110146)Victor Stinner2023-09-30
| | | Add a specification of the PyConfig structure to factorize the code.
* gh-110079: Remove extern "C" { ...} in C code (#110080)Victor Stinner2023-09-29
|
* gh-110052: Fix faulthandler for freed tstate (#110069)Victor Stinner2023-09-29
| | | | faulthandler now detected freed interp and freed tstate, and no longer dereference them.
* gh-109889: fix compiler's redundant NOP detection to look past NOPs with no ↵Irit Katriel2023-09-28
| | | | lineno when looking for the next instruction's lineno (#109987)
* gh-110020: Fix unused variable warnings in bytecodes.c (GH-110023)Nikita Sobolev2023-09-28
|
* gh-104909: Split some more insts into ops (#109943)Guido van Rossum2023-09-27
| | | | | | | | | | | | | | | | | | | | These are the most popular specializations of `LOAD_ATTR` and `STORE_ATTR` that weren't already viable uops: * Split LOAD_ATTR_METHOD_WITH_VALUES * Split LOAD_ATTR_METHOD_NO_DICT * Split LOAD_ATTR_SLOT * Split STORE_ATTR_SLOT * Split STORE_ATTR_INSTANCE_VALUE Also: * Add `-v` flag to code generator which prints a list of non-viable uops (easter-egg: it can print execution counts -- see source) * Double _Py_UOP_MAX_TRACE_LENGTH to 128 I had dropped one of the DEOPT_IF() calls! :-(
* gh-109793: Allow Switching Interpreters During Finalization (gh-109794)Eric Snow2023-09-27
| | | Essentially, we should check the thread ID rather than the thread state pointer.
* gh-109740: Use 't' in `--disable-gil` SOABI (#109922)Sam Gross2023-09-27
| | | | Shared libraries for CPython 3.13 are now marked with a 't' for threading. For example, `binascii.cpython-313t-darwin.so`.
* gh-109923: set line number on the POP_TOP that follows a RETURN_GENERATOR ↵Irit Katriel2023-09-27
| | | | (#109924)
* gh-109823: Adjust labels in compiler when removing an empty basic block ↵Irit Katriel2023-09-25
| | | | which is a jump target (#109839)
* gh-109521: Fix obscure cases handling in PyImport_GetImporter() (GH-109522)Serhiy Storchaka2023-09-23
| | | | | | | | 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-23
|
* GH-107265: Add missing deoptimizations for ENTER_EXECUTOR's original opcode ↵Tian Gao2023-09-22
| | | | (GH-109420)
* gh-109719: Fix missing jump target labels when compiler reorders cold/warm ↵Irit Katriel2023-09-22
| | | | blocks (#109734)
* gh-109627: duplicated smalll exit blocks need to be assigned jump target ↵Irit Katriel2023-09-20
| | | | labels (#109630)
* gh-109390: add dump_symtable utility under #if 0 (#109391)Carl Meyer2023-09-20
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-76785: Use Pending Calls When Releasing Cross-Interpreter Data (gh-109556)Eric Snow2023-09-19
| | | 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-19
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-18
|
* gh-109371: Fix monitoring with instruction events set (gh-109385)Tian Gao2023-09-18
|
* gh-108511: Add C API functions which do not silently ignore errors (GH-109025)Serhiy Storchaka2023-09-17
| | | | | | | | | 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-15
| | | | | | | | | | | | | | | | | | | | | | | | 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-14
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-105658: fix excess trace events for except block ending with a ↵Irit Katriel2023-09-14
| | | | conditional block (#109384)
* dump readable opcode names in flowgraph debug utility (#109392)Carl Meyer2023-09-14
| | | 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-13
|
* GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW (GH-109300)Brandt Bucher2023-09-13
|
* gh-109341: Fix crash on compiling invalid AST including TypeAlias (#109349)Jelle Zijlstra2023-09-13
|
* gh-109351: Fix crash when compiling AST with invalid NamedExpr (#109352)Jelle Zijlstra2023-09-13
|
* GH-109330: Dump and compare stats using opcode names, not numbers (GH-109335)Michael Droettboom2023-09-12
|
* gh-106581: Honor 'always_exits' in write_components() (#109338)Guido van Rossum2023-09-12
| | | | | | | | | | 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-12
|
* gh-109216: Fix possible memory leak in `BUILD_MAP` (#109257)Nikita Sobolev2023-09-12
|
* gh-109118: Disallow nested scopes within PEP 695 scopes within classes (#109196)Jelle Zijlstra2023-09-11
| | | | | 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-11
|
* gh-109214: Rename SAVE_IP to _SET_IP, and similar (#109285)Guido van Rossum2023-09-11
| | | | | | | | * 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-11
| | | | | | | | | | | 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-11
|
* gh-108987: Fix _thread.start_new_thread() race condition (#109135)Victor Stinner2023-09-11
| | | | | | | | | | | | | 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-11
| | | | during callback. (GH-109131)
* gh-109207: Fix SystemError when printing symtable entry object. (GH-109225)云line2023-09-10
|
* gh-109118: Fix runtime crash when NameError happens in PEP 695 function ↵Jelle Zijlstra2023-09-09
| | | | (#109123)
* Check the result of PySet_Contains() for error in Python/symtable.c (GH-109146)Serhiy Storchaka2023-09-08
|
* GH-108614: Unbreak emscripten build (GH-109132)Mark Shannon2023-09-08
|
* gh-106922: Fix error location for constructs with spaces and parentheses ↵Pablo Galindo Salgado2023-09-08
| | | | (#108959)