[pypy-svn] r49981 - pypy/dist/pypy/rpython/memory/gctransform

arigo at codespeak.net arigo at codespeak.net
Fri Dec 21 14:27:34 CET 2007


Author: arigo
Date: Fri Dec 21 14:27:34 2007
New Revision: 49981

Modified:
   pypy/dist/pypy/rpython/memory/gctransform/boehm.py
   pypy/dist/pypy/rpython/memory/gctransform/framework.py
   pypy/dist/pypy/rpython/memory/gctransform/refcounting.py
   pypy/dist/pypy/rpython/memory/gctransform/transform.py
Log:
Make sure the database sees all the finalizers early enough.
(fixes test_newgc.py: TestUsingStacklessFramework().test_framework_finalizer)


Modified: pypy/dist/pypy/rpython/memory/gctransform/boehm.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform/boehm.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform/boehm.py	Fri Dec 21 14:27:34 2007
@@ -108,7 +108,7 @@
                    "    v = cast_adr_to_ptr(addr, PTR_TYPE)\n"
                    "%s\n")%(static_body,)
             exec src in d
-            fptr = self.annotate_helper(d['ll_finalizer'], [llmemory.Address], lltype.Void)
+            fptr = self.annotate_finalizer(d['ll_finalizer'], [llmemory.Address], lltype.Void)
         elif destrptr:
             EXC_INSTANCE_TYPE = self.translator.rtyper.exceptiondata.lltype_of_exception_value
             def ll_finalizer(addr):
@@ -116,7 +116,7 @@
                 v = llmemory.cast_adr_to_ptr(addr, DESTR_ARG)
                 ll_call_destructor(destrptr, v)
                 llop.gc_restore_exception(lltype.Void, exc_instance)
-            fptr = self.annotate_helper(ll_finalizer, [llmemory.Address], lltype.Void)
+            fptr = self.annotate_finalizer(ll_finalizer, [llmemory.Address], lltype.Void)
         else:
             fptr = lltype.nullptr(self.FINALIZER_PTR.TO)
 

Modified: pypy/dist/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform/framework.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform/framework.py	Fri Dec 21 14:27:34 2007
@@ -801,9 +801,9 @@
             def ll_finalizer(addr):
                 v = llmemory.cast_adr_to_ptr(addr, DESTR_ARG)
                 ll_call_destructor(destrptr, v)
-            fptr = self.transformer.annotate_helper(ll_finalizer,
-                                                    [llmemory.Address],
-                                                    lltype.Void)
+            fptr = self.transformer.annotate_finalizer(ll_finalizer,
+                                                       [llmemory.Address],
+                                                       lltype.Void)
         else:
             fptr = lltype.nullptr(gctypelayout.GCData.FINALIZERTYPE.TO)
         return fptr

Modified: pypy/dist/pypy/rpython/memory/gctransform/refcounting.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform/refcounting.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform/refcounting.py	Fri Dec 21 14:27:34 2007
@@ -247,7 +247,7 @@
              'HDRPTR':lltype.Ptr(self.HDR)}
         exec src in d
         this = d['ll_deallocator']
-        fptr = self.annotate_helper(this, [llmemory.Address], lltype.Void)
+        fptr = self.annotate_finalizer(this, [llmemory.Address], lltype.Void)
         self.static_deallocator_funcptrs[TYPE] = fptr
         for p in find_gc_ptrs_in_type(TYPE):
             self.static_deallocation_funcptr_for_type(p.TO)

Modified: pypy/dist/pypy/rpython/memory/gctransform/transform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform/transform.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform/transform.py	Fri Dec 21 14:27:34 2007
@@ -111,6 +111,7 @@
             self.lltype_to_classdef = translator.rtyper.lltype_to_classdef_mapping()
         self.graphs_to_inline = {}
         self.graph_dependencies = {}
+        self.ll_finalizers_ptrs = []
         if self.MinimalGCTransformer:
             self.minimalgctransformer = self.MinimalGCTransformer(self)
         else:
@@ -286,6 +287,11 @@
         ptr = self.annotate_helper(ll_helper, ll_args, ll_result, inline=inline)
         return Constant(ptr, lltype.typeOf(ptr))
 
+    def annotate_finalizer(self, ll_finalizer, ll_args, ll_result):
+        fptr = self.annotate_helper(ll_finalizer, ll_args, ll_result)
+        self.ll_finalizers_ptrs.append(fptr)
+        return fptr
+
     def finish_helpers(self):
         if self.translator is not None:
             self.mixlevelannotator.finish_annotate()
@@ -293,6 +299,11 @@
         if self.translator is not None:
             self.mixlevelannotator.finish_rtype()
             self.mixlevelannotator.backend_optimize()
+        # Make sure that the database also sees all finalizers now.
+        # XXX we need to think more about the interaction with stackless...
+        # It is likely that the finalizers need special support there
+        newgcdependencies = self.ll_finalizers_ptrs
+        return newgcdependencies
 
     def finish_tables(self):
         pass



More information about the Pypy-commit mailing list