summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* gh-85283: Add PySys_AuditTuple() function (#108965)Victor Stinner2023-10-051-3/+19
| | | | | | sys.audit() now has assertions to check that the event argument is not NULL and that the format argument does not use the "N" format. Add tests on PySys_AuditTuple().
* gh-109549: Add new states to PyThreadState to support PEP 703 (gh-109915)Sam Gross2023-10-053-91/+95
| | | This adds a new field 'state' to PyThreadState that can take on one of three values: _Py_THREAD_ATTACHED, _Py_THREAD_DETACHED, or _Py_THREAD_GC. The "attached" and "detached" states correspond closely to acquiring and releasing the GIL. The "gc" state is current unused, but will be used to implement stop-the-world GC for --disable-gil builds in the near future.
* gh-109329: Add stat for "trace too short" (GH-110402)Michael Droettboom2023-10-052-0/+2
|
* gh-88402: Add new sysconfig variables on Windows (GH-110049)Sam Gross2023-10-048-55/+7
| | | | Co-authored-by: Filipe Laíns <filipe.lains@gmail.com>
* gh-110310: Add a Per-Interpreter XID Registry for Heap Types (gh-110311)Eric Snow2023-10-041-39/+118
| | | | | | | | | | | We do the following: * add a per-interpreter XID registry (PyInterpreterState.xidregistry) * put heap types there (keep static types in _PyRuntimeState.xidregistry) * clear the registries during interpreter/runtime finalization * avoid duplicate entries in the registry (when _PyCrossInterpreterData_RegisterClass() is called more than once for a type) * use Py_TYPE() instead of PyObject_Type() in _PyCrossInterpreterData_Lookup() The per-interpreter registry helps preserve isolation between interpreters. This is important when heap types are registered, which is something we haven't been doing yet but I will likely do soon.
* GH-109329: Add tier 2 stats (GH-109913)Michael Droettboom2023-10-046-10/+88
|
* GH-109369: Merge all eval-breaker flags and monitoring version into one ↵Mark Shannon2023-10-046-208/+143
| | | | word. (GH-109846)
* gh-104909: Split more LOAD_ATTR specializations (GH-110317)Guido van Rossum2023-10-044-184/+485
| | | | | | | | | | | | | | | | | | | * Split LOAD_ATTR_MODULE * Split LOAD_ATTR_WITH_HINT * Split _GUARD_TYPE_VERSION out of the latter * Split LOAD_ATTR_CLASS * Split LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES * Fix indent of DEOPT_IF in macros * Split LOAD_ATTR_METHOD_LAZY_DICT * Split LOAD_ATTR_NONDESCRIPTOR_NO_DICT * Fix omission of _CHECK_ATTR_METHOD_LAZY_DICT
* gh-109979: Unify _GUARD_TYPE_VERSION{,_STORE} (#110301)Guido van Rossum2023-10-034-24/+4
| | | | | Now the target for `DEOPT_IF()` is auto-filled, we don't need a separate `_GUARD_TYPE_VERSION_STORE` uop.
* gh-109979: Auto-generate the target for DEOPT_IF() (#110193)Guido van Rossum2023-10-033-295/+262
| | | | | | | | | | | | | | | | In Python/bytecodes.c, you now write ``` DEOPT_IF(condition); ``` The code generator expands this to ``` DEOPT_IF(condition, opcode); ``` where `opcode` is the name of the unspecialized instruction. This works inside macro expansions too. **CAVEAT:** The entire `DEOPT_IF(condition)` statement must be on a single line. If it isn't, the substitution will fail; an error will be printed by the code generator and the C compiler will report some errors.
* gh-108867: Add PyThreadState_GetUnchecked() function (#108870)Victor Stinner2023-10-031-1/+1
| | | | | | Add PyThreadState_GetUnchecked() function: similar to PyThreadState_Get(), but don't issue a fatal error if it is NULL. The caller is responsible to check if the result is NULL. Previously, this function was private and known as _PyThreadState_UncheckedGet().
* gh-109860: Use a New Thread State When Switching Interpreters, When ↵Eric Snow2023-10-032-20/+64
| | | | | | | | | Necessary (gh-110245) In a few places we switch to another interpreter without knowing if it has a thread state associated with the current thread. For the main interpreter there wasn't much of a problem, but for subinterpreters we were *mostly* okay re-using the tstate created with the interpreter (located via PyInterpreterState_ThreadHead()). There was a good chance that tstate wasn't actually in use by another thread. However, there are no guarantees of that. Furthermore, re-using an already used tstate is currently fragile. To address this, now we create a new thread state in each of those places and use it. One consequence of this change is that PyInterpreterState_ThreadHead() may not return NULL (though that won't happen for the main interpreter).
* gh-105716: Support Background Threads in Subinterpreters Consistently ↵Eric Snow2023-10-021-0/+37
| | | | | | | (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-022-0/+28
| | | 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-301-3/+0
| | | Oops, I commited debug code by mistake, sorry about that.
* gh-110014: Include explicitly <unistd.h> header (#110155)Victor Stinner2023-09-307-14/+38
| | | | | | | | | | | * 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-303-6/+28
| | | | | | | | | | | | | | | | * 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-301-320/+257
| | | Add a specification of the PyConfig structure to factorize the code.
* gh-110079: Remove extern "C" { ...} in C code (#110080)Victor Stinner2023-09-2911-109/+6
|
* gh-110052: Fix faulthandler for freed tstate (#110069)Victor Stinner2023-09-291-10/+37
| | | | 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-281-1/+11
| | | | lineno when looking for the next instruction's lineno (#109987)
* gh-110020: Fix unused variable warnings in bytecodes.c (GH-110023)Nikita Sobolev2023-09-283-18/+9
|
* gh-104909: Split some more insts into ops (#109943)Guido van Rossum2023-09-274-88/+355
| | | | | | | | | | | | | | | | | | | | 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-271-1/+16
| | | 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-271-2/+8
| | | | 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-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
|