mirror of
https://github.com/python/cpython.git
synced 2025-09-03 23:41:18 +00:00
Use low bit of LOAD_GLOBAL's oparg to indicate whether it should push an additional NULL. (GH-31933)
This commit is contained in:
parent
ef1327e3b6
commit
3011a097bd
7 changed files with 212 additions and 196 deletions
|
@ -1000,7 +1000,7 @@ stack_effect(int opcode, int oparg, int jump)
|
|||
return -1;
|
||||
|
||||
case LOAD_GLOBAL:
|
||||
return 1;
|
||||
return (oparg & 1) + 1;
|
||||
|
||||
/* Exception handling pseudo-instructions */
|
||||
case SETUP_FINALLY:
|
||||
|
@ -4185,8 +4185,12 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
|
|||
assert(op);
|
||||
arg = compiler_add_o(dict, mangled);
|
||||
Py_DECREF(mangled);
|
||||
if (arg < 0)
|
||||
if (arg < 0) {
|
||||
return 0;
|
||||
}
|
||||
if (op == LOAD_GLOBAL) {
|
||||
arg <<= 1;
|
||||
}
|
||||
return compiler_addop_i(c, op, arg);
|
||||
}
|
||||
|
||||
|
@ -8812,6 +8816,13 @@ optimize_basic_block(struct compiler *c, basicblock *bb, PyObject *consts)
|
|||
break;
|
||||
case KW_NAMES:
|
||||
break;
|
||||
case PUSH_NULL:
|
||||
if (nextop == LOAD_GLOBAL && (inst[1].i_opcode & 1) == 0) {
|
||||
inst->i_opcode = NOP;
|
||||
inst->i_oparg = 0;
|
||||
inst[1].i_oparg |= 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* All HAS_CONST opcodes should be handled with LOAD_CONST */
|
||||
assert (!HAS_CONST(inst->i_opcode));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue