[Python-checkins] python/dist/src/Python compile.c,2.345,2.346

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Mon Feb 21 21:04:49 CET 2005


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12494

Modified Files:
	compile.c 
Log Message:
Document how the pattern recognizer keeps all of its references in bounds.
Add a test in case the underlying assumptions ever change (i.e. the 
compiler starts generating code blocks that are not punctuated by 
RETURN_VALUE).



Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.345
retrieving revision 2.346
diff -u -d -r2.345 -r2.346
--- compile.c	20 Feb 2005 12:41:32 -0000	2.345
+++ compile.c	21 Feb 2005 20:03:14 -0000	2.346
@@ -677,6 +677,14 @@
 		goto exitUnchanged;
 	codestr = memcpy(codestr, PyString_AS_STRING(code), codelen);
 
+	/* Verify that RETURN_VALUE terminates the codestring.  This allows
+	   the various transformation patterns to look ahead several
+	   instructions without additional checks to make sure they are not
+	   looking beyond the end of the code string.
+	*/
+	if (codestr[codelen-1] != RETURN_VALUE)
+		goto exitUnchanged;
+
 	/* Mapping to new jump targets after NOPs are removed */
 	addrmap = PyMem_Malloc(codelen * sizeof(int));
 	if (addrmap == NULL)



More information about the Python-checkins mailing list