Uh oh!
There was an error while loading. Please reload this page.
GH-98831: Update generate_cases.py: register inst, opcode_metadata.h - #100735
Conversation
(These aren't used yet, but may be coming soon, and it's easier to keep this tool the same between branches.)
| [BINARY_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, | ||
| [SWAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, | ||
| [EXTENDED_ARG] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, | ||
| [CACHE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, |
There was a problem hiding this comment.
END_FOR is missing, I think we need something to handle macros.
Also, note that missing entries default to 0. Would be safer if they defaulted to -1.
There was a problem hiding this comment.
Also, note that missing entries default to 0. Would be safer if they defaulted to -1.
The code generator doesn't know the numeric values of the opcodes (yet) so it doesn't have enough info to generate explicit entries filled with -1 for missing values. The best we can do is add an additional flag valid_entry.
| [GET_AWAITABLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, | ||
| [SEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, | ||
| [ASYNC_GEN_WRAP] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, | ||
| [YIELD_VALUE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, |
There was a problem hiding this comment.
stack_effect of YIELD_VALUE is 0. Why is it here 1 popped, 0 pushed?
There was a problem hiding this comment.
That seems to be a bug in bytecodes.c. The code ends with goto resume_frame so the push sequence at the end is never executed. I can fix it by making the IO effect (retval -- retval) (indicating that it doesn't change) or perhaps (retval -- unused), indicating that we don't write it here. I presume it's written in some weird way when the frame is resumed.
This is the sanity check I used to find those two issues: --- a/Python/compile.c+++ b/Python/compile.c@@ -8854,6 +8854,26 @@ assemble(struct compiler *c, int addNone)
assert(no_redundant_jumps(g));
+ for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {+ for (int j = 0; j < b->b_iused; j++) {+ struct instr *instr = &b->b_instr[j];+ int opcode = instr->i_opcode;+ assert(opcode < 256);+ int pushed = _PyOpcode_opcode_metadata[opcode].n_pushed;+ int popped = _PyOpcode_opcode_metadata[opcode].n_popped;+ if (pushed >= 0 && popped >= 0) {+ int oparg = instr->i_oparg;+ int effect = stack_effect(opcode, oparg, -1);+ if (effect != pushed-popped) {+ fprintf(stderr, "opcode = %d oparg = %d effect = %d pushed = %d popped = %d\n",+ opcode, oparg, effect, pushed, popped);+ }+ assert(effect == pushed-popped);+ }+ }+ }++ |
gvanrossum
commented
Jan 4, 2023
Maybe we should include that in the code as a helper function and call it in an |
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
gvanrossum
commented
Jan 5, 2023
Have to revert, see #100777 |
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
bedevere-bot
commented
Jan 5, 2023
|
gvanrossum
commented
Jan 5, 2023
Bot failures fixed by #100778 |
(These aren't used yet, but may be coming soon,
and it's easier to keep this tool the same between branches.)