8000 gh-112355: fix calculation of jump target of ENTER_EXECUTOR in dis by iritkatriel · Pull Request #112377 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-112355: fix calculation of jump target of ENTER_EXECUTOR in dis #112377

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 1 commit into from
Nov 24, 2023
Merged
Changes from all 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
gh-112355: fix calculation of jump target of ENTER_EXECUTOR in dis
  • Loading branch information
iritkatriel committed Nov 24, 2023
commit d637953c11362e9a9825fdb3193fea5061979572
7 changes: 6 additions & 1 deletion Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
SET_FUNCTION_ATTRIBUTE = opmap['SET_FUNCTION_ATTRIBUTE']
FUNCTION_ATTR_FLAGS = ('defaults', 'kwdefaults', 'annotations', 'closure')

ENTER_EXECUTOR = opmap['ENTER_EXECUTOR']
LOAD_CONST = opmap['LOAD_CONST']
RETURN_CONST = opmap['RETURN_CONST']
LOAD_GLOBAL = opmap['LOAD_GLOBAL']
Expand Down Expand Up @@ -373,6 +374,8 @@ def _get_argval_argrepr(op, arg, offset, co_consts, names, varname_from_oparg,
argval = offset + 2 + signed_arg*2
caches = _get_cache_size(_all_opname[deop])
argval += 2 * caches
if deop == ENTER_EXECUTOR:
argval += 2
Copy link
Member Author
@iritkatriel iritkatriel Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we didn't need to special case this here, but that would require a change in the oparg (and implementation) of ENTER_EXECUTOR, and I figured this PR should just fix the bug in dis.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this must be the cache of the underlying JUMP_BACKWARD. I think there currently is no way to get that. Not even via _testinternalcapi.

we should file an issue about that, it will get worse once we start putting executors on other ops.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created an issue here: #112383

argrepr = f"to L{labels_map[argval]}"
elif deop in (LOAD_FAST_LOAD_FAST, STORE_FAST_LOAD_FAST, STORE_FAST_STORE_FAST):
arg1 = arg >> 4
Expand Down Expand Up @@ -605,7 +608,9 @@ def _parse_exception_table(code):
return entries

def _is_backward_jump(op):
return 'JUMP_BACKWARD' in opname[op]
return opname[op] in ('JUMP_BACKWARD',
'JUMP_BACKWARD_NO_INTERRUPT',
'ENTER_EXECUTOR')

def _get_instructions_bytes(code, varname_from_oparg=None,
names=None, co_consts=None,
Expand Down
0