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:
Mark Shannon 2021-04-01 16:00:31 +01:00 committed by GitHub
parent 2ac0515027
commit fcb55c0037
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 4568 additions and 4569 deletions

View file

@ -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: