[pypy-svn] r48276 - in pypy/dist/pypy/translator/backendopt: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Nov 3 19:19:28 CET 2007


Author: cfbolz
Date: Sat Nov  3 19:19:28 2007
New Revision: 48276

Modified:
   pypy/dist/pypy/translator/backendopt/coalloc.py
   pypy/dist/pypy/translator/backendopt/test/test_coalloc.py
Log:
fix two wrong tests, and the code


Modified: pypy/dist/pypy/translator/backendopt/coalloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/coalloc.py	(original)
+++ pypy/dist/pypy/translator/backendopt/coalloc.py	Sat Nov  3 19:19:28 2007
@@ -324,16 +324,17 @@
                 continue
             for fromcrep in fromcreps:
                 if fromcrep.creation_method.startswith("malloc"):
-                    continue # also recently malloced
+                     break # also recently malloced
+            else:
+                #import pdb; pdb.set_trace()
+                num = do_coalloc(adi, graph, op.args[0], block,
+                                 fromcreps, tocrep)
 
-            #import pdb; pdb.set_trace()
-            num = do_coalloc(adi, graph, op.args[0], block,
-                             fromcreps, tocrep)
-
-            if num:
-                look_at.append(graph)
-                print "changed %s mallocs to coallocs in %s" % (num, graph.name)
-                total += num
+                if num:
+                    look_at.append(graph)
+                    print "changed %s mallocs to coallocs in %s" % (
+                        num, graph.name)
+                    total += num
     return total
 
 

Modified: pypy/dist/pypy/translator/backendopt/test/test_coalloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_coalloc.py	(original)
+++ pypy/dist/pypy/translator/backendopt/test/test_coalloc.py	Sat Nov  3 19:19:28 2007
@@ -213,16 +213,18 @@
             l.append(A())
             i += 1
         return len(l)
-    t = check_malloc_to_coalloc(f, [int], [8], 8, must_remove=2)
+    t = check_malloc_to_coalloc(f, [int], [8], 8, must_remove=1)
 
 
 def test_nocoalloc_bug():
     class A(object):
         pass
     a1 = A()
+    def g(a):
+        a.items = A()
     def f(count):
         a = A()
         a.length = count
-        a.items = A()
+        g(a)
         return a.length
     t = check_malloc_to_coalloc(f, [int], [8], 8, must_remove=1)



More information about the Pypy-commit mailing list