Commit Graph

7222 Commits

Author SHA1 Message Date
Mark Shannon efd6236d36
bpo-46072: Add top level stats struct (GH-30169) 2021-12-17 14:48:01 +00:00
Irit Katriel 396b58345f
bpo-45711: Remove type and traceback from exc_info (GH-30122)
* 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
2021-12-17 14:46:22 +00:00
Irit Katriel 8d6155ee9d
bpo-45635: Do not suppress errors in functions called from _PyErr_Display (GH-30073)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2021-12-16 23:00:13 +00:00
Mark Shannon 86f42851c0
Better randomization of stats filenames. (GH-30145) 2021-12-16 15:56:01 +00:00
Brandt Bucher 62a8a0c522
bpo-45829: Check `__getitem__`'s version for overflow before specializing (GH-30129)
* Check __getitem__'s version for overflow.

* Use SPEC_FAIL_OUT_OF_VERSIONS instead
2021-12-16 11:08:20 +00:00
Mark Shannon 342b93f9f2
bpo-46072: Add --with-pystats configure option to simplify gathering of VM stats (GH-30116)
* Simplify specialization stats collection macros.

* Add --enable-pystats option to configure.

* Update specialization summary script to handle larger number of kinds
2021-12-15 15:32:32 +00:00
Mark Shannon 3a60bfef49
bpo-44525: Specialize for calls to type and other builtin classes with 1 argument. (GH-29942) 2021-12-15 15:03:42 +00:00
Mark Shannon 0b50a4f0cd
bpo-46039: Split yield from in two (GH-30035)
* Split YIELD_FROM opcode into SEND and JUMP_ABSOLUTE.

