8000 GH-105848: Simplify the arrangement of `CALL`'s stack by brandtbucher · Pull Request #107788 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-105848: Simplify the arrangement of CALL's stack #107788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ the following command can be used to display the disassembly of
>>> dis.dis(myfunc)
2 0 RESUME 0
<BLANKLINE>
3 2 LOAD_GLOBAL 1 (NULL + len)
3 2 LOAD_GLOBAL 1 (len + NULL)
12 LOAD_FAST 0 (alist)
14 CALL 1
22 RETURN_VALUE
Expand Down
6 changes: 3 additions & 3 deletions Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,15 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
if deop == LOAD_GLOBAL:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL + " + argrepr
argrepr = f"{argrepr} + NULL"
elif deop == LOAD_ATTR:
argval, argrepr = _get_name_info(arg//2, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
argrepr = f"{argrepr} + NULL|self"
elif deop == LOAD_SUPER_ATTR:
argval, argrepr = _get_name_info(arg//4, get_name)
if (arg & 1) and argrepr:
argrepr = "NULL|self + " + argrepr
argrepr = f"{argrepr} + NULL|self"
else:
argval, argrepr = _get_name_info(arg, get_name)
elif deop in hasjabs:
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_compiler_assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def inner():

instructions = [
('RESUME', 0,),
('PUSH_NULL', 0, 1),
('LOAD_CLOSURE', 0, 1),
('BUILD_TUPLE', 1, 1),
('LOAD_CONST', 1, 1),
('MAKE_FUNCTION', 0, 2),
('SET_FUNCTION_ATTRIBUTE', 8, 2),
('PUSH_NULL', 0, 1),
('CALL', 0, 2), # (lambda: x)()
('LOAD_CONST', 2, 2), # 2
('BINARY_OP', 6, 2), # %
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_compiler_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def test_for_loop(self):
loop_lbl := self.Label(),
('FOR_ITER', exit_lbl := self.Label(), 1),
('STORE_NAME', 1, 1),
('PUSH_NULL', None, 2),
('LOAD_NAME', 2, 2),
('PUSH_NULL', None, 2),
('LOAD_NAME', 1, 2),
('CALL', 1, 2),
('POP_TOP', None),
Expand Down
56 changes: 28 additions & 28 deletions Lib/test/test_dis.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Modify the bytecode so that the actual callable for a :opcode:`CALL` is at a
consistent position on the stack (regardless of whether or not
bound-method-calling optimizations are active).
2 changes: 1 addition & 1 deletion Objects/exception_handling_notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ a table to determine where to jump to when an exception is raised.

2 2 NOP

3 4 LOAD_GLOBAL 1 (NULL + g)
3 4 LOAD_GLOBAL 1 (g + NULL)
16 LOAD_CONST 1 (0)
18 PRECALL 1
22 CALL 1
Expand Down
22 changes: 11 additions & 11 deletions Programs/test_frozenmain.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
0