mirror of
https://github.com/python/cpython.git
synced 2025-10-15 11:22:18 +00:00
Move NOP to end of code transformation.
This commit is contained in:
parent
b86aa99eb9
commit
43ea47ff06
1 changed files with 7 additions and 3 deletions
|
@ -392,7 +392,8 @@ optimize_code(PyObject *code, PyObject* consts)
|
||||||
opcode = codestr[i];
|
opcode = codestr[i];
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
|
|
||||||
/* Replace UNARY_NOT JUMP_IF_FALSE with NOP JUMP_IF_TRUE */
|
/* Replace UNARY_NOT JUMP_IF_FALSE POP_TOP with
|
||||||
|
with JUMP_IF_TRUE POP_TOP NOP */
|
||||||
case UNARY_NOT:
|
case UNARY_NOT:
|
||||||
if (codestr[i+1] != JUMP_IF_FALSE ||
|
if (codestr[i+1] != JUMP_IF_FALSE ||
|
||||||
codestr[i+4] != POP_TOP ||
|
codestr[i+4] != POP_TOP ||
|
||||||
|
@ -401,8 +402,11 @@ optimize_code(PyObject *code, PyObject* consts)
|
||||||
tgt = GETJUMPTGT(codestr, (i+1));
|
tgt = GETJUMPTGT(codestr, (i+1));
|
||||||
if (codestr[tgt] != POP_TOP)
|
if (codestr[tgt] != POP_TOP)
|
||||||
continue;
|
continue;
|
||||||
codestr[i] = NOP;
|
j = GETARG(codestr, i+1) + 1;
|
||||||
codestr[i+1] = JUMP_IF_TRUE;
|
codestr[i] = JUMP_IF_TRUE;
|
||||||
|
SETARG(codestr, i, j);
|
||||||
|
codestr[i+3] = POP_TOP;
|
||||||
|
codestr[i+4] = NOP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* not a is b --> a is not b
|
/* not a is b --> a is not b
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue