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

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


Author: cfbolz
Date: Sat Nov  3 19:32:25 2007
New Revision: 48277

Modified:
   pypy/dist/pypy/translator/backendopt/coalloc.py
   pypy/dist/pypy/translator/backendopt/test/test_coalloc.py
Log:
some fixes necessary to make coallocation with dictionaries work.


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:32:25 2007
@@ -197,14 +197,14 @@
     def op_malloc(self, op, typestate, flagsstate):
         assert flagsstate is None
         flags = op.args[1].value
-        if flags != {'flavor': 'gc'}:
+        if flags['flavor'] != 'gc':
             return NotImplemented
         return VarState(self.get_creationpoint(op.result, "malloc"))
 
     def op_malloc_varsize(self, op, typestate, flagsstate, lengthstate):
         assert flagsstate is None
         flags = op.args[1].value
-        if flags != {'flavor': 'gc'}:
+        if flags['flavor'] != 'gc':
             return NotImplemented
         return VarState(self.get_creationpoint(op.result, "malloc_varsize"))
 
@@ -214,7 +214,7 @@
     def op_cast_pointer(self, op, state):
         return state
     
-    def op_getfield(self, op, objstate, fieldname):
+    def op_getfield(self, op, objstate, *rest):
         # connectivity-wise the field within is identical to the containing
         # structure
         return objstate
@@ -223,7 +223,7 @@
     def op_getarraysize(self, op, arraystate):
         pass
 
-    def op_setfield(self, op, objstate, fieldname, valuestate):
+    def op_setfield(self, op, objstate, *args):
         pass
     op_setarrayitem = op_setinteriorfield = op_setfield
 

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:32:25 2007
@@ -215,6 +215,18 @@
         return len(l)
     t = check_malloc_to_coalloc(f, [int], [8], 8, must_remove=1)
 
+def test_coalloc_dict():
+    class A(object):
+        pass
+    a1 = A()
+    def f(count):
+        i = 0
+        d = {}
+        while i < count:
+            d[i] = A()
+            i += 1
+        return len(d)
+    t = check_malloc_to_coalloc(f, [int], [8], 8, must_remove=1)
 
 def test_nocoalloc_bug():
     class A(object):



More information about the Pypy-commit mailing list