summaryrefslogtreecommitdiff
path: root/Python/compile.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-11-02 04:20:10 +0000
committerRaymond Hettinger <python@rcn.com>2004-11-02 04:20:10 +0000
commitec4890fa183ca08b61e95491efb5ba40d941698c (patch)
treee0dd85e5aa860a2addeedfa6084b63d34fe5ffa9 /Python/compile.c
parentc1a81c56ae19f030800721d92f2480b0721c99d1 (diff)
downloadcpython-ec4890fa183ca08b61e95491efb5ba40d941698c.tar.gz
Maintain peepholer's cumlc invariant by updating the running total
everytime a LOAD_CONSTANT is encountered, created, or overwritten. Added two tests to cover cases affected by the patch.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c
index d47f8d53fe..be81ba0b1a 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -586,6 +586,7 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
if (PyList_GET_ITEM(consts, j) == Py_None) {
codestr[i] = LOAD_CONST;
SETARG(codestr, i, j);
+ cumlc = lastlc + 1;
break;
}
}
@@ -601,6 +602,7 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
!PyObject_IsTrue(PyList_GET_ITEM(consts, j)))
continue;
memset(codestr+i, NOP, 7);
+ cumlc = 0;
break;
/* Try to fold tuples of constants.
@@ -615,6 +617,8 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
codestr[h] == LOAD_CONST &&
ISBASICBLOCK(blocks, h, 3*(j+1)) &&
tuple_of_constants(&codestr[h], j, consts)) {
+ assert(codestr[i] == LOAD_CONST);
+ cumlc = 1;
break;
}
/* Intentional fallthrough */