-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-128295: Add value and backoff to CACHE disassembly
#128296
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
base: main
Are you sure you want to change the base?
Conversation
3e7fa3e to
ab86fb7
Compare
value and backoff to CACHE disassembly`value and backoff to CACHE disassembly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely needs a What's New entry as well as a .. versionchanged:: next for the various dis functions.
I also don't really know how this could help for debugging though, because we only fancy render the very first CACHE entry. In addition, are there situations where the value or the backoff are nonzero and are rendered? because otherwise it wouldn't really help IMO.
| data_int = int.from_bytes(data, sys.byteorder) | ||
| argrepr = f"{name}: {data_int}" | ||
| if name == "counter": | ||
| argrepr += f" (value: {data_int >> 4}, backoff: {data_int & 15})" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be extracted into a helper function in case we want to add more information later.
What do you mean? Value and backoff are rendered no matter what they are, zero or non-zero. Idea is to extract and show those components in disassembly. Since counter is 16bit integer with low 4 bits as backoff and 12 high bits as value and it requires you to figure out manually what those numbers are when debugging |
The problem is that we only fancy render the instruction when it's the first entry of a CACHE, as mentioned in this comment: # Only show the fancy argrepr for a CACHE instruction when it's
# the first entry for a particular cache value:So what I want to see is a test case which renders something else than a counter of 0 and a backoff of 0. |
I see.
If it is |
Arf, sorry I misunderstood the comment. NVM on this one. Now for the test: I want a test where what is being rendered is not (value: 0, backoff: 0) but (value: XXX, backof: YYY). AFAIR, this requires specialized bytecode (otherwise, it will always be 0). >>> dis.dis('print()', show_caches=True)
0 RESUME 0
1 LOAD_NAME 0 (print)
PUSH_NULL
CALL 0
CACHE 0 (counter: 0)
CACHE 0 (func_version: 0)
CACHE 0
RETURN_VALUE
>>> dis.dis('print()', show_caches=True, adaptive=True)
0 RESUME 0
1 LOAD_NAME 0 (print)
PUSH_NULL
CALL 0
CACHE 0 (counter: 17 (value: 1, backoff: 0))
CACHE 0 (func_version: 0)
CACHE 0
RETURN_VALUEYou might also want to update |
Inline CACHE exists only for adaptive bytecodes so
Makes sense, but I would wait if this feature gets accepted, otherwise no point in adding tests now |
Yes, but what I meant is that the output of
I think it always makes sense to add test (and if one wants to wait for the feature to be accepted, I wouldn't have written a PR, but that's my own opinion). Btw, I'm neutral on this feature (for those who can make |
valueandbackoffwhen disassemblingCACHEopcode #128295