[pypy-svn] r23318 - pypy/dist/pypy/rpython/memory

mwh at codespeak.net mwh at codespeak.net
Tue Feb 14 13:13:46 CET 2006


Author: mwh
Date: Tue Feb 14 13:13:45 2006
New Revision: 23318

Modified:
   pypy/dist/pypy/rpython/memory/gctransform.py
Log:
this fixes test_del_raises from test_newgc


Modified: pypy/dist/pypy/rpython/memory/gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform.py	Tue Feb 14 13:13:45 2006
@@ -94,8 +94,7 @@
         v.concretetype = self.get_lltype_of_exception_value()
         graph.exc_cleanup = (v, self.pop_alive(v))
                     
-        if self.translator is not None and self.translator.rtyper is not None:
-            self.translator.rtyper.specialize_more_blocks()
+        self.specialize_more_blocks()
 
     def transform_block(self, block):
         newops = []
@@ -190,6 +189,10 @@
         result.concretetype = lltype.Void
         return [SpaceOperation("gc_pop_alive_pyobj", [var], result)]
 
+    def specialize_more_blocks(self):
+        if self.translator is not None and self.translator.rtyper is not None:
+            self.translator.rtyper.specialize_more_blocks()
+
     annotate_helper_count = 0
     def annotate_helper(self, ll_helper, args):
 ##         import sys, time
@@ -205,6 +208,14 @@
         return r
     
 
+class MinimalGCTransformer(GCTransformer):
+    def push_alive_nopyobj(self, var):
+        return []
+
+    def pop_alive_nopyobj(self, var):
+        return []
+
+
     # ----------------------------------------------------------------
 
 def _static_deallocator_body_for_type(v, TYPE, depth=1):
@@ -286,11 +297,13 @@
             self.translator.rtyper.specialize_more_blocks()
             self.no_pointer_dealloc_ptr = const_funcptr_fromgraph(self.no_pointer_dealloc_graph)
             self.seen_graphs[self.no_pointer_dealloc_graph] = True
+        self.deallocators_needing_transforming = []
         # cache graphs:
         self.decref_graphs = {}
         self.static_deallocator_graphs = {}
         self.dynamic_deallocator_graphs = {}
         self.queryptr2dynamic_deallocator_graph = {}
+        
 
     def push_alive_nopyobj(self, var):
         adr1 = varoftype(llmemory.Address)
@@ -350,6 +363,16 @@
     def static_deallocation_graph_for_type(self, TYPE):
         if TYPE in self.static_deallocator_graphs:
             return self.static_deallocator_graphs[TYPE]
+        g = self._static_deallocation_graph_for_type(TYPE)
+        self.specialize_more_blocks()
+        for g in self.deallocators_needing_transforming:
+            MinimalGCTransformer(self.translator).transform_graph(g)
+        self.deallocators_needing_transforming = []
+        return g
+
+    def _static_deallocation_graph_for_type(self, TYPE):
+        if TYPE in self.static_deallocator_graphs:
+            return self.static_deallocator_graphs[TYPE]
         #print_call_chain(self)
         def compute_pop_alive_ll_ops(hop):
             hop.llops.extend(self.pop_alive(hop.args_v[1]))
@@ -412,6 +435,11 @@
         g = self.annotate_helper(this, [llmemory.Address])
         # the produced deallocator graph does not need to be transformed
         self.seen_graphs[g] = True
+        if destrptr:
+            # however, the direct_call to the destructor needs to get
+            # .cleanup attached
+            self.deallocators_needing_transforming.append(g)
+        
         opcount = 0
         for block in g.iterblocks():
             opcount += len(block.operations)
@@ -429,7 +457,7 @@
 
         rtti = self.get_rtti(TYPE)
         if rtti is None:
-            g = self.static_deallocation_graph_for_type(TYPE)
+            g = self._static_deallocation_graph_for_type(TYPE)
             self.dynamic_deallocator_graphs[TYPE] = g
             return g
             



More information about the Pypy-commit mailing list