summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-06-24 09:25:39 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-06-24 09:25:39 (GMT)
commit43ea47ff06295924c4f7512417370f988d1ea7da (patch)
treeb7a9076c6b9e3b86ec215c723fca16a423f8c260 /Python
parentb86aa99eb99bb95629a57dee9bebe69317455e2d (diff)
downloadcpython-43ea47ff06295924c4f7512417370f988d1ea7da.zip
cpython-43ea47ff06295924c4f7512417370f988d1ea7da.tar.gz
cpython-43ea47ff06295924c4f7512417370f988d1ea7da.tar.bz2
Move NOP to end of code transformation.
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Python/compile.c b/Python/compile.c
index ab4b533..16328b5 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -392,7 +392,8 @@ optimize_code(PyObject *code, PyObject* consts)
opcode = codestr[i];
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:
if (codestr[i+1] != JUMP_IF_FALSE ||
codestr[i+4] != POP_TOP ||
@@ -401,8 +402,11 @@ optimize_code(PyObject *code, PyObject* consts)
tgt = GETJUMPTGT(codestr, (i+1));
if (codestr[tgt] != POP_TOP)
continue;
- codestr[i] = NOP;
- codestr[i+1] = JUMP_IF_TRUE;
+ j = GETARG(codestr, i+1) + 1;
+ codestr[i] = JUMP_IF_TRUE;
+ SETARG(codestr, i, j);
+ codestr[i+3] = POP_TOP;
+ codestr[i+4] = NOP;
break;
/* not a is b --> a is not b