Brandt Bucher
08b67fb34f
GH-90997: Shrink the LOAD_GLOBAL caches ( #102569 )
2023-03-10 17:01:16 -08:00
Mark Shannon
160f2fe2b9
GH-87849: Simplify stack effect of SEND and specialize it for generators and coroutines. (GH-101788)
2023-02-13 11:24:55 +00:00
penguin_wwy
753fc8a5d6
gh-101632: Add the new RETURN_CONST opcode ( #101633 )
2023-02-07 22:32:21 +00:00
Mark Shannon
f02fa64bf2
GH-100762: Don't call `gen.throw()` in `gen.close()`, unless necessary. (GH-101013)
...
* Store exception stack depth in YIELD_VALUE's oparg and use it avoid expensive gen.throw() in gen.close() where possible.
2023-01-24 17:25:37 +00:00
Irit Katriel
e9ccfe4a63
gh-100712: make it possible to disable specialization (for debugging) ( #100713 )
2023-01-19 18:14:55 +00:00
Mark Shannon
7b14c2ef19
GH-100982: Add `COMPARE_AND_BRANCH` instruction (GH-100983)
2023-01-16 12:35:21 +00:00
Mark Shannon
6e4e14d98f
GH-100923: Embed jump mask in `COMPARE_OP` oparg (GH-100924)
2023-01-11 20:40:43 +00:00
Mark Shannon
28187141cc
GH-99005: Add `CALL_INTRINSIC_1` instruction (GH-100771)
...
* Remove PRINT_EXPR instruction
* Remove STOPITERATION_ERROR instruction
* Remove IMPORT_STAR instruction
2023-01-05 16:05:51 +00:00
Irit Katriel
3dd6ee2c00
gh-99254: remove all unused consts from code objects (GH-99255)
2022-11-11 10:53:43 +00:00
Brandt Bucher
c7f5708714
GH-98686: Get rid of "adaptive" and "quick" instructions (GH-99182)
2022-11-09 10:50:09 -08:00
Mark Shannon
f4adb97506
GH-96793: Implement PEP 479 in bytecode. (GH-99006)
...
* Handle converting StopIteration to RuntimeError in bytecode.
* Add custom instruction for converting StopIteration into RuntimeError.
2022-11-03 11:38:51 +00:00
Brandt Bucher
276d77724f
GH-98686: Quicken everything (GH-98687)
2022-11-02 10:42:57 -07:00
Mark Shannon
22863df7ca
GH-96793: Change `FOR_ITER` to not pop the iterator on exhaustion. (GH-96801)
...
Change FOR_ITER to have the same stack effect regardless of whether it branches or not.
Performance is unchanged as FOR_ITER (and specialized forms jump over the cleanup code).
2022-10-27 11:55:03 +01:00
Irit Katriel
27ce45d8e1
gh-92886: make test_ast pass with -O (assertions off) (GH-98058)
...
-O does not strip docstrings.
Automerge-Triggered-By: GH:iritkatriel
2022-10-07 16:30:23 -07:00
Irit Katriel
6d7a0e0dd7
gh-87092: reduce redundancy and repetition in compiler's optimization stage (GH-96713)
2022-09-13 13:03:41 +01:00
Irit Katriel
4c72517cad
gh-93554: Conditional jump opcodes only jump forward (GH-96318)
2022-09-01 21:36:47 +01:00
Brandt Bucher
5bfb3c372b
GH-90997: Wrap yield from/await in a virtual try/except StopIteration (GH-96010)
2022-08-19 12:33:44 -07:00
Brandt Bucher
e402b26b7f
GH-95113: Don't use EXTENDED_ARG_QUICK in unquickened code (GH-95121)
2022-07-22 11:04:20 -07:00
Irit Katriel
bde06e1b83
gh-92228: disable the compiler's 'small exit block inlining' optimization for blocks that have a line number (GH-94592)
...
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".
2022-07-06 23:38:36 -07:00
Irit Katriel
324d01944d
gh-94485: Set line number of module's RESUME instruction to 0, as specified by PEP 626 (GH-94552)
...
Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-07-05 14:38:44 +02:00
Irit Katriel
c57aad777a
gh-94216: add pseudo instructions to the dis/opcodes modules (GH-94241)
2022-07-01 15:33:35 +01:00
Dennis Sweeney
5fcfdd87c9
GH-91432: Specialize FOR_ITER (GH-91713)
...
* Adds FOR_ITER_LIST and FOR_ITER_RANGE specializations.
* Adds _PyLong_AssignValue() internal function to avoid temporary boxing of ints.
2022-06-21 11:19:26 +01:00
Brandt Bucher
f8e576be0a
GH-91389: Fix dis position information for CACHEs (GH-93663)
2022-06-16 13:49:32 -07:00
Ken Jin
b083450f88
GH-93429: Merge `LOAD_METHOD` back into `LOAD_ATTR` (GH-93430)
2022-06-14 11:36:22 +01:00
Irit Katriel
cf730b595e
GH-93621: reorder code in with/async-with exception exit path to reduce the size of the exception table (GH-93622)
2022-06-10 17:53:34 +01:00
Mark Shannon
f012df706c
Shrink the LOAD_METHOD cache by one codeunit. ( #93537 )
2022-06-07 10:28:53 +01:00
Dong-hee Na
b013804134
gh-92932: dis._unpack_opargs should handle EXTENDED_ARG_QUICK (gh-92945)
2022-06-03 11:29:27 +09:00
Irit Katriel
94b1586ca5
gh-93356: Lay out exception handling code at end of code unit (GH-92769)
2022-06-02 14:13:43 +01:00
Dennis Sweeney
f425f3bb27
gh-93143: Avoid NULL check in LOAD_FAST based on analysis in the compiler (GH-93144)
2022-05-31 16:32:30 -04:00
Dennis Sweeney
ddc4a782d3
gh-93223: More aggressive Jump-To-Jump elimination (GH-93229)
2022-05-27 11:17:59 +01:00
Mark Shannon
e48ac9c100
GH-90690: Remove `PRECALL` instruction (GH-92925)
2022-05-19 11:05:26 +01:00
Irit Katriel
7c6b7ade8d
gh-92619: Fix bug where the compiler duplicates exit blocks unnecessarily (GH-92620)
2022-05-10 13:36:08 +01:00
Brandt Bucher
93a666b5a5
gh-90997: Show cached inline values in `dis` output ( #92360 )
2022-05-06 15:18:09 +01:00
Irit Katriel
84b986ba10
gh-91276: revert the increase of dis output width (GH-92126)
2022-05-02 16:51:17 +01: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
penguin_wwy
e590379197
gh-90997: bpo-46841: Disassembly of quickened code (GH-32099)
2022-04-19 09:45:08 +01:00
Irit Katriel
e44f988b26
gh-91276: make space for longer opcodes in dis output (GH-91444)
2022-04-12 14:35:56 +01: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
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
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
f193631387
bpo-46841: Use inline caching for calls (GH-31709)
2022-03-07 11:45:00 -08:00
Brandt Bucher
05a8bc1c94
bpo-46841: Use inline caching for attribute accesses (GH-31640)
2022-03-03 15:31:00 -08:00
Brandt Bucher
7820a5897e
bpo-46841: Use inline caching for `COMPARE_OP` (GH-31622)
2022-03-01 13:53:13 +00:00
Mark Shannon
4558af5a8f
bpo-46841: Move the cache for `LOAD_GLOBAL` inline. (GH-31575)
2022-02-28 12:56:29 +00:00
Brandt Bucher
0f41aac109
bpo-46841: Use *inline* caching for `BINARY_OP` (GH-31543)
2022-02-25 12:11:34 +00: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
Saul Shanabrook
c3ce7781e3
bpo-46724: Fix dis support for overflow args (GH-31285)
2022-02-18 09:56:23 +00:00
Mark Shannon
3954fcb83f
Remove offsets from expected output in test.test_dis (GH-31369)
2022-02-16 12:19:09 +00:00
Mark Shannon
89fd7c3452
bpo-46329: Split calls into precall and call instructions. (GH-30855)
...
* Add PRECALL_FUNCTION opcode.
* Move 'call shape' varaibles into struct.
* Replace CALL_NO_KW and CALL_KW with KW_NAMES and CALL instructions.
* Specialize for builtin methods taking using the METH_FASTCALL | METH_KEYWORDS protocol.
* Allow kwnames for specialized calls to builtin types.
* Specialize calls to tuple(arg) and str(arg).
2022-01-28 12:42:30 +00:00
Irit Katriel
3d2ce34716
bpo-46458: emit code for else of a try block immediately after the try body (GH-30751)
2022-01-27 13:40:44 +00:00
Brandt Bucher
8548366864
bpo-46528: Simplify the VM's stack manipulations (GH-30902)
2022-01-26 12:47:45 -08:00
Nikita Sobolev
84f093918a
bpo-45578: add a test case for `dis.findlabels` (GH-30058)
2022-01-26 19:05:35 +09:00
Nikita Sobolev
58f3d98098
bpo-46422: use `dis.Positions` in `dis.Instruction` (GH-30716)
...
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
2022-01-24 14:09:20 +03:00
Irit Katriel
9c2ebb906d
bpo-46344: Fix trace bug in else of try and try-star blocks (GH-30544)
2022-01-13 12:34:38 +00:00
Mark Shannon
e028ae99ec
bpo-45923: Handle call events in bytecode (GH-30364)
...
* Add a RESUME instruction to handle "call" events.
2022-01-06 13:09:25 +00:00
Irit Katriel
a94461d718
bpo-46202: Remove opcode POP_EXCEPT_AND_RERAISE (GH-30302)
...
* bpo-46202: remove opcode POP_EXCEPT_AND_RERAISE
* do not assume that an exception group is truthy
2022-01-04 10:37:12 +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
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
Mark Shannon
135cabd328
bpo-44525: Copy free variables in bytecode to allow calls to inner functions 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.
2021-11-23 09:53:24 +00:00
Brandt Bucher
9178f533ff
bpo-45636: Merge all numeric operators (GH-29482)
2021-11-10 22:56:22 -08:00
Irit Katriel
4cdeee5978
bpo-45711: remove unnecessary DUP_TOP and POP in exception handling (GH-29495)
2021-11-10 18:08:28 +00:00
Irit Katriel
cb414cf0e2
bpo-45757: Fix bug where dis produced an incorrect oparg on EXTENDED_ARG before a no-arg opcode (GH-29480)
2021-11-09 20:07:38 +00:00
Nikita Sobolev
e346f19681
bpo-45578: add tests for `dis.distb` (GH-29332)
2021-11-03 14:55:42 +01:00
Mark Shannon
f6eafe18c0
Normalize jumps in compiler. All forward jumps to use JUMP_FORWARD. (GH-28755)
2021-10-06 13:05:45 +01:00
Irit Katriel
c99fc4e53a
bpo-45168: change dis output to omit missing values rather than replacing them by their index (GH-28313)
2021-09-14 10:09:05 +01:00
Irit Katriel
04676b6946
bpo-45017: move opcode-related logic from modulefinder to dis (GH-28246)
2021-09-09 14:04:12 +01:00
Batuhan Taskaya
85ea2d6165
bpo-43950: support positions for dis.Instructions created through dis.Bytecode (GH-28142)
2021-09-03 18:29:09 +03:00
Inada Naoki
55c4a92fc1
bpo-45056: Remove trailing unused constants from co_consts (GH-28109)
2021-09-02 13:02:06 +02:00
Mark Shannon
b854557b49
bpo-44840: Compiler: Move duplication of exit blocks with no line numbers to after CFG optimization. (GH-27656)
2021-08-09 10:18:59 +01:00
Mark Shannon
a86f7dae0a
bpo-44626: Merge basic blocks earlier to enable better handling of exit blocks without line numbers (GH-27138)
2021-07-15 17:46:55 +01:00
Ammar Askar
4823d9a512
bpo-43950: Add option to opt-out of PEP-657 (GH-27023)
...
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
2021-07-07 20:07:12 +01:00
Gabriele N. Tornetta
2f180ce2cb
bpo-44530: Add co_qualname field to PyCodeObject (GH-26941)
2021-07-07 12:21:51 +01:00
Batuhan Taskaya
693cec0e2d
bpo-43950: include position in dis.Instruction (GH-27015)
...
Automerge-Triggered-By: GH:isidentical
2021-07-04 12:05:05 -07:00
Guido van Rossum
769d7d0c66
bpo-43693 Get rid of CO_NOFREE -- it's unused (GH-26839)
...
All uses of this flag are either setting it
or in doc or tests for it. So we should be
able to get rid of it completely.
2021-06-23 09:51:44 -07:00
Eric Snow
ac38a9f2df
bpo-43693: Eliminate unused "fast locals". (gh-26587)
...
Currently, if an arg value escapes (into the closure for an inner function) we end up allocating two indices in the fast locals even though only one gets used. Additionally, using the lower index would be better in some cases, such as with no-arg `super()`. To address this, we update the compiler to fix the offsets so each variable only gets one "fast local". As a consequence, now some cell offsets are interspersed with the locals (only when an arg escapes to an inner function).
https://bugs.python.org/issue43693
2021-06-15 16:35:25 -06:00
Eric Snow
3e1c7167d8
bpo-43693: Un-revert commit f3fa63e
. ( #26609 )
...
This was reverted in GH-26596 (commit 6d518bb
) due to some bad memory accesses.
* Add the MAKE_CELL opcode. (gh-26396)
The memory accesses have been fixed.
https://bugs.python.org/issue43693
2021-06-08 16:01:34 -06:00
Pablo Galindo
3fe921cd49
Revert "bpo-43693: Add the MAKE_CELL opcode and interleave fast locals offsets. (gh-26396)" (GH-26597)
...
This reverts commit 631f9938b1
.
2021-06-08 13:17:55 +01:00
Eric Snow
631f9938b1
bpo-43693: Add the MAKE_CELL opcode and interleave fast locals offsets. (gh-26396)
...
This moves logic out of the frame initialization code and into the compiler and eval loop. Doing so simplifies the runtime code and allows us to optimize it better.
https://bugs.python.org/issue43693
2021-06-07 16:52:00 -06:00
Eric Snow
2ab27c4af4
bpo-43693: Un-revert commits 2c1e258
and b2bf2bc
. (gh-26577)
...
These were reverted in gh-26530 (commit 17c4edc
) due to refleaks.
* 2c1e258
- Compute deref offsets in compiler (gh-25152)
* b2bf2bc
- Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388)
This change fixes the refleaks.
https://bugs.python.org/issue43693
2021-06-07 12:22:26 -06:00
Pablo Galindo
17c4edc4e0
bpo-43693: Revert commits 2c1e2583fd
and b2bf2bc1ec
(GH-26530)
...
* Revert "bpo-43693: Compute deref offsets in compiler (gh-25152)"
This reverts commit b2bf2bc1ec
.
* Revert "bpo-43693: Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388)"
This reverts commit 2c1e2583fd
.
These two commits are breaking the refleak buildbots.
2021-06-04 17:51:05 +01:00
Mark Shannon
b2bf2bc1ec
bpo-43693: Compute deref offsets in compiler (gh-25152)
...
Merges locals and cells into a single array.
Saves a pointer in the interpreter and means that we don't need the LOAD_CLOSURE opcode any more
https://bugs.python.org/issue43693
2021-06-03 18:03:54 -06:00
Mark Shannon
adcd220556
bpo-40222: "Zero cost" exception handling (GH-25729)
...
"Zero cost" exception handling.
* Uses a lookup table to determine how to handle exceptions.
* Removes SETUP_FINALLY and POP_TOP block instructions, eliminating (most of) the runtime overhead of try statements.
* Reduces the size of the frame object by about 60%.
2021-05-07 15:19:19 +01:00
Mark Shannon
5979e81a21
bpo-43933: Set frame.f_lineno during call to __exit__ (GH-25719)
...
* Set line number of __exit__ call in a with statement to be that of the with keyword.
2021-04-30 14:32:47 +01:00
Mark Shannon
c76da79b37
bpo-42739: Don't use sentinels to mark end of line table. (GH-25657)
...
* Add length parameter to PyLineTable_InitAddressRange and doen't use sentinel values at end of table. Makes the line number table more robust.
* Update PyCodeAddressRange to match PEP 626.
2021-04-29 13:12:51 +01:00
Pablo Galindo
b0544ba77c
bpo-38605: Revert making 'from __future__ import annotations' the default (GH-25490)
...
This reverts commits 044a1048ca
and 1be456ae9d
, adapting the code to changes that happened after it.
2021-04-21 12:41:19 +01:00
Mark Shannon
fcb55c0037
bpo-27129: Use instruction offsets, not byte offsets, in bytecode and internally. (GH-25069)
...
* Use instruction offset, rather than bytecode offset. Streamlines interpreter dispatch a bit, and removes most EXTENDED_ARGs for jumps.
* Change some uses of PyCode_Addr2Line to PyFrame_GetLineNumber
2021-04-01 16:00:31 +01:00
Mark Shannon
3bd6035b6b
bpo-42908: Mark cleanup code at end of try-except and with artificial ( #24202 )
...
* Mark bytecodes at end of try-except as artificial.
* Make sure that the CFG is consistent throughout optimiization.
* Extend line-number propagation logic so that implicit returns after 'try-except' or 'with' have the correct line numbers.
* Update importlib
2021-01-13 12:05:43 +00:00
Mark Shannon
28b75c80dc
bpo-42246: Don't eliminate jumps to jumps, if it will break PEP 626. (GH-23896)
2020-12-23 11:43:10 +00:00
Mark Shannon
f2dbfd7e20
bpo-42634: Mark reraise after except blocks as artificial. (GH-23877)
...
* Mark reraise after except blocks as artificial.
* Update importlib
* Update dis test.
2020-12-21 13:53:50 +00:00
Max Bernstein
6e799be0a1
bpo-42199: Fix bytecode_helper assertNotInBytecode ( #23031 )
...
* bpo-42199: Fix bytecode_helper assertNotInBytecode
Add tests.
* 📜 🤖 Added by blurb_it.
Co-authored-by: Dino Viehland <dinoviehland@fb.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2020-12-17 16:30:29 -08:00
Mark Shannon
bf353f3c2d
bpo-42246: Make sure that `f_lasti`, and thus `f_lineno`, is set correctly after raising or reraising an exception (GH-23803)
...
* Ensure that f_lasti is set correctly after an exception is raised to conform to PEP 626.
* Update importlib
* Add NEWS.
2020-12-17 13:55:28 +00:00
Mark Shannon
5274b682bc
bpo-42645: Make sure that return/break/continue are only traced once when exiting via a finally block. (GH-23780)
...
* Make sure that return/break/continue are only traced once when exiting via a finally block.
* Add test for return in try-finally.
* Update importlib
2020-12-16 13:07:01 +00:00
Mark Shannon
8473cf89bd
bpo-42246: Remove DO_NOT_EMIT_BYTECODE macros, so that while loops and if statements conform to PEP 626. (GH-23743)
2020-12-15 11:07:50 +00:00
Yurii Karabas
f24b8101a0
bpo-42562: Fix issue when dis failed to parse function that has no line numbers (GH-23632)
...
Fix issue when dis failed to parse function that has only annotations
2020-12-04 15:20:53 +00:00
Mark Shannon
5977a7989d
bpo-42246: Make sure that line number is correct after a return, as required by PEP 626 (GH-23495)
...
Make sure that line number is correct after a return, as defined by PEP 626.
2020-12-02 13:31:40 +00:00
Mark Shannon
266b462238
bpo-42349: Compiler clean up. More yak-shaving for PEP 626. (GH-23267)
...
Make sure that CFG from compiler front-end is correct. Be a bit more aggressive in the compiler back-end.
2020-11-17 19:30:14 +00:00