summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
...
* gh-104584: Allow unspecialized instructions in superblocks (#106497)Guido van Rossum2023-07-072-126/+438
| | | | | | | | | | | | | | | | This adds several of unspecialized opcodes to superblocks: TO_BOOL, BINARY_SUBSCR, STORE_SUBSCR, UNPACK_SEQUENCE, LOAD_GLOBAL, LOAD_ATTR, COMPARE_OP, BINARY_OP. While we may not want that eventually, for now this helps finding bugs. There is a rudimentary test checking for UNPACK_SEQUENCE. Once we're ready to undo this, that would be simple: just replace the call to variable_used_unspecialized with a call to variable_used (as shown in a comment). Or add individual opcdes to FORBIDDEN_NAMES_IN_UOPS.
* gh-104584: Move super-instruction special-casing to generator (#106500)Guido van Rossum2023-07-072-37/+25
| | | | | | Instead of special-casing specific instructions, we add a few more special values to the 'size' field of expansions, so in the future we can automatically handle additional super-instructions in the generator.
* GH-106057: Handle recursion errors in inline class calls properly. (GH-106108)Mark Shannon2023-07-073-91/+93
|
* gh-104584: Handle EXTENDED_ARG in superblock creation (#106489)Guido van Rossum2023-07-061-0/+16
| | | With test.
* gh-104584: Clean up and fix uops tests and fix crash (#106492)Guido van Rossum2023-07-061-2/+8
| | | | | | | | | | | | The uops test wasn't testing anything by default, and was failing when run with -Xuops. Made the two executor-related context managers global, so TestUops can use them (notably `with temporary_optimizer(opt)`). Made clear_executor() a little more thorough. Fixed a crash upon finalizing a uop optimizer, by adding a `tp_dealloc` handler.
* gh-104584: Fix error handling from backedge optimization (#106484)Guido van Rossum2023-07-064-11/+15
| | | | | | | | | | | | When `_PyOptimizer_BackEdge` returns `NULL`, we should restore `next_instr` (and `stack_pointer`). To accomplish this we should jump to `resume_with_error` instead of just `error`. The problem this causes is subtle -- the only repro I have is in PR gh-106393, at commit d7df54b139bcc47f5ea094bfaa9824f79bc45adc. But the fix is real (as shown later in that PR). While we're at it, also improve the debug output: the offsets at which traces are identified are now measured in bytes, and always show the start offset. This makes it easier to correlate executor calls with optimizer calls, and either with `dis` output. <!-- gh-issue-number: gh-104584 --> * Issue: gh-104584 <!-- /gh-issue-number -->
* gh-105340: include hidden fast-locals in locals() (#105715)Carl Meyer2023-07-052-34/+66
| | | * gh-105340: include hidden fast-locals in locals()
* gh-106320: Fix specialize.c compilation by including pycore_pylifecycle.h ↵Guido van Rossum2023-07-041-0/+1
| | | | | (#106434) Compilation of Python/specialize.c was broken on macOS for me by gh-106400.
* GH-106360: Support very basic superblock introspection (#106422)Mark Shannon2023-07-042-4/+72
| | | * Add len() and indexing support to uop superblocks.
* GH-106008: Fix refleak when peepholing `None` comparisons (#106367)Brandt Bucher2023-07-041-1/+1
|
* gh-106320: Remove private pylifecycle.h functions (#106400)Victor Stinner2023-07-043-2/+5
| | | | | | | Remove private pylifecycle.h functions: move them to the internal C API ( pycore_atexit.h, pycore_pylifecycle.h and pycore_signal.h). No longer export most of these functions. Move _testcapi.test_atexit() to _testinternalcapi.
* gh-106320: Remove _PyUnicode_TransformDecimalAndSpaceToASCII() (#106398)Victor Stinner2023-07-041-0/+1
| | | | | | | | Remove private _PyUnicode_TransformDecimalAndSpaceToASCII() and other private _PyUnicode C API functions: move them to the internal C API (pycore_unicodeobject.h). No longer most of these functions. Replace _testcapi.unicode_transformdecimalandspacetoascii() with _testinternal._PyUnicode_TransformDecimalAndSpaceToASCII().
* gh-106320: Remove more private _PyUnicode C API functions (#106382)Victor Stinner2023-07-031-0/+1
| | | | | | Remove more private _PyUnicode C API functions: move them to the internal C API (pycore_unicodeobject.h). No longer export most pycore_unicodeobject.h functions.
* GH-104584: Fix ENTER_EXECUTOR (GH-106141)Mark Shannon2023-07-037-269/+270
| | | | | | * Check eval-breaker in ENTER_EXECUTOR. * Make sure that frame->prev_instr is set before entering executor.
* gh-106290: Fix edge cases around uops (#106319)Guido van Rossum2023-07-034-228/+263
| | | | | | | | | | - Tweak uops debugging output - Fix the bug from gh-106290 - Rename `SET_IP` to `SAVE_IP` (per https://github.com/faster-cpython/ideas/issues/558) - Add a `SAVE_IP` uop at the start of the trace (ditto) - Allow `unbound_local_error`; this gives us uops for `LOAD_FAST_CHECK`, `LOAD_CLOSURE`, and `DELETE_FAST` - Longer traces - Support `STORE_FAST_LOAD_FAST`, `STORE_FAST_STORE_FAST` - Add deps on pycore_uops.h to Makefile(.pre.in)
* gh-106320: Remove private _PyErr C API functions (#106356)Victor Stinner2023-07-031-0/+1
| | | | Remove private _PyErr C API functions: move them to the internal C API (pycore_pyerrors.h).
* gh-106320: Create pycore_modsupport.h header file (#106355)Victor Stinner2023-07-033-1/+4
| | | | | | | | | | Remove the following functions from the C API, move them to the internal C API: add a new pycore_modsupport.h internal header file: * PyModule_CreateInitialized() * _PyArg_NoKwnames() * _Py_VaBuildStack() No longer export these functions.
* Document PYTHONSAFEPATH along side -P (#106122)Jeremy Paige2023-07-031-2/+2
|
* gh-106320: Use _PyInterpreterState_GET() (#106336)Victor Stinner2023-07-024-14/+11
| | | | Replace PyInterpreterState_Get() with inlined _PyInterpreterState_GET().
* gh-104922: remove PY_SSIZE_T_CLEAN (#106315)Inada Naoki2023-07-021-2/+0
|
* gh-106320: Remove private _PyInterpreterState functions (#106325)Victor Stinner2023-07-023-4/+6
| | | | | | | | | Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
* gh-106320: Remove _PyInterpreterState_Get() alias (#106321)Victor Stinner2023-07-014-13/+13
| | | | Replace calls to the (removed) slow _PyInterpreterState_Get() with fast inlined _PyInterpreterState_GET() function.
* gh-106316: Remove pytime.h header file (#106317)Victor Stinner2023-07-011-0/+1
| | | | | | | | | | | | | | | | | Remove the "cpython/pytime.h" header file: it only contained private functions. Move functions to the internal pycore_time.h header file. Move tests from _testcapi to _testinternalcapi. Rename also test methods to have the same name than tested C functions. No longer export these functions: * _PyTime_Add() * _PyTime_As100Nanoseconds() * _PyTime_FromMicrosecondsClamp() * _PyTime_FromTimespec() * _PyTime_FromTimeval() * _PyTime_GetPerfCounterWithInfo() * _PyTime_MulDiv()
* Fix duplicate word typos in comments (#106225)Md Sadman Chowdhury2023-07-011-1/+1
|
* gh-106149: move unconditional jump direction resolution from optimizer to ↵Irit Katriel2023-07-013-18/+42
| | | | assembler (#106291)
* gh-106145: Make `end_{lineno,col_offset}` required on `type_param` nodes ↵Nikita Sobolev2023-06-301-12/+6
| | | | (#106224)
* gh-106267: Add type cast to generated code (#106289)Kirill Podoprigora2023-06-301-1/+1
|
* gh-106280: Remove unnecessary unreachable code (gh-106285)Dong-hee Na2023-06-301-3/+0
|
* gh-106023: Remove _PyObject_FastCallTstate() function (#106273)Victor Stinner2023-06-301-7/+5
|
* Remove private _PyCodec_Lookup() function (#106269)Victor Stinner2023-06-301-0/+1
| | | | | | | | | | | | | | | Remove the following private functions of the C API: * _PyCodecInfo_GetIncrementalDecoder() * _PyCodecInfo_GetIncrementalEncoder() * _PyCodec_DecodeText() * _PyCodec_EncodeText() * _PyCodec_Forget() * _PyCodec_Lookup() * _PyCodec_LookupTextEncoding() Move these functions to a new pycore_codecs.h internal header file. These functions are no longer exported.
* gh-106182: sys: Intern getfilesystemencoding() and ↵Inada Naoki2023-06-301-5/+25
| | | | | getfilesystemencodeerrors() (#106183) sys: Intern getfilesystemencoding() and getfilesystemencodeerrors()
* fix typos (#106247)Inada Naoki2023-06-302-2/+2
| | | Most typos are in comments, but two typos are in docstring.
* gh-106023: Update code using _PyObject_FastCall() (#106257)Victor Stinner2023-06-306-422/+415
| | | Replace _PyObject_FastCall() calls with PyObject_Vectorcall().
* gh-106210 Remove Emscripten import trampoline (#106211)Hood Chatham2023-06-303-19/+3
| | | | | It's no longer necessary. Co-authored-by: Brett Cannon <brett@python.org>
* GH-106008: Make implicit boolean conversions explicit (GH-106003)Brandt Bucher2023-06-298-903/+1397
|
* gh-105775: Convert LOAD_CLOSURE to a pseudo-op (#106059)hms2023-06-297-661/+652
| | | | | | This enables super-instruction formation, removal of checks for uninitialized variables, and frees up an instruction.
* gh-101006: Improve error handling when read marshal data (GH-101007)Serhiy Storchaka2023-06-291-61/+71
| | | | | | | | * EOFError no longer overrides other errors such as MemoryError or OSError at the start of the object. * Raise more relevant error when the NULL object occurs as a code object component. * Minimize an overhead of calling PyErr_Occurred().
* gh-104584: Emit macro expansions to opcode_metadata.h (#106163)Guido van Rossum2023-06-283-6/+40
| | | | | | | This produces longer traces (superblocks?). Also improved debug output (uop names are now printed instead of numeric opcodes). This would be simpler if the numeric opcode values were generated by generate_cases.py, but that's another project. Refactored some code in generate_cases.py so the essential algorithm for cache effects is only run once. (Deciding which effects are used and what the total cache size is, regardless of what's used.)
* gh-106118: Add O_CLOEXEC preprocessor guard (#106120)Erlend E. Aasland2023-06-281-1/+4
|
* gh-106084: Remove _PyObject_CallMethod() function (#106159)Victor Stinner2023-06-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the following private functions from the public C API: * _Py_CheckFunctionResult() * _PyObject_CallMethod() * _PyObject_CallMethodId() * _PyObject_CallMethodIdNoArgs() * _PyObject_CallMethodIdObjArgs() * _PyObject_CallMethodIdOneArg() * _PyObject_MakeTpCall() * _PyObject_VectorcallMethodId() * _PyStack_AsDict() Move these functions to the internal C API (pycore_call.h). No longer export the following functions: * _PyObject_Call() * _PyObject_CallMethod() * _PyObject_CallMethodId() * _PyObject_CallMethodIdObjArgs() * _PyObject_Call_Prepend() * _PyObject_FastCallDictTstate() * _PyStack_AsDict() The following functions are still exported for stdlib shared extensions: * _Py_CheckFunctionResult() * _PyObject_MakeTpCall() Mark the following internal functions as extern: * _PyStack_UnpackDict() * _PyStack_UnpackDict_Free() * _PyStack_UnpackDict_FreeNoDecRef()
* gh-104584: Change DEOPT_IF in uops executor (#106146)Guido van Rossum2023-06-272-12/+7
| | | This effectively reverts bb578a0, restoring the original DEOPT_IF() macro in ceval_macros.h, and redefining it in the Tier 2 interpreter. We can get rid of the PREDICTED() macros there as well!
* gh-106149: move jump target resolution from optimizer to assembler (#106150)Irit Katriel2023-06-273-100/+108
|
* gh-104584: Fix assert in DEOPT macro -- should fix buildbot (#106131)Guido van Rossum2023-06-271-1/+2
|
* gh-104584: Add #line directives to executor_cases.c.h (#106126)Guido van Rossum2023-06-271-0/+254
|
* gh-104584: Baby steps towards generating and executing traces (#105924)Guido van Rossum2023-06-279-271/+2326
| | | | | Added a new, experimental, tracing optimizer and interpreter (a.k.a. "tier 2"). This currently pessimizes, so don't use yet -- this is infrastructure so we can experiment with optimizing passes. To enable it, pass ``-Xuops`` or set ``PYTHONUOPS=1``. To get debug output, set ``PYTHONUOPSDEBUG=N`` where ``N`` is a debug level (0-4, where 0 is no debug output and 4 is excessively verbose). All of this code is likely to change dramatically before the 3.13 feature freeze. But this is a first step.
* gh-106084: Remove old PyObject call aliases (#106085)Victor Stinner2023-06-265-7/+7
| | | | | | | | | | | | | | Remove old aliases which were kept backwards compatibility with Python 3.8: * _PyObject_CallMethodNoArgs() * _PyObject_CallMethodOneArg() * _PyObject_CallOneArg() * _PyObject_FastCallDict() * _PyObject_Vectorcall() * _PyObject_VectorcallMethod() * _PyVectorcall_Function() Update code which used these aliases to use new names.
* gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr ↵Serhiy Storchaka2023-06-231-7/+5
| | | | | | | | (GH-106034) These functions are broken by design because they discard any exceptions raised inside, including MemoryError and KeyboardInterrupt. They should not be used in new code.
* gh-106030: Miscellaneous fixes in Python/suggestions.c (GH-106031)Serhiy Storchaka2023-06-231-15/+27
| | | | | | | | | | * PyDict_GetItem() and PyObject_HasAttr() suppress arbitrary errors and should not be used. * PyUnicode_CompareWithASCIIString() only works if the second argument is ASCII string. * Refleak in get_suggestions_for_name_error. * Use of borrowed pointer after possible freeing (self). * Add some missing error checks.
* GH-106012: Fix monitoring of static code objects (GH-106017)Mark Shannon2023-06-231-13/+18
|
* gh-105927: PyImport_AddModule() uses _PyWeakref_GET_REF() (#106001)Victor Stinner2023-06-221-3/+19
| | | | | | | It now raises an exception if sys.modules doesn't hold a strong reference to the module. Elaborate the comment explaining why a weak reference is used to create a borrowed reference.