8000 gh-90997: bpo-46841: Disassembly of quickened code by penguin-wwy · Pull Request #32099 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-90997: bpo-46841: Disassembly of quickened code #32099

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 16 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Clean code
  • Loading branch information
penguin-wwy committed Mar 24, 2022
commit 9cef324859a5c156dbf74dd5faa41e8d81ba8473
8 changes: 3 additions & 5 deletions Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

def deoptop(op):
name = opname[op]
return opmap[deoptmap[name]] if name in deoptmap else opmap[name]
return opmap[deoptmap[name]] if name in deoptmap else op

def _try_compile(source, name):
"""Attempts to compile the given source, first as an expression and
Expand Down Expand Up @@ -427,12 +427,12 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
argval = None
argrepr = ''
positions = Positions(*next(co_positions, ()))
deop = deoptop(op)
if arg is not None:
# Set argval to the dereferenced value of the argument when
# available, and argrepr to the string representation of argval.
# _disassemble_bytes needs the string repr of the
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
deop = deoptop(op)
argval = arg
if deop in hasconst:
argval, argrepr = _get_const_info(deop, arg, co_consts)
Expand Down Expand Up @@ -466,9 +466,7 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
if arg & (1<<i))
elif deop == BINARY_OP:
_, argrepr = _nb_ops[arg]
name = opname[op]
if not quickened and name in deoptmap:
name = deoptmap[name]
name = opname[op if quickened else deop]
yield Instruction(name, op,
arg, argval, argrepr,
offset, starts_line, is_jump_target, positions)
Expand Down
12 changes: 2 additions & 10 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ def jabs_op(name, op, entries=0):
def_op(name, op, entries)
hasjabs.append(op)

def spec_op(origin_name, spec_name, counter):
op = _empty_slot[counter]
# fill opname
opname[op] = spec_name
opmap[spec_name] = op
deoptmap[op] = opmap[origin_name]

# Instruction opcodes for compiled code
# Blank lines correspond to available opcodes

Expand Down Expand Up @@ -205,6 +198,8 @@ def spec_op(origin_name, spec_name, counter):
hasconst.append(172)


del def_op, name_op, jrel_op, jabs_op

_nb_ops = [
("NB_ADD", "+"),
("NB_AND", "&"),
Expand Down Expand Up @@ -359,6 +354,3 @@ def spec_op(origin_name, spec_name, counter):
"miss",
"deopt",
]

del def_op, name_op, jrel_op, jabs_op, spec_op

0