diff Python/compile.c @ 33880:8a09c82e4261 legacy-trunk

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.
author Raymond Hettinger <python@rcn.com>
date Tue, 02 Nov 2004 04:20:10 +0000
parents 24fc3eaa19e0
children e4404046e552
line wrap: on
line diff
--- a/Python/compile.c	Tue Nov 02 02:11:35 2004 +0000
+++ b/Python/compile.c	Tue Nov 02 04:20:10 2004 +0000
@@ -586,6 +586,7 @@
 				if (PyList_GET_ITEM(consts, j) == Py_None) {
 					codestr[i] = LOAD_CONST;
 					SETARG(codestr, i, j);
+					cumlc = lastlc + 1;
 					break;
 				}
 			}
@@ -601,6 +602,7 @@
 			    !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 @@
 			    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 */