summaryrefslogtreecommitdiffstats
path: root/Include/internal
Commit message (Collapse)AuthorAgeFilesLines
* gh-112287: Speed up Tier 2 (uop) interpreter a little (#112286)Guido van Rossum2023-11-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This makes the Tier 2 interpreter a little faster. I calculated by about 3%, though I hesitate to claim an exact number. This starts by doubling the trace size limit (to 512), making it more likely that loops fit in a trace. The rest of the approach is to only load `oparg` and `operand` in cases that use them. The code generator know when these are used. For `oparg`, it will conditionally emit ``` oparg = CURRENT_OPARG(); ``` at the top of the case block. (The `oparg` variable may be referenced multiple times by the instructions code block, so it must be in a variable.) For `operand`, it will use `CURRENT_OPERAND()` directly instead of referencing the `operand` variable, which no longer exists. (There is only one place where this will be used.)
* gh-106529: Make FOR_ITER a viable uop (#112134)Guido van Rossum2023-11-201-39/+47
| | | | | | | | | | This uses the new mechanism whereby certain uops are replaced by others during translation, using the `_PyUop_Replacements` table. We further special-case the `_FOR_ITER_TIER_TWO` uop to update the deoptimization target to point just past the corresponding `END_FOR` opcode. Two tiny code cleanups are also part of this PR.
* gh-111863: Rename `Py_NOGIL` to `Py_GIL_DISABLED` (#111864)Hugo van Kemenade2023-11-204-14/+14
| | | Rename Py_NOGIL to Py_GIL_DISABLED
* gh-111926: Update _PyWeakref_IS_DEAD to be thread-safe (gh-112267)Donghee Na2023-11-191-4/+11
|
* gh-106529: Cleanups split off gh-112134 (#112214)Guido van Rossum2023-11-171-1/+1
| | | | | | | - Double max trace size to 256 - Add a dependency on executor_cases.c.h for ceval.o - Mark `_SPECIALIZE_UNPACK_SEQUENCE` as `TIER_ONE_ONLY` - Add debug output back showing the optimized trace - Bunch of cleanups to Tools/cases_generator/
* gh-111956: Add thread-safe one-time initialization. (gh-111960)Sam Gross2023-11-164-7/+44
|
* gh-112026: Restore removed private C API (#112115)Victor Stinner2023-11-158-235/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Restore removed private C API functions, macros and structures which have no simple replacement for now: * _PyDict_GetItem_KnownHash() * _PyDict_NewPresized() * _PyHASH_BITS * _PyHASH_IMAG * _PyHASH_INF * _PyHASH_MODULUS * _PyHASH_MULTIPLIER * _PyLong_Copy() * _PyLong_FromDigits() * _PyLong_New() * _PyLong_Sign() * _PyObject_CallMethodId() * _PyObject_CallMethodNoArgs() * _PyObject_CallMethodOneArg() * _PyObject_CallOneArg() * _PyObject_EXTRA_INIT * _PyObject_FastCallDict() * _PyObject_GetAttrId() * _PyObject_Vectorcall() * _PyObject_VectorcallMethod() * _PyStack_AsDict() * _PyThread_CurrentFrames() * _PyUnicodeWriter structure * _PyUnicodeWriter_Dealloc() * _PyUnicodeWriter_Finish() * _PyUnicodeWriter_Init() * _PyUnicodeWriter_Prepare() * _PyUnicodeWriter_PrepareKind() * _PyUnicodeWriter_WriteASCIIString() * _PyUnicodeWriter_WriteChar() * _PyUnicodeWriter_WriteLatin1String() * _PyUnicodeWriter_WriteStr() * _PyUnicodeWriter_WriteSubstring() * _PyUnicode_AsString() * _PyUnicode_FromId() * _PyVectorcall_Function() * _Py_HashDouble() * _Py_HashPointer() * _Py_IDENTIFIER() * _Py_c_abs() * _Py_c_diff() * _Py_c_neg() * _Py_c_pow() * _Py_c_prod() * _Py_c_quot() * _Py_c_sum() * _Py_static_string() * _Py_static_string_init()
* GH-111848: Set the IP when de-optimizing (GH-112065)Mark Shannon2023-11-152-54/+55
| | | | | | | | | | | | * Replace jumps with deopts in tier 2 * Fewer special cases of uop names * Add target field to uop IR * Remove more redundant SET_IP and _CHECK_VALIDITY micro-ops * Extend whitelist of non-escaping API functions.
* GH-111848: Convert remaining jumps to deopts into tier 2 code. (GH-112045)Mark Shannon2023-11-141-55/+87
|
* gh-111262: Add PyDict_Pop() function (#112028)Victor Stinner2023-11-141-1/+5
| | | | | | | _PyDict_Pop_KnownHash(): remove the default value and the return type becomes an int. Co-authored-by: Stefan Behnel <stefan_ml@behnel.de> Co-authored-by: Antoine Pitrou <pitrou@free.fr>
* gh-107149: make new opcode util functions private rather than public and ↵Irit Katriel2023-11-141-0/+14
| | | | unstable (#112042)
* Add private _PyUnicode_AsUTF8NoNUL() function (GH-111957)Serhiy Storchaka2023-11-101-0/+4
| | | | Like PyUnicode_AsUTF8(), but check for embedded null characters.
* GH-109369: Exit tier 2 if executor is invalid (GH-111657)Mark Shannon2023-11-091-224/+233
|
* gh-111354: remove comparisons with enum values, variable reuse, unused ↵Irit Katriel2023-11-091-0/+1
| | | | imports in genobject.c (#111708)
* gh-111569: Implement Python critical section API (gh-111571)Sam Gross2023-11-082-3/+259
| | | | | | | | Critical sections are helpers to replace the global interpreter lock with finer grained locking. They provide similar guarantees to the GIL and avoid the deadlock risk that plain locking involves. Critical sections are implicitly ended whenever the GIL would be released. They are resumed when the GIL would be acquired. Nested critical sections behave as if the sections were interleaved.
* GH-111848: Tidy up tier 2 handling of FOR_ITER specialization by using ↵Mark Shannon2023-11-081-18/+21
| | | | DEOPT_IF instead of jumps. (GH-111849)
* GH-111485: Allow arbitrary annotations on instructions and micro-ops. ↵Mark Shannon2023-11-071-1/+9
| | | | (GH-111697)
* GH-111485: Make BEFORE_WITH a uop (GH-111812)Brandt Bucher2023-11-071-0/+1
|
* gh-76785: Move _Py_excinfo Functions Out of the Internal C-API (gh-111715)Eric Snow2023-11-062-24/+11
| | | | | I added _Py_excinfo to the internal API (and added its functions in Python/errors.c) in gh-111530 (9322ce9). Since then I've had a nagging sense that I should have added the type and functions in its own PR. While I do plan on using _Py_excinfo outside crossinterp.c very soon (see gh-111572/gh-111573), I'd still feel more comfortable if the _Py_excinfo stuff went in as its own PR. Hence, here we are. (FWIW, I may combine that with gh-111572, which I may, in turn, combine with gh-111573. We'll see.)
* GH-110829: Ensure Thread.join() joins the OS thread (#110848)Antoine Pitrou2023-11-041-0/+42
| | | | | | | Joining a thread now ensures the underlying OS thread has exited. This is required for safer fork() in multi-threaded processes. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-103615: Use local events for opcode tracing (GH-109472)Tian Gao2023-11-033-1/+4
| | | | | | | * Use local monitoring for opcode trace * Remove f_opcode_trace_set * Add test for setting f_trace_opcodes after settrace
* gh-111652: Fix --enable-pystats build (GH-111653)Michael Droettboom2023-11-031-0/+2
|
* gh-106168: Revert the "size before item" setting (#111683)scoder2023-11-031-1/+1
| | | | gh-106168: Update the size only after setting the item, to avoid temporary inconsistencies. Also remove the "what's new" sentence regarding the size setting since tuples cannot grow after allocation.
* gh-111354: Simplify _PyGen_yf by moving some of its work to the compiler and ↵Irit Katriel2023-11-032-5/+8
| | | | frame state (#111648)
* gh-108082: Remove _PyErr_WriteUnraisableMsg() (GH-111643)Serhiy Storchaka2023-11-031-5/+0
| | | | Replace the remaining calls with PyErr_FormatUnraisable().
* gh-111354: simplify detection of RESUME after YIELD_VALUE at except-depth 1 ↵Irit Katriel2023-11-022-3/+5
| | | | (#111459)
* gh-76785: Crossinterp utils additions (gh-111530)Eric Snow2023-11-015-4/+161
| | | | | | | | | | | | This moves several general internal APIs out of _xxsubinterpretersmodule.c and into the new Python/crossinterp.c (and the corresponding internal headers). Specifically: * _Py_excinfo, etc.: the initial implementation for non-object exception snapshots (in pycore_pyerrors.h and Python/errors.c) * _PyXI_exception_info, etc.: helpers for passing an exception beween interpreters (wraps _Py_excinfo) * _PyXI_namespace, etc.: helpers for copying a dict of attrs between interpreters * _PyXI_Enter(), _PyXI_Exit(): functions that abstract out the transitions between one interpreter and a second that will do some work temporarily Again, these were all abstracted out of _xxsubinterpretersmodule.c as generalizations. I plan on proposing these as public API at some point.
* GH-111485: Use micro-ops to split specialization code from base action ↵Mark Shannon2023-11-011-78/+253
| | | | (GH-111561)
* GH-111485: Remove some special cases from the code generator and bytecodes.c ↵Mark Shannon2023-10-311-17/+19
| | | | (GH-111540)
* GH-111485: Increment `next_instr` consistently at the start of the ↵Mark Shannon2023-10-311-5/+6
| | | | instruction. (GH-111486)
* gh-109329: Count tier2 opcode misses (#110561)Michael Droettboom2023-10-311-2/+2
| | | This keeps a separate 'miss' counter for each micro-opcode, incremented whenever a guard uop takes a deoptimization side exit.
* gh-76785: Move the Cross-Interpreter Code to Its Own File (gh-111502)Eric Snow2023-10-304-32/+141
| | | This is partly to clear this stuff out of pystate.c, but also in preparation for moving some code out of _xxsubinterpretersmodule.c. This change also moves this stuff to the internal API (new: Include/internal/pycore_crossinterp.h). @vstinner did this previously and I undid it. Now I'm re-doing it. :/
* gh-90815: Fix mimalloc atomic.h on Windows arm64 (#111527)Victor Stinner2023-10-301-1/+1
| | | | | | | mi_atomic_load_explicit() casts 'p' argument to drop the 'const' qualifier on Windows arm64 platform. Fix the compiler warning: 'function': different 'const' qualifiers (compiling source file ..\Objects\mimalloc\options.c)
* gh-110481: Implement biased reference counting (gh-110764)Sam Gross2023-10-303-13/+92
|
* gh-90815: Add mimalloc memory allocator (#109914)Dino Viehland2023-10-308-2/+3091
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add mimalloc v2.12 Modified src/alloc.c to remove include of alloc-override.c and not compile new handler. Did not include the following files: - include/mimalloc-new-delete.h - include/mimalloc-override.h - src/alloc-override-osx.c - src/alloc-override.c - src/static.c - src/region.c mimalloc is thread safe and shares a single heap across all runtimes, therefore finalization and getting global allocated blocks across all runtimes is different. * mimalloc: minimal changes for use in Python: - remove debug spam for freeing large allocations - use same bytes (0xDD) for freed allocations in CPython and mimalloc This is important for the test_capi debug memory tests * Don't export mimalloc symbol in libpython. * Enable mimalloc as Python allocator option. * Add mimalloc MIT license. * Log mimalloc in Lib/test/pythoninfo.py. * Document new mimalloc support. * Use macro defs for exports as done in: https://github.com/python/cpython/pull/31164/ Co-authored-by: Sam Gross <colesbury@gmail.com> Co-authored-by: Christian Heimes <christian@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
* GH-111339: Fix initialization and finalization of static optimizer types ↵Savannah Ostrowski2023-10-291-0/+5
| | | | (GH-111430)
* gh-109587: Allow "precompiled" perf-trampolines to largely mitigate the cost ↵gsallam2023-10-271-0/+2
| | | | of enabling perf-trampolines (#109666)
* gh-111354: define names for RESUME oparg values (#111365)Irit Katriel2023-10-261-0/+6
|
* gh-109094: replace frame->prev_instr by frame->instr_ptr (#109095)Irit Katriel2023-10-264-26/+16
|
* gh-67224: Show source lines in tracebacks when using the -c option when ↵Pablo Galindo Salgado2023-10-261-0/+3
| | | | running Python (#111200)
* gh-106320: Re-add some PyLong/PyDict C-API functions (GH-#111162)scoder2023-10-252-49/+0
| | | | | | | | * gh-106320: Re-add _PyLong_FromByteArray(), _PyLong_AsByteArray() and _PyLong_GCD() to the public header files since they are used by third-party packages and there is no efficient replacement. See https://github.com/python/cpython/issues/111140 See https://github.com/python/cpython/issues/111139 * gh-111262: Re-add _PyDict_Pop() to have a C-API until a new public one is designed.
* GH-109214: _SET_IP before _PUSH_FRAME (but not _POP_FRAME) (GH-111001)Brandt Bucher2023-10-241-2/+2
|
* gh-109894: Fix initialization of static `MemoryError` in subinterpreter ↵Radislav Chugunov2023-10-231-0/+1
| | | | | | | | | | | | (gh-110911) Fixes #109894 * set `interp.static_objects.last_resort_memory_error.args` to empty tuple to avoid crash on `PyErr_Display()` call * allow `_PyExc_InitGlobalObjects()` to be called on subinterpreter init --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* GH-109369: Add machinery for deoptimizing tier2 executors, both individually ↵Mark Shannon2023-10-231-0/+1
| | | | and globally. (GH-110384)
* gh-84570: Add Timeouts to SendChannel.send() and RecvChannel.recv() (gh-110567)Eric Snow2023-10-171-0/+6
|
* gh-84570: Send-Wait Fixes for _xxinterpchannels (gh-111006)Eric Snow2023-10-171-0/+15
| | | | | There were a few things I did in gh-110565 that need to be fixed. I also forgot to add tests in that PR. (Note that this PR exposes a refleak introduced by gh-110246. I'll take care of that separately.)
* gh-109693: Remove pycore_atomic.h (gh-110992)Donghee Na2023-10-173-557/+4
|
* gh-85283: Build winsound extension with limited C API (#110978)Victor Stinner2023-10-174-18/+0
| | | Replace type->tp_name with PyType_GetQualName().
* gh-110964: Remove private _PyArg functions (#110966)Victor Stinner2023-10-171-0/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the following private functions and structures to pycore_modsupport.h internal C API: * _PyArg_BadArgument() * _PyArg_CheckPositional() * _PyArg_NoKeywords() * _PyArg_NoPositional() * _PyArg_ParseStack() * _PyArg_ParseStackAndKeywords() * _PyArg_Parser structure * _PyArg_UnpackKeywords() * _PyArg_UnpackKeywordsWithVararg() * _PyArg_UnpackStack() * _Py_ANY_VARARGS() Changes: * Python/getargs.h now includes pycore_modsupport.h to export functions. * clinic.py now adds pycore_modsupport.h when one of these functions is used. * Add pycore_modsupport.h includes when a C extension uses one of these functions. * Define Py_BUILD_CORE_MODULE in C extensions which now include directly or indirectly (via code generated by Argument Clinic) pycore_modsupport.h: * _csv * _curses_panel * _dbm * _gdbm * _multiprocessing.posixshmem * _sqlite.row * _statistics * grp * resource * syslog * _testcapi: bad_get() no longer uses METH_FASTCALL calling convention but METH_VARARGS. Replace _PyArg_UnpackStack() with PyArg_ParseTuple(). * _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined by _testcapi sub-modules which need the internal C API (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c, watchers.c. * Remove Include/cpython/modsupport.h header file. Include/modsupport.h no longer includes the removed header file. * Fix mypy clinic.py
* gh-109693: Update _gil_runtime_state.locked to use pyatomic.h (gh-110836)Donghee Na2023-10-161-2/+1
|