[pypy-svn] r23113 - in pypy/dist/pypy/rpython/memory: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Feb 7 17:10:57 CET 2006


Author: cfbolz
Date: Tue Feb  7 17:10:55 2006
New Revision: 23113

Modified:
   pypy/dist/pypy/rpython/memory/gctransform.py
   pypy/dist/pypy/rpython/memory/test/test_gctransform.py
Log:
(cfbolz, mwh, pedronis):

refactor to not have these obscure rtype arguments everywhere:
specialize_more_blocks is only called in transform_graph



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  7 17:10:55 2006
@@ -82,6 +82,8 @@
                     link.prevblock.operations.extend(newops)
                 else:
                     insert_empty_block(None, link, newops)
+        if self.translator.rtyper is not None:
+            self.translator.rtyper.specialize_more_blocks()
 
     def transform_block(self, block):
         newops = []
@@ -213,16 +215,9 @@
                                      varoftype(lltype.Void)))
         return result
 
-    def pop_alive(self, var, rtype=True):
-        if var_ispyobj(var):
-            return self.pop_alive_pyobj(var)
-        else:
-            return self.pop_alive_nopyobj(var, rtype)
-        
-
-    def pop_alive_nopyobj(self, var, rtype=True):
+    def pop_alive_nopyobj(self, var):
         PTRTYPE = var.concretetype
-        decref_graph = self.decref_graph_for_type(PTRTYPE.TO, rtype)
+        decref_graph = self.decref_graph_for_type(PTRTYPE.TO)
         FUNC = lltype.FuncType([PTRTYPE], lltype.Void)
         const_fptr = rmodel.inputconst(
              lltype.Ptr(FUNC), lltype.functionptr(FUNC, decref_graph.name, graph=decref_graph))
@@ -284,11 +279,15 @@
         elif isinstance(TYPE, lltype.Ptr):
             yield '    '*depth + 'pop_alive(%s)'%v
 
-    def static_deallocation_graph_for_type(self, TYPE, rtype=True):
+    def static_deallocation_graph_for_type(self, TYPE):
         if TYPE in self.static_deallocator_graphs:
             return self.static_deallocator_graphs[TYPE]
+        PTRS = find_gc_ptrs_in_type(TYPE)
+        for PTR in PTRS:
+            # as a side effect the graphs are cached
+            self.static_deallocation_graph_for_type(PTR.TO)
         def compute_pop_alive_ll_ops(hop):
-            hop.llops.extend(self.pop_alive(hop.args_v[1], False))
+            hop.llops.extend(self.pop_alive(hop.args_v[1]))
             return hop.inputconst(hop.r_result.lowleveltype, hop.s_result.const)
         def pop_alive(var):
             pass
@@ -342,16 +341,10 @@
         print src
         print
         exec src in d
-        PTRS = find_gc_ptrs_in_type(TYPE)
-        for PTR in PTRS:
-            # as a side effect the graphs are cached
-            self.static_deallocation_graph_for_type(PTR.TO, rtype=False)
         this = d['deallocator']
         g = self.translator.rtyper.annotate_helper(this, [llmemory.Address])
         # the produced deallocator graph does not need to be transformed
         self.seen_graphs[g] = True
-        if rtype:
-            self.translator.rtyper.specialize_more_blocks()
         opcount = 0
         for block in g.iterblocks():
             opcount += len(block.operations)
@@ -362,7 +355,7 @@
             self.static_deallocator_graphs[TYPE] = g
             return g
 
-    def dynamic_deallocation_graph_for_type(self, TYPE, rtype=True):
+    def dynamic_deallocation_graph_for_type(self, TYPE):
         if TYPE in self.dynamic_deallocator_graphs:
             return self.dynamic_deallocator_graphs[TYPE]
 
@@ -384,13 +377,11 @@
             rtti = queryptr(v)
             call_destructor_for_rtti(addr, rtti)
         g = self.translator.rtyper.annotate_helper(dealloc, [llmemory.Address])
-        if rtype: 
-            self.translator.rtyper.specialize_more_blocks()
         self.dynamic_deallocator_graphs[TYPE] = g
         self.seen_graphs[g] = True
         return g
 
-    def decref_graph_for_type(self, TYPE, rtype=True):
+    def decref_graph_for_type(self, TYPE):
         if TYPE in self.decref_graphs:
             return self.decref_graphs[TYPE]
         need_dynamic_destructor = False
@@ -400,9 +391,9 @@
         else:
             need_dynamic_destructor = True
         if not need_dynamic_destructor:
-            graph = self.static_deallocation_graph_for_type(TYPE, False)
+            graph = self.static_deallocation_graph_for_type(TYPE)
         else:
-            graph = self.dynamic_deallocation_graph_for_type(TYPE, False)
+            graph = self.dynamic_deallocation_graph_for_type(TYPE)
         FUNC = lltype.FuncType([llmemory.Address], lltype.Void)
         const_funcptr = rmodel.inputconst(lltype.Ptr(FUNC),
                                  lltype.functionptr(FUNC, graph.name, graph=graph))
@@ -423,8 +414,6 @@
             if refcount == 0:
                 destructor(array)
         g = self.translator.rtyper.annotate_helper(decref, [lltype.Ptr(TYPE)])
-        if rtype:
-            self.translator.rtyper.specialize_more_blocks()
         # the produced deallocator graph does not need to be transformed
         self.seen_graphs[g] = True
         self.decref_graphs[TYPE] = g

Modified: pypy/dist/pypy/rpython/memory/test/test_gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_gctransform.py	(original)
+++ pypy/dist/pypy/rpython/memory/test/test_gctransform.py	Tue Feb  7 17:10:55 2006
@@ -316,6 +316,7 @@
     t.buildrtyper().specialize(t)
     transformer = gctransform.RefcountingGCTransformer(t)
     graph = getattr(transformer, attr)(TYPE)
+    t.rtyper.specialize_more_blocks()
     if conftest.option.view:
         t.view()
     return graph, t
@@ -413,4 +414,4 @@
     fgraph = graphof(t, f)
     TYPE = fgraph.startblock.operations[0].result.concretetype.TO
     graph = transformer.dynamic_deallocation_graph_for_type(TYPE)
-    
+    t.rtyper.specialize_more_blocks() 



More information about the Pypy-commit mailing list