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

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


Author: cfbolz
Date: Sat Nov  3 19:11:55 2007
New Revision: 48274

Modified:
   pypy/dist/pypy/translator/backendopt/coalloc.py
   pypy/dist/pypy/translator/backendopt/test/test_coalloc.py
Log:
woops, check whether the malloc we are trying to replace is the correct one.


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:11:55 2007
@@ -326,6 +326,7 @@
                 if fromcrep.creation_method.startswith("malloc"):
                     continue # also recently malloced
 
+            #import pdb; pdb.set_trace()
             num = do_coalloc(adi, graph, op.args[0], block,
                              fromcreps, tocrep)
 
@@ -355,6 +356,8 @@
     for block, op in graph.iterblockops():
         if not op.opname.startswith("malloc"):
             continue
+        if adi.getstate(op.result).creation_points.keys()[0] is not tocrep:
+            continue
         coallocvar = find_coalloc_var()
         if coallocvar is None:
             continue

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:11:55 2007
@@ -201,3 +201,28 @@
         return 4
     t = check_malloc_to_coalloc(f, [bool], [True], 4, must_remove=1)
 
+
+def test_coalloc_list():
+    class A(object):
+        pass
+    a1 = A()
+    def f(count):
+        i = 0
+        l = []
+        while i < count:
+            l.append(A())
+            i += 1
+        return len(l)
+    t = check_malloc_to_coalloc(f, [int], [8], 8, must_remove=2)
+
+
+def test_nocoalloc_bug():
+    class A(object):
+        pass
+    a1 = A()
+    def f(count):
+        a = A()
+        a.length = count
+        a.items = A()
+        return a.length
+    t = check_malloc_to_coalloc(f, [int], [8], 8, must_remove=1)



More information about the Pypy-commit mailing list