-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Fix stack effect #43
Fix stack effect #43
Conversation
Codecov Report
@@ Coverage Diff @@
## master #43 +/- ##
=========================================
Coverage ? 93.67%
=========================================
Files ? 17
Lines ? 2623
Branches ? 0
=========================================
Hits ? 2457
Misses ? 166
Partials ? 0
Continue to review full report at Codecov.
|
This is a subtle but critical detail. Thanks for the reminder! |
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.
Some minor comment edits suggestion (this new Github feature is great !) but otherwise this is good to go. Please check the length of the lines of my edits github does not provide yet rulers.
Fix #38.
@MatthieuDartiailh
If
dis.stack_effect
doesn't convert oparg when unnecessarily, we wouldn't get this error.https://github.com/python/cpython/blob/137b0632dccb992ca11e9445142fb33a29c33a51/Modules/_opcode.c#L38
However, for we cannot change the standard module immediately, we have to avoid passing the oparg when we didn't calculate the operand of an instruction.
For instance,
Instr('LOAD_CONST', 0xFFFFFFFFFFFFFFF)
might donate bytecodeLOAD_CONST 1
, and when we calculate its stack effect, we should usedis.stack_effect(100, 1)
instead ofdis.stack_effect(100, 0xFFFFFFFFFFFFFFF)
.Actually we cannot convert
0xFFFFFFFFFFFFFFF
to1
when calculating stack effects, fortunately if we have to convert the oparg ofInstr
to the operand of bytecode instruction, it means that the oparg is insignificant to the result.Thanks @serhiy-storchaka for
https://github.com/python/cpython/blob/137b0632dccb992ca11e9445142fb33a29c33a51/Python/compile.c#L859.