[pypy-svn] pypy default: We dont want too many guards, but a residual call to min_max_loop

hakanardo commits-noreply at bitbucket.org
Fri Apr 15 13:09:23 CEST 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: 
Changeset: r43384:fc7a4da5aac7
Date: 2011-04-15 13:08 +0200
http://bitbucket.org/pypy/pypy/changeset/fc7a4da5aac7/

Log:	We dont want too many guards, but a residual call to min_max_loop

diff --git a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
--- a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
@@ -1452,26 +1452,41 @@
 
     def test_silly_max(self):
         def main():
-            i=2
-            sa=0
-            while i < 300: 
-                sa+=max(*range(i))
-                i+=1
+            i = 2
+            sa = 0
+            while i < 300:
+                lst = range(i)
+                sa += max(*lst) # ID: max
+                i += 1
             return sa
         log = self.run(main, [], threshold=200)
         assert log.result == main()
         loop, = log.loops_by_filename(self.filepath)
-        # XXX: what do we want to check here?
+        # We dont want too many guards, but a residual call to min_max_loop
+        assert len([n for n in log.opnames(loop.ops_by_id("max")) if n.startswith('guard')]) < 20
+        assert loop.match_by_id('max',"""
+            ...
+            p76 = call_may_force(ConstClass(min_max_loop__max), p73, ConstPtr(ptr75), descr=...)
+            ...
+        """)
+        
 
     def test_iter_max(self):
         def main():
-            i=2
-            sa=0
+            i = 2
+            sa = 0
             while i < 300:
-                sa+=max(range(i))
-                i+=1
+                lst = range(i)
+                sa += max(lst) # ID: max
+                i += 1
             return sa
         log = self.run(main, [], threshold=200)
         assert log.result == main()
         loop, = log.loops_by_filename(self.filepath)
-        # XXX: what do we want to check here?
+        # We dont want too many guards, but a residual call to min_max_loop
+        assert len([n for n in log.opnames(loop.ops_by_id("max")) if n.startswith('guard')]) < 20
+        assert loop.match_by_id('max',"""
+            ...
+            p76 = call_may_force(ConstClass(min_max_loop__max), p73, ConstPtr(ptr75), descr=...)            
+            ...
+        """)


More information about the Pypy-commit mailing list