mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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
This commit is contained in:
parent
2ac0515027
commit
fcb55c0037
14 changed files with 4568 additions and 4569 deletions
|
@ -338,8 +338,11 @@ def _get_instructions_bytes(code, varnames=None, names=None, constants=None,
|
|||
argval, argrepr = _get_const_info(arg, constants)
|
||||
elif op in hasname:
|
||||
argval, argrepr = _get_name_info(arg, names)
|
||||
elif op in hasjabs:
|
||||
argval = arg*2
|
||||
argrepr = "to " + repr(argval)
|
||||
elif op in hasjrel:
|
||||
argval = offset + 2 + arg
|
||||
argval = offset + 2 + arg*2
|
||||
argrepr = "to " + repr(argval)
|
||||
elif op in haslocal:
|
||||
argval, argrepr = _get_name_info(arg, varnames)
|
||||
|
@ -437,9 +440,9 @@ def findlabels(code):
|
|||
for offset, op, arg in _unpack_opargs(code):
|
||||
if arg is not None:
|
||||
if op in hasjrel:
|
||||
label = offset + 2 + arg
|
||||
label = offset + 2 + arg*2
|
||||
elif op in hasjabs:
|
||||
label = arg
|
||||
label = arg*2
|
||||
else:
|
||||
continue
|
||||
if label not in labels:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue