summaryrefslogtreecommitdiffstats
path: root/Include/internal
Commit message (Collapse)AuthorAgeFilesLines
* bpo-46315: Add ifdef HAVE_ feature checks for WASI compatibility (GH-30507)Christian Heimes2022-01-131-1/+3
|
* bpo-45953: Statically allocate the main interpreter (and initial thread ↵Eric Snow2022-01-123-15/+67
| | | | | | | | | state). (gh-29883) Previously, the main interpreter was allocated on the heap during runtime initialization. Here we instead embed it into _PyRuntimeState, which means it is statically allocated as part of the _PyRuntime global. The same goes for the initial thread state (of each interpreter, including the main one). Consequently there are fewer allocations during runtime/interpreter init, fewer possible failures, and better memory locality. FYI, this also helps efforts to consolidate globals, which in turns helps work on subinterpreter isolation. https://bugs.python.org/issue45953
* bpo-45953: Statically allocate and initialize global bytes objects. (gh-30096)Eric Snow2022-01-113-12/+280
| | | | | The empty bytes object (b'') and the 256 one-character bytes objects were allocated at runtime init. Now we statically allocate and initialize them. https://bugs.python.org/issue45953
* bpo-46303: Move fileutils.h private functions to internal C API (GH-30484)Victor Stinner2022-01-112-0/+161
| | | | | | | | | | Move almost all private functions of Include/cpython/fileutils.h to the internal C API Include/internal/pycore_fileutils.h. Only keep _Py_fopen_obj() in Include/cpython/fileutils.h, since it's used by _testcapi which must not use the internal C API. Move EncodeLocaleEx() and DecodeLocaleEx() functions from _testcapi to _testinternalcapi, since the C API moved to the internal C API.
* bpo-46006: Revert "bpo-40521: Per-interpreter interned strings (GH-20085)" ↵Victor Stinner2022-01-061-11/+1
| | | | | | | | | | | (GH-30422) This reverts commit ea251806b8dffff11b30d2182af1e589caf88acf. Keep "assert(interned == NULL);" in _PyUnicode_Fini(), but only for the main interpreter. Keep _PyUnicode_ClearInterned() changes avoiding the creation of a temporary Python list object.
* bpo-45256: Don't track the exact depth of each `InterpreterFrame` (GH-30372)Brandt Bucher2022-01-051-2/+4
|
* bpo-46219, 46221: simplify except* implementation following exc_info ↵Irit Katriel2022-01-021-3/+3
| | | | changes. Move helpers to exceptions.c. Do not assume that exception groups are truthy. (GH-30289)
* bpo-46090: Allow PyThreadState.datastack_* members to be NULL (GH-30234)Brandt Bucher2021-12-281-4/+7
|
* bpo-46072: Add top level stats struct (GH-30169)Mark Shannon2021-12-171-8/+21
|
* bpo-45711: Remove type and traceback from exc_info (GH-30122)Irit Katriel2021-12-171-10/+2
| | | | | | | | * Do not PUSH/POP traceback or type to the stack as part of exc_info * Remove exc_traceback and exc_type from _PyErr_StackItem * Add to what's new, because this change breaks things like Cython
* bpo-46072: Add --with-pystats configure option to simplify gathering of VM ↵Mark Shannon2021-12-151-15/+2
| | | | | | | | | 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-46039: Split yield from in two (GH-30035)Mark Shannon2021-12-151-0/+1
| | | | | | * Split YIELD_FROM opcode into SEND and JUMP_ABSOLUTE. * Remove YIELD_FROM opcode.
* bpo-44525: Split calls into PRECALL and CALL (GH-30011)Mark Shannon2021-12-141-2/+2
| | | | | | | | | | * Add 3 new opcodes for calls: PRECALL_METHOD, CALL_NO_KW, CALL_KW. * Update specialization to handle new CALL opcodes. * Specialize call to method descriptors. * Remove old CALL opcodes: CALL_FUNCTION, CALL_METHOD, CALL_METHOD_KW, CALL_FUNCTION_KW.
* bpo-45292: [PEP-654] add except* (GH-29581)Irit Katriel2021-12-143-3/+23
|
* bpo-45953: Statically initialize the small ints. (gh-30092)Eric Snow2021-12-144-45/+355
| | | | | | | The array of small PyLong objects has been statically declared. Here I also statically initialize them. Consequently they are no longer initialized dynamically during runtime init. I've also moved them under a new sub-struct in _PyRuntimeState, in preparation for static allocation and initialization of other global objects. https://bugs.python.org/issue45953
* bpo-46042: Improve SyntaxError locations in the symbol table (GH-30059)Pablo Galindo Salgado2021-12-111-2/+9
|
* bpo-46008: Make runtime-global object/type lifecycle functions and state ↵Eric Snow2021-12-0920-231/+483
| | | | | | | | | | | | consistent. (gh-29998) This change is strictly renames and moving code around. It helps in the following ways: * ensures type-related init functions focus strictly on one of the three aspects (state, objects, types) * passes in PyInterpreterState * to all those functions, simplifying work on moving types/objects/state to the interpreter * consistent naming conventions help make what's going on more clear * keeping API related to a type in the corresponding header file makes it more obvious where to look for it https://bugs.python.org/issue46008
* bpo-46008: Move Py*State init into distinct functions. (gh-29977)Eric Snow2021-12-082-2/+21
| | | | | Previously, basic initialization of PyInterprterState happened in PyInterpreterState_New() (along with allocation and adding the new interpreter to the runtime state). This prevented us from initializing interpreter states that were allocated separately (e.g. statically or in a free list). We've addressed that here by factoring out a separate function just for initialization. We've done the same for PyThreadState. _PyRuntimeState was sorted out when we added it since _PyRuntime is statically allocated. However, here we update the existing init code to line up with the functions for PyInterpreterState and PyThreadState. https://bugs.python.org/issue46008
* bpo-46008: Add _PyInterpreterState_Main(). (gh-29978)Eric Snow2021-12-081-5/+9
| | | | | PyInterpreterState_Main() is a plain function exposed in the public C-API. For internal usage we can take the more efficient approach in this PR. https://bugs.python.org/issue46008
* bpo-46008: Stop calling _PyThreadState_Init() in new_threadstate(). (gh-29973)Eric Snow2021-12-081-0/+2
| | | | | This simplifies new_threadstate(). We also rename _PyThreadState_Init() to _PyThreadState_SetCurrent() to reflect what it actually does. https://bugs.python.org/issue46008
* bpo-46008: Move thread-related interpreter state into a sub-struct. (gh-29971)Eric Snow2021-12-071-11/+13
| | | | | This parallels _PyRuntimeState.interpreters. Doing this helps make it more clear what part of PyInterpreterState relates to its threads. https://bugs.python.org/issue46008
* bpo-46008: Return void from _PyEval_InitState(). (gh-29970)Eric Snow2021-12-071-1/+1
| | | | | This falls into the category of keep-allocation-and-initialization separate. It also allows us to use _PyEval_InitState() safely in functions that return void. https://bugs.python.org/issue46008
* bpo-45947: Place dict and values pointer at fixed (negative) offset just ↵Mark Shannon2021-12-071-1/+22
| | | | | | | | | | | | | | | | | | | before GC header. (GH-29879) * Place __dict__ immediately before GC header for plain Python objects. * Fix up lazy dict creation logic to use managed dict pointers. * Manage values pointer, placing them directly before managed dict pointers. * Convert hint-based load/store attr specialization target managed dict classes. * Specialize LOAD_METHOD for managed dict objects. * Remove unsafe _PyObject_GC_Calloc function. * Remove unsafe _PyObject_GC_Malloc() function. * Add comment explaning use of Py_TPFLAGS_MANAGED_DICT.
* bpo-45963: Make space for the InterpreterFrame of a generator in that ↵Mark Shannon2021-12-062-2/+2
| | | | | | | generator. (GH-29891) * Make generator, coroutine and async gen structs all the same size. * Store interpreter frame in generator (and coroutine). Reduces the number of allocations neeeded for a generator from two to one.
* bpo-45582 Fix prototype of _Py_Get_Getpath_CodeObject. (GH-29907)Benjamin Peterson2021-12-031-1/+1
| | | Automerge-Triggered-By: GH:tiran
* bpo-45885: Specialize COMPARE_OP (GH-29734)Dennis Sweeney2021-12-031-0/+2
| | | | | | | * Add COMPARE_OP_ADAPTIVE adaptive instruction. * Add COMPARE_OP_FLOAT_JUMP, COMPARE_OP_INT_JUMP and COMPARE_OP_STR_JUMP specialized instructions. * Introduce and use _PyUnicode_Equal
* bpo-45582: Port getpath[p].c to Python (GH-29041)Steve Dower2021-12-033-56/+11
| | | | | The getpath.py file is frozen at build time and executed as code over a namespace. It is never imported, nor is it meant to be importable or reusable. However, it should be easier to read, modify, and patch than the previous code. This commit attempts to preserve every previously tested quirk, but these may be changed in the future to better align platforms.
* bpo-45753: Interpreter internal tweaks (GH-29575)Mark Shannon2021-12-012-11/+17
| | | | | | | | | | * Split exit paths into exceptional and non-exceptional. * Move exit tracing code to individual bytecodes. * Wrap all trace entry and exit events in macros to make them clearer and easier to enhance. * Move return sequence into RETURN_VALUE, YIELD_VALUE and YIELD_FROM. Distinguish between normal trace events and dtrace events.
* bpo-45476: Disallow using asdl_seq_GET() as l-value (GH-29866)Victor Stinner2021-11-301-3/+3
| | | | | | | | | The following internal macros can not longer be used as l-value: * asdl_seq_GET() * asdl_seq_GET_UNTYPED() * asdl_seq_LEN() They are modified to use the _Py_RVALUE() macro.
* bpo-45476: Add _Py_RVALUE() macro (GH-29860)Victor Stinner2021-11-302-4/+4
| | | | | | | | | | | | | | | | | | Add a new _Py_RVALUE() macro to prevent using an expression as an l-value. Replace a "(void)" cast with the _Py_RVALUE() macro in the following macros: * PyCell_SET() * PyList_SET_ITEM() * PyTuple_SET_ITEM() * _PyGCHead_SET_FINALIZED() * _PyGCHead_SET_NEXT() * asdl_seq_SET() * asdl_seq_SET_UNTYPED() Add also parentheses around macro arguments in PyCell_SET() and PyTuple_SET_ITEM() macros.
* bpo-45786: Allocate space for frame in frame object. (GH-29729)Mark Shannon2021-11-293-19/+3
|
* bpo-45711: use exc_value instead of exc_type to determine if exc_info is ↵Irit Katriel2021-11-251-0/+2
| | | | valid. Add more assertions. (GH-29627)
* bpo-44525: Copy free variables in bytecode to allow calls to inner functions ↵Mark Shannon2021-11-233-15/+28
| | | | | | | | | | | to be specialized (GH-29595) * Make internal APIs that take PyFrameConstructor take a PyFunctionObject instead. * Add reference to function to frame, borrow references to builtins and globals. * Add COPY_FREE_VARS instruction to allow specialization of calls to inner functions.
* bpo-45609: Specialize STORE_SUBSCR (GH-29242)Dennis Sweeney2021-11-192-0/+3
| | | | | * Specialize STORE_SUBSCR for list[int], and dict[object] * Adds _PyDict_SetItem_Take2 which consumes references to the key and values.
* bpo-45829: Specialize BINARY_SUBSCR for __getitem__ implemented in Python. ↵Mark Shannon2021-11-181-1/+2
| | | | (GH-29592)
* bpo-45510: Specialize BINARY_SUBTRACT (GH-29523)Dong-hee Na2021-11-181-0/+1
|
* bpo-45636: Simplify BINARY_OP (GH-29565)Brandt Bucher2021-11-161-0/+3
|
* bpo-45753: Make recursion checks more efficient. (GH-29524)Mark Shannon2021-11-161-4/+4
| | | | * Uses recursion remaining, instead of recursion depth to speed up check against recursion limit.
* bpo-45636: Merge all numeric operators (GH-29482)Brandt Bucher2021-11-111-2/+2
|
* bpo-45292: [PEP 654] Update traceback display code to work with exception ↵Irit Katriel2021-11-051-0/+11
| | | | groups (GH-29207)
* bpo-45691: Make array of small ints static to fix use-after-free error. ↵Mark Shannon2021-11-033-29/+17
| | | | (GH-29366)
* bpo-45395: Make custom frozen modules additions instead of replacements. ↵Eric Snow2021-10-281-0/+3
| | | | | | | | | (gh-28778) Currently custom modules (the array set on PyImport_FrozenModules) replace all the frozen stdlib modules. That can be problematic and is unlikely to be what the user wants. This change treats the custom frozen modules as additions instead. They take precedence over all other frozen modules except for those needed to bootstrap the import system. If the "code" field of an entry in the custom array is NULL then that frozen module is treated as disabled, which allows a custom entry to disable a frozen stdlib module. This change allows us to get rid of is_essential_frozen_module() and simplifies the logic for which frozen modules should be ignored. https://bugs.python.org/issue45395
* Store actual ints, not pointers to them in the interpreter state. (GH-29274)Mark Shannon2021-10-283-3/+3
|
* bpo-45256: Rationalize code around Python-to-Python calls a bit. (GH-29235)Mark Shannon2021-10-281-0/+15
|
* bpo-45506: Normalize _PyPathConfig.stdlib_dir when calculated. (#29040)Eric Snow2021-10-221-0/+3
| | | | | The recently added PyConfig.stdlib_dir was being set with ".." entries. When __file__ was added for from modules this caused a problem on out-of-tree builds. This PR fixes that by normalizing "stdlib_dir" when it is calculated in getpath.c. https://bugs.python.org/issue45506
* bpo-45292: [PEP 654] add the ExceptionGroup and BaseExceptionGroup classes ↵Irit Katriel2021-10-222-0/+3
| | | | (GH-28569)
* bpo-45522: Allow to disable freelists on build time (GH-29056)Christian Heimes2021-10-211-0/+37
| | | | | | | | Freelists for object structs can now be disabled. A new ``configure`` option ``--without-freelists`` can be used to disable all freelists except empty tuple singleton. Internal Py*_MAXFREELIST macros can now be defined as 0 without causing compiler warnings and segfaults. Signed-off-by: Christian Heimes <christian@python.org>
* bpo-45527: Don't count cache hits, just misses. (GH-29092)Mark Shannon2021-10-201-47/+0
|
* bpo-44525: Specialize simple Python calls. (GH-29033)Mark Shannon2021-10-201-0/+7
|
* bpo-44525: Specialize ``CALL_FUNCTION`` for C function calls (GH-26934)Ken Jin2021-10-191-0/+1
|