[pypy-svn] r25313 - pypy/branch/explicit-exceptions/rpython/memory

mwh at codespeak.net mwh at codespeak.net
Tue Apr 4 19:11:57 CEST 2006


Author: mwh
Date: Tue Apr  4 19:11:56 2006
New Revision: 25313

Modified:
   pypy/branch/explicit-exceptions/rpython/memory/gctransform.py
Log:
make the FrameworkGCTransformer work on the branch.
much easier than i expected!


Modified: pypy/branch/explicit-exceptions/rpython/memory/gctransform.py
==============================================================================
--- pypy/branch/explicit-exceptions/rpython/memory/gctransform.py	(original)
+++ pypy/branch/explicit-exceptions/rpython/memory/gctransform.py	Tue Apr  4 19:11:56 2006
@@ -103,12 +103,12 @@
         # had to solve there.
         for i, op in enumerate(block.operations):
             num_ops_after_exc_raising = 0
-            ops = self.replacement_operations(op, livevars, block)
+            ops, index = self.replacement_operations(op, livevars, block)
             if not ops:
                 continue # may happen when we eat gc_protect/gc_unprotect.
             newops.extend(ops)
             origname = op.opname
-            op = ops[-1]
+            op = ops[index]
             if var_needsgc(op.result):
                 if op.opname not in ('direct_call', 'indirect_call') and not var_ispyobj(op.result):
                     lst = list(self.push_alive(op.result))
@@ -139,10 +139,13 @@
     def replacement_operations(self, op, livevars, block):
         m = getattr(self, 'replace_' + op.opname, None)
         if m:
-            return m(op, livevars, block)
+            r = m(op, livevars, block)
+            if not isinstance(r, tuple):
+                return r, -1
+            else:
+                return r
         else:
-            return [op]
-
+            return [op], 0
 
     def push_alive(self, var):
         if var_ispyobj(var):
@@ -935,8 +938,10 @@
         else:
             print "block which needs conservative livevar calculation found"
         newops = list(self.push_roots(livevars))
+        index = len(newops)
         newops.append(op)
-        return newops, tuple(self.pop_roots(livevars))
+        newops.extend(self.pop_roots(livevars))
+        return newops, index
 
     replace_direct_call    = protect_roots
     replace_indirect_call  = protect_roots
@@ -972,11 +977,11 @@
             args = [self.malloc_varsize_ptr, newop0.result, c_type_id,
                     v_length, c_size, c_varitemsize, c_ofstolength] 
         newop = SpaceOperation("direct_call", args, v)
-        ops, finally_ops = self.protect_roots(newop, livevars, block,
-                                              block.operations.index(op))
+        ops, index = self.protect_roots(newop, livevars, block,
+                                        block.operations.index(op))
         ops.insert(0, newop0)
         ops.append(SpaceOperation("cast_adr_to_ptr", [v], op.result))
-        return ops, finally_ops, 1
+        return ops
 
     replace_malloc_varsize = replace_malloc
 



More information about the Pypy-commit mailing list