[pypy-svn] r18482 - in pypy/dist/pypy: rpython translator translator/c/src translator/c/test

afa at codespeak.net afa at codespeak.net
Wed Oct 12 16:38:21 CEST 2005


Author: afa
Date: Wed Oct 12 16:38:14 2005
New Revision: 18482

Modified:
   pypy/dist/pypy/rpython/rtyper.py
   pypy/dist/pypy/translator/c/src/ll_stackless.h
   pypy/dist/pypy/translator/c/src/support.h
   pypy/dist/pypy/translator/c/test/test_annotated.py
   pypy/dist/pypy/translator/c/test/test_typed.py
   pypy/dist/pypy/translator/transform.py
Log:
(valentino, afa): corrections for stack checks
+ minor compilation warnings fixes


Modified: pypy/dist/pypy/rpython/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py	(original)
+++ pypy/dist/pypy/rpython/rtyper.py	Wed Oct 12 16:38:14 2005
@@ -24,6 +24,7 @@
 from pypy.rpython.lltype import attachRuntimeTypeInfo, Primitive
 from pypy.tool.sourcetools import func_with_new_name, valid_identifier
 from pypy.translator.unsimplify import insert_empty_block
+from pypy.translator.transform import insert_stackcheck
 from pypy.rpython.rmodel import Repr, inputconst
 from pypy.rpython.rmodel import TyperError, BrokenReprTyperError
 from pypy.rpython.rmodel import getfunctionptr, warning
@@ -109,7 +110,9 @@
         self.crash_on_first_typeerror = crash_on_first_typeerror
         # specialize depends on annotator simplifications
         if not dont_simplify_again:
+            insert_stackcheck(self.annotator)
             self.annotator.simplify()
+            
         # first make sure that all functions called in a group have exactly
         # the same signature, by hacking their flow graphs if needed
         perform_normalizations(self)

Modified: pypy/dist/pypy/translator/c/src/ll_stackless.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/ll_stackless.h	(original)
+++ pypy/dist/pypy/translator/c/src/ll_stackless.h	Wed Oct 12 16:38:14 2005
@@ -156,5 +156,5 @@
 
 #endif /* PYPY_NOT_MAIN_FILE */
 
-#endif USE_STACKLESS
+#endif /* USE_STACKLESS */
 

Modified: pypy/dist/pypy/translator/c/src/support.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/support.h	(original)
+++ pypy/dist/pypy/translator/c/src/support.h	Wed Oct 12 16:38:14 2005
@@ -34,8 +34,13 @@
 PyObject* PyList_Pack(int n, ...);
 PyObject* PyDict_Pack(int n, ...);
 PyObject* PyTuple_Pack(int n, ...);
+#if PY_VERSION_HEX >= 0x02030000   /* 2.3 */
+# define PyObject_GetItem1  PyObject_GetItem
+# define PyObject_SetItem1  PyObject_SetItem
+#else
 PyObject* PyObject_GetItem1(PyObject* obj, PyObject* index);
 PyObject* PyObject_SetItem1(PyObject* obj, PyObject* index, PyObject* v);
+#endif
 PyObject* CallWithShape(PyObject* callable, PyObject* shape, ...);
 PyObject* decode_arg(PyObject* fname, int position, PyObject* name,
 			    PyObject* vargs, PyObject* vkwds, PyObject* def);
@@ -168,10 +173,7 @@
 }
 #endif
 
-#if PY_VERSION_HEX >= 0x02030000   /* 2.3 */
-# define PyObject_GetItem1  PyObject_GetItem
-# define PyObject_SetItem1  PyObject_SetItem
-#else
+#if PY_VERSION_HEX < 0x02030000   /* 2.3 */
 /* for Python 2.2 only */
 PyObject* PyObject_GetItem1(PyObject* obj, PyObject* index)
 {

Modified: pypy/dist/pypy/translator/c/test/test_annotated.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_annotated.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_annotated.py	Wed Oct 12 16:38:14 2005
@@ -166,14 +166,3 @@
         fn = self.getcompiled(f)
         assert fn(-4.5) == 92.125
         assert fn(4.5) == 90.125
-
-    def test_recursion_detection(self):
-        def f(n=int, accum=int):
-            if n == 0:
-                return accum
-            else:
-                return f(n-1, accum*n)
-        fn = self.getcompiled(f)
-        assert fn(7, 1) == 5040
-        py.test.skip("recursion detection: in-progress")
-        py.test.raises(RuntimeError, fn, -1, 0)

Modified: pypy/dist/pypy/translator/c/test/test_typed.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_typed.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_typed.py	Wed Oct 12 16:38:14 2005
@@ -1,5 +1,6 @@
 import autopath
 import sys
+import py
 from py.test import raises
 from pypy.translator.translator import Translator
 from pypy.translator.test import snippet 
@@ -398,3 +399,13 @@
         f = self.getcompiled(fn)
         for args in [2, 7, 0], [7, 2, 0], [10, 50, 7], [50, -10, -3]:
             assert f(*args) == intmask(fn(*args))
+
+    def test_recursion_detection(self):
+        def f(n=int, accum=int):
+            if n == 0:
+                return accum
+            else:
+                return f(n-1, accum*n)
+        fn = self.getcompiled(f)
+        assert fn(7, 1) == 5040
+        py.test.raises(RuntimeError, fn, -1, 0)

Modified: pypy/dist/pypy/translator/transform.py
==============================================================================
--- pypy/dist/pypy/translator/transform.py	(original)
+++ pypy/dist/pypy/translator/transform.py	Wed Oct 12 16:38:14 2005
@@ -222,7 +222,6 @@
     #          modified by t.simplify() after it had been annotated.
     if block_subset is None:
         block_subset = fully_annotated_blocks(ann)
-        insert_stackcheck(ann)
     if not isinstance(block_subset, dict):
         block_subset = dict.fromkeys(block_subset)
     if ann.translator:



More information about the Pypy-commit mailing list