* Remove YIELD_FROM opcode.
2021-12-15 10:30:09 +00:00
Mark Shannon 9f8f45144b
bpo-44525: Split calls into PRECALL and CALL (GH-30011)
* 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.
2021-12-14 18:22:44 +00:00
Irit Katriel d60457a667
bpo-45292: [PEP-654] add except* (GH-29581) 2021-12-14 16:48:15 +00:00
Dong-hee Na 9130a4d620
bpo-45919: Remove out of date comment (GH-30090) 2021-12-14 10:31:41 +09:00
Eric Snow 121f1f893a
bpo-45953: Statically initialize the small ints. (gh-30092)
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
2021-12-13 18:04:05 -07:00
Dong-hee Na 191c431de7
bpo-45919: Use WinAPI GetFileType() in is_valid_fd() (GH-30082) 2021-12-13 21:57:59 +09:00
Kumar Aditya 41026c3155
bpo-45855: Replaced deprecated `PyImport_ImportModuleNoBlock` with PyImport_ImportModule (GH-30046) 2021-12-12 10:45:20 +02:00
Pablo Galindo Salgado 59435eea08
bpo-46042: Improve SyntaxError locations in the symbol table (GH-30059) 2021-12-11 21:28:24 +00:00
Carl Friedrich Bolz-Tereick b593bdc780
bpo-37971: fix the position of decorator application (GH-30027)
The line numbers of actually calling the decorator functions of
functions and classes was wrong (as opposed to loading them, were they
have been correct previously too).

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-12-11 00:45:02 +01:00
Irit Katriel 0fe104fce7
bpo-45635: refactor print_exception_recursive into smaller functions to standardize error handling (GH-30015)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2021-12-10 23:02:10 +00:00
Christian Heimes 16638a4bdb
bpo-45654: No need to freeze types (GH-30028) 2021-12-10 19:09:09 +01:00
neonene 3f398a77d3
bpo-45582: Fix test_embed failure during a PGO build on Windows (GH-30014)
This defines VPATH differently in PGO instrumentation builds, to account for a different default output directory. It also adds sys._vpath on Windows to make the value available to sysconfig so that it can be used in tests.
2021-12-10 17:13:55 +00:00
Gabriele N. Tornetta 50669083fe
bpo-43931: Export Python version as API data (GH-25577)
When Python is embedded in other applications, it is not easy to determine which version of Python is being used. This change exposes the Python version as part of the API data. Tools like Austin (https://github.com/P403n1x87/austin) can benefit from this data when targeting applications like uWSGI, as the Python version can then be inferred systematically by looking at the exported symbols rather than relying on unreliable pattern matching or other hacks (like remote code execution etc...).

Automerge-Triggered-By: GH:pablogsal
2021-12-09 17:52:05 -08:00
Eric Snow c8749b5783
bpo-46008: Make runtime-global object/type lifecycle functions and state 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
2021-12-09 12:59:26 -07:00
Kumar Aditya 44b0e76f2a
bpo-45654: Freeze the runpy module and stuff it imports (GH-29903) 2021-12-09 08:51:09 -08:00
Irit Katriel dc4a212bd3
bpo-45635: continue refactor of print_exception() to standardize error handling (GH-29996)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2021-12-09 14:38:00 +00:00
Brandt Bucher 5de39f4b41
bpo-45510: Check both types when specializing subtraction (GH-29995) 2021-12-09 10:17:16 +09:00
Irit Katriel 2109f7880b
bpo-45711: Remove unnecessary normalization of exc_info (GH-29922) 2021-12-08 20:08:06 +00:00
Irit Katriel f893bb2e01
bpo-45635: refactor print_exception() into smaller functions (GH-29981)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2021-12-08 18:47:27 +00:00
Mark Shannon 69806b9516
bpo-46009: Do not exhaust generator when send() method raises (GH-29986) 2021-12-08 12:09:26 +00:00
Eric Snow 32a67246b0
bpo-46008: Move Py*State init into distinct functions. (gh-29977)
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
2021-12-07 18:59:49 -07:00
Eric Snow 758b74e71e
bpo-46008: Add _PyInterpreterState_Main(). (gh-29978)
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
2021-12-07 18:56:06 -07:00
Eric Snow 1f384e3184
bpo-46008: Stop calling _PyThreadState_Init() in new_threadstate(). (gh-29973)
This simplifies new_threadstate().  We also rename _PyThreadState_Init() to _PyThreadState_SetCurrent() to reflect what it actually does.

https://bugs.python.org/issue46008
2021-12-07 17:26:29 -07:00
Eric Snow 9b577cd01f
bpo-46008: Use PyMem_RawCalloc() to allocate PyThreadState. (GH-29972)
Doing so allows us to stop assigning various fields to `NULL` and 0.  It also more closely matches the behavior of a static initializer.

Automerge-Triggered-By: GH:ericsnowcurrently
2021-12-07 13:37:51 -08:00
Eric Snow 313f92a57b
bpo-46008: Move thread-related interpreter state into a sub-struct. (gh-29971)
This parallels _PyRuntimeState.interpreters.  Doing this helps make it more clear what part of PyInterpreterState relates to its threads.

https://bugs.python.org/issue46008
2021-12-07 14:03:47 -07:00
Eric Snow 8262c96bcc
bpo-46008: Return void from _PyEval_InitState(). (gh-29970)
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
2021-12-07 14:02:17 -07:00
Mark Shannon 064e53d19a
Fix leak when an exception is raised during generator creation. (GH-29960) 2021-12-07 18:05:48 +00:00
Irit Katriel d596acbd3b
bpo-45635: standardize error handling in traceback.c (GH-29905)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2021-12-07 16:17:22 +00:00
Mark Shannon 8319114fee
bpo-45947: Place dict and values pointer at fixed (negative) offset just 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.
2021-12-07 16:02:53 +00:00
Victor Stinner cf7eaa4617
Revert "bpo-28533: Remove asyncore, asynchat, smtpd modules (GH-29521)" (GH-29951)
This reverts commit 9bf2cbc4c4.
2021-12-07 12:31:04 +01:00
Mark Shannon 299483c95d
bpo-45963: Make space for the InterpreterFrame of a generator in that 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.
2021-12-06 10:13:49 +00:00
Guido van Rossum 605f4bf783
Delete orphaned comment (#29917)
(The function this described was deleted by PR #23743, the comment was accidentally retained.)
2021-12-05 09:03:58 -08:00
Irit Katriel 5bb7ef2768
bpo-45607: Make it possible to enrich exception displays via setting their __note__ field (GH-29880) 2021-12-03 22:01:15 +00:00
Christian Heimes 84ca1232b0
bpo-45950: Introduce Bootstrap Python again (#29859)
The build system now uses a :program:`_bootstrap_python` interpreter for
freezing and deepfreezing again. To speed up build process the build tools
:program:`_bootstrap_python` and :program:`_freeze_module` are no longer
build with LTO.

Cross building depends on a build Python interpreter, which must have same
version and bytecode as target host Python.
2021-12-03 16:01:11 +01:00
Dennis Sweeney 03768c4d13
bpo-45885: Specialize COMPARE_OP (GH-29734)
* 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
2021-12-03 11:29:12 +00:00
Steve Dower 99fcf15052
bpo-45582: Port getpath[p].c to Python (GH-29041)
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.
2021-12-03 00:08:42 +00:00
Christian Heimes cb8f491f46
bpo-40280: Optimize ints and and startup on wasm (GH-29887) 2021-12-02 12:19:30 +01:00
Victor Stinner a6c3b0faa1
bpo-45954: Rename PyConfig.no_debug_ranges to code_debug_ranges (GH-29886)
Rename PyConfig.no_debug_ranges to PyConfig.code_debug_ranges and
invert the value.

Document -X no_debug_ranges and PYTHONNODEBUGRANGES env var in
PyConfig.code_debug_ranges documentation.
2021-12-02 11:43:37 +01:00
Mark Shannon 49444fb807
bpo-45753: Interpreter internal tweaks (GH-29575)
* 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.
2021-12-01 12:09:36 +00:00
Irit Katriel 8a45ca542a
bpo-45711: Change exc_info related APIs to derive type and traceback from the exception instance (GH-29780) 2021-11-30 22:37:04 +00:00
Mark Shannon 60929576e4
bpo-45786: Allocate space for frame in frame object. (GH-29729) 2021-11-29 12:34:59 +00:00
Serhiy Storchaka 87d5180b7a
Remove misleading comment in the AST optimizer (#29825) 2021-11-29 11:19:59 +03:00
Christian Heimes f87ea03502
bpo-45915: use fcntl(fd, F_GETFD) in is_valid_fd() (GH-29821) 2021-11-28 19:40:27 +01:00