diff options
Diffstat (limited to 'Python/peephole.c')
-rw-r--r-- | Python/peephole.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Python/peephole.c b/Python/peephole.c index 1ce3535626..6f3e2ed88b 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -250,12 +250,16 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, lnotab = (unsigned char*)PyBytes_AS_STRING(lnotab_obj); tabsiz = PyBytes_GET_SIZE(lnotab_obj); assert(tabsiz == 0 || Py_REFCNT(lnotab_obj) == 1); - if (memchr(lnotab, 255, tabsiz) != NULL) { - /* 255 value are used for multibyte bytecode instructions */ - goto exitUnchanged; + + /* Don't optimize if lnotab contains instruction pointer delta larger + than +255 (encoded as multiple bytes), just to keep the peephole optimizer + simple. The optimizer leaves line number deltas unchanged. */ + + for (j = 0; j < tabsiz; j += 2) { + if (lnotab[j] == 255) { + goto exitUnchanged; + } } - /* Note: -128 and 127 special values for line number delta are ok, - the peephole optimizer doesn't modify line numbers. */ assert(PyBytes_Check(code)); Py_ssize_t codesize = PyBytes_GET_SIZE(code); |