mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Bypass peepholing of code with lineno tables having intervals >= 255.
Allows the lineno fixup code to remain simple and not have to deal with multibyte codings. * Add an assertion to that effect. * Remove the XXX comment on the subject.
This commit is contained in:
parent
65d3c0537a
commit
1792bfbf90
1 changed files with 8 additions and 4 deletions
|
@ -435,6 +435,13 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
|
||||||
unsigned int *blocks;
|
unsigned int *blocks;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
/* Bypass optimization when the lineno table is too complex */
|
||||||
|
assert(PyString_Check(lineno_obj));
|
||||||
|
lineno = PyString_AS_STRING(lineno_obj);
|
||||||
|
tabsiz = PyString_GET_SIZE(lineno_obj);
|
||||||
|
if (memchr(lineno, 255, tabsiz) != NULL)
|
||||||
|
goto exitUnchanged;
|
||||||
|
|
||||||
if (!PyString_Check(code))
|
if (!PyString_Check(code))
|
||||||
goto exitUnchanged;
|
goto exitUnchanged;
|
||||||
|
|
||||||
|
@ -614,15 +621,12 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fixup linenotab */
|
/* Fixup linenotab */
|
||||||
/* XXX make sure this handles intervals > 256 */
|
|
||||||
assert(PyString_Check(lineno_obj));
|
|
||||||
lineno = PyString_AS_STRING(lineno_obj);
|
|
||||||
tabsiz = PyString_GET_SIZE(lineno_obj);
|
|
||||||
cum_orig_line = 0;
|
cum_orig_line = 0;
|
||||||
last_line = 0;
|
last_line = 0;
|
||||||
for (i=0 ; i < tabsiz ; i+=2) {
|
for (i=0 ; i < tabsiz ; i+=2) {
|
||||||
cum_orig_line += lineno[i];
|
cum_orig_line += lineno[i];
|
||||||
new_line = addrmap[cum_orig_line];
|
new_line = addrmap[cum_orig_line];
|
||||||
|
assert (new_line - last_line < 255);
|
||||||
lineno[i] =((unsigned char)(new_line - last_line));
|
lineno[i] =((unsigned char)(new_line - last_line));
|
||||||
last_line = new_line;
|
last_line = new_line;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue