mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
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.
This commit is contained in:
parent
7d112df94f
commit
5dec096e6a
2 changed files with 9 additions and 3 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue