Commit graph

931 commits

Author SHA1 Message Date
Irit Katriel
99ab0d49e2
[3.11] gh-116034: fix location info on the error of a failed assertion (#116052) 2024-02-28 19:12:16 +00:00
Erlend E. Aasland
90e357bc8a
[3.11] gh-105375: Improve error handling in compiler_enter_scope() (#105494) (#105582)
(cherry picked from commit 6c832ddcf2)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-09 17:36:06 +00:00
Jelle Zijlstra
48957888d2
[3.11] gh-105164: Detect annotations inside match blocks (GH-105177). (#105314)
(cherry picked from commit 69d1245685)
2023-06-05 13:46:12 +00:00
Carl Meyer
667e4ece98
[3.11] gh-104615: don't make unsafe swaps in apply_static_swaps (GH-104620). (#104636)
(cherry picked from commit 0589c6a4d3)
2023-05-19 12:04:04 -06:00
Tian Gao
fee3c91a19
[3.11] GH-103971: Fix incorrect locations for code following case blocks 2023-04-28 20:08:25 +00:00
Irit Katriel
93a9535d54
[3.11] gh-101517: fix line number propagation in code generated for except* (#103550) (#103816)
Manual backport of https://github.com/python/cpython/pull/103550.



<!-- gh-issue-number: gh-101517 -->
* Issue: gh-101517
<!-- /gh-issue-number -->

---------

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-04-25 18:08:54 +01:00
Dong-hee Na
0c37ea9aba
[3.11] gh-101400: Fix incorrect lineno in exception message on contin… (gh-101447) 2023-01-31 23:53:14 +09:00
Brandt Bucher
0e61d2b557
[3.11] GH-95921: Fix positions for some chained comparisons (GH-96968) (GH-96973)
(cherry picked from commit dfc73b5724)

Automerge-Triggered-By: GH:brandtbucher
2022-09-20 14:56:38 -07:00
Brandt Bucher
064462a719
[3.11] GH-94036: Fix more attribute location quirks (GH-95028) (GH-95156)
(cherry picked from commit 900bfc53cb)
2022-07-22 17:31:06 -07:00
Brandt Bucher
5a48ab01e9
[3.11] GH-95113: Don't use EXTENDED_ARG_QUICK in unquickened code (GH-95121) (GH-95143)
(cherry picked from commit e402b26b7f)
2022-07-22 11:56:10 -07:00
Brandt Bucher
e2fce3a8e7
[3.11] GH-91409: Don't overwrite valid locations with NOP locations (GH-95067) (GH-95068)
(cherry picked from commit 742d4614e1)
2022-07-20 15:01:42 -07:00
Miss Islington (bot)
16cb8ca52e
GH-94851: fix immortal objects refcounting in compiler (gh-95040)
(cherry picked from commit 7476154886)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-07-20 03:42:05 -07:00
Brandt Bucher
e5c8ad3e15
[3.11] GH-94694: Fix column offsets for multi-line method lookups (GH-94721)
(cherry picked from commit 264b3ddfd5)
2022-07-09 22:12:45 -07:00
Christian Heimes
74c953d396
[3.11] gh-92228: disable the compiler's 'small exit block inlining' optimization for blocks that have a line number (GH-94592) (GH-94643)
Inlining of code that corresponds to source code lines, can make it hard to distinguish later between code which is only reachable from except handlers, and that which is reachable in normal control flow. This caused problems with the debugger's jump feature.

This PR turns off the inlining optimisation for code which has line numbers. We still inline things like the implicit "return None"..
(cherry picked from commit bde06e1b83)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2022-07-07 03:10:32 -07:00
Łukasz Langa
1bfe83a114
[3.11] gh-94485: Set line number of module's RESUME instruction to 0 as specified by PEP 626 (GH-94552) (GH-94562)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Mark Shannon <mark@hotpy.org>

(cherry picked from commit 324d01944d)
2022-07-05 16:01:24 +02:00
Miss Islington (bot)
f58c366a73
GH-94329: Don't raise on excessive stack consumption (GH-94421) (GH-94446)
(cherry picked from commit b152bf448b)
2022-06-30 15:53:20 +01:00
Irit Katriel
48a739ec10
gh-94332: make it safe to call assemble_free when assemble_init has not been called (GH-94389) (GH-94442)
(cherry picked from commit be82d26570)
2022-06-30 15:30:12 +01:00
Irit Katriel
df091e14d8
[3.11] GH-93662: Make sure that column offsets are correct in multi-line method calls. (GH-93673) (#93895)
Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-06-16 11:56:35 +01:00
Miss Islington (bot)
f0950585a3
gh-93061: Mark as artificial: backwards jump after async for (GH-93062) (GH-93110)
(cherry picked from commit a458be3263)

Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
2022-05-23 14:58:53 -04:00
Miss Islington (bot)
6a17cdebe9
gh-92619: Fix bug where the compiler duplicates exit blocks unnecessarily (GH-92620) (GH-92621)
(cherry picked from commit 7c6b7ade8d)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2022-05-10 22:01:17 +01:00
Dennis Sweeney
37c6db60f9
gh-91869: Fix tracing of specialized instructions with extended args (GH-91945) 2022-04-27 22:36:34 -06:00
Victor Stinner
64a54e511d
gh-91719: Add pycore_opcode.h internal header file (#91906)
Move the following API from Include/opcode.h (public C API) to a new
Include/internal/pycore_opcode.h header file (internal C API):

* EXTRA_CASES
* _PyOpcode_Caches
* _PyOpcode_Deopt
* _PyOpcode_Jump
* _PyOpcode_OpName
* _PyOpcode_RelativeJump
2022-04-26 00:14:30 +02:00
Mark Shannon
944fffee89
GH-88116: Use a compact format to represent end line and column offsets. (GH-91666)
* Stores all location info in linetable to conform to PEP 626.

* Remove column table from code objects.

* Remove end-line table from code objects.

* Document new location table format
2022-04-21 16:10:37 +01:00
Kumar Aditya
ab0d35d70d
bpo-46712: share more global strings in deepfreeze (gh-32152)
(for gh-90868)
2022-04-19 11:41:36 -06:00
Irit Katriel
304f5b63e9
Fix an out of date comment in compile.c (GH-91615) 2022-04-16 20:40:02 +01:00
Irit Katriel
ea2ae02607
gh-91276: Make JUMP_IF_TRUE_OR_POP/JUMP_IF_FALSE_OR_POP relative (GH-32215) 2022-04-15 20:19:24 +01:00
L. A. F. Pereira
5f056acdf2
Fill holes in internal compiler structs (#91458) 2022-04-13 15:09:20 -07:00
Irit Katriel
dd207a6ac5
bpo-47120: make POP_JUMP_IF_TRUE/FALSE/NONE/NOT_NONE relative (GH-32400) 2022-04-11 10:40:24 +01:00
Irit Katriel
0aa8d5cbd8
bpo-47120: make JUMP_NO_INTERRUPT relative (GH-32221) 2022-04-05 12:49:08 +01:00
Irit Katriel
32091df41c
bpo-47186: Replace JUMP_IF_NOT_EG_MATCH by CHECK_EG_MATCH + jump (GH-32309) 2022-04-05 12:06:22 +01:00
Irit Katriel
997ba5d126
bpo-47172: Compiler enhancements (GH-32200)
* Make virtual opcodes negative. 

* Make is_jump detect only actual jumps.

* Use is_block_push for the exception block setup opcodes.
2022-04-01 15:50:15 +01:00
Irit Katriel
04e07c258f
bpo-47186: Replace JUMP_IF_NOT_EXC_MATCH by CHECK_EXC_MATCH + jump (GH-32231) 2022-04-01 13:59:38 +01:00
Irit Katriel
a00518d9ad
bpo-47120: Replace the JUMP_ABSOLUTE opcode by the relative JUMP_BACKWARD (GH-32115) 2022-03-31 14:14:15 +01:00
Matthew Rahtz
e8e737bcf6
bpo-43224: Implement PEP 646 grammar changes (GH-31018)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-26 09:55:35 -07:00
Brandt Bucher
2bde6827ea
bpo-46841: Quicken code in-place (GH-31888)
* Moves the bytecode to the end of the corresponding PyCodeObject, and quickens it in-place.

* Removes the almost-always-unused co_varnames, co_freevars, and co_cellvars member caches

* _PyOpcode_Deopt is a new mapping from all opcodes to their un-quickened forms.

* _PyOpcode_InlineCacheEntries is renamed to _PyOpcode_Caches

* _Py_IncrementCountAndMaybeQuicken is renamed to _PyCode_Warmup

* _Py_Quicken is renamed to _PyCode_Quicken

* _co_quickened is renamed to _co_code_adaptive (and is now a read-only memoryview).

* Do not emit unused nonzero opargs anymore in the compiler.
2022-03-21 11:11:17 +00:00
Mark Shannon
3011a097bd
Use low bit of LOAD_GLOBAL's oparg to indicate whether it should push an additional NULL. (GH-31933) 2022-03-17 16:14:57 +00:00
Brandt Bucher
586b24d3be
bpo-46841: Fix error message hacks in GET_AWAITABLE (GH-31664) 2022-03-04 12:41:17 +00:00
Shantanu
81d968b7c3
bpo-46831: Update __build_class__ comment (#31522)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-02 21:32:57 -08:00
Inada Naoki
df9f759755
compiler: Merge except_table and cnotab (GH-31614) 2022-03-01 10:27:20 +09:00
Mark Shannon
4558af5a8f
bpo-46841: Move the cache for LOAD_GLOBAL inline. (GH-31575) 2022-02-28 12:56:29 +00:00
Irit Katriel
c579243eb6
bpo-46808: remove NEXT_BLOCK() from compile.c (GH-31448) 2022-02-25 12:17:50 +00:00
Brandt Bucher
0f41aac109
bpo-46841: Use *inline* caching for BINARY_OP (GH-31543) 2022-02-25 12:11:34 +00:00
Eric Snow
1f455361ec
bpo-46765: Replace Locally Cached Strings with Statically Initialized Objects (gh-31366)
https://bugs.python.org/issue46765
2022-02-22 17:23:51 -07:00
Mark Shannon
59585d6b2e
bpo-46329: Streamline calling sequence a bit. (GH-31465)
* Move handling of bound-methods to PRECALL.

* Remove call_shape.postcall_shrink

* Remove call_shape.callable

* Remove call_shape.callable. Change CALL oparg to match PRECALL oparg.

* Move KW_NAMES before PRECALL.

* Update opcode docs in dis.rst
2022-02-21 18:26:47 +00:00
Mark Shannon
cf345e945f
bpo-46329: Change calling sequence (again) (GH-31373)
* Change calling sequence: Add PUSH_NULL. Merge PRECALL_FUNCTION and PRECALL_METHOD into PRECALL.
2022-02-18 17:19:08 +00:00
Mark Shannon
3be1a443ca
bpo-46724: Use JUMP_ABSOLUTE for all backward jumps. (GH-31326)
* Make sure all backward jumps use JUMP_ABSOLUTE.

* Add news.

* Fix up news item.

* Make test use consistent style.
2022-02-15 09:35:16 +00:00
Eric Snow
12360aa159
bpo-46541: Discover the global strings. (gh-31346)
Instead of manually enumerating the global strings in generate_global_objects.py, we extrapolate the list from usage of _Py_ID() and _Py_STR() in the source files.

This is partly inspired by gh-31261.

https://bugs.python.org/issue46541
2022-02-14 17:36:51 -07:00
Brandt Bucher
3b799d7448
Remove unnecessary basic block from comprehensions (GH-31263) 2022-02-14 17:48:45 +00:00
Brandt Bucher
78ae4cc6dc
bpo-46528: Attempt SWAPs at compile-time (GH-30970) 2022-02-09 15:15:36 -08:00
Brandt Bucher
46328d8ae6
bpo-46528: Check PyMem_Malloc for NULL (GH-30998) 2022-02-09 11:31:01 -08:00