[pypy-commit] pypy jitframe-on-heap: Move the hacks around until it seems to work

arigo noreply at buildbot.pypy.org
Sun Mar 3 18:05:07 CET 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: jitframe-on-heap
Changeset: r61954:dc7053edd681
Date: 2013-03-03 18:03 +0100
http://bitbucket.org/pypy/pypy/changeset/dc7053edd681/

Log:	Move the hacks around until it seems to work

diff --git a/rpython/memory/gctransform/asmgcroot.py b/rpython/memory/gctransform/asmgcroot.py
--- a/rpython/memory/gctransform/asmgcroot.py
+++ b/rpython/memory/gctransform/asmgcroot.py
@@ -139,6 +139,7 @@
         if self._with_jit:
             jit2gc = gctransformer.translator._jit2gc
             self.frame_tid = jit2gc['frame_tid']
+        self.gctransformer = gctransformer
 
     def need_stacklet_support(self, gctransformer, getfn):
         # stacklet support: BIG HACK for rlib.rstacklet
diff --git a/rpython/memory/gctransform/framework.py b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -1228,14 +1228,9 @@
                 [llmemory.Address], lltype.Void)
         try:
             g = destrptr._obj.graph
-        except AttributeError:
-            # hack hack hack
-            self.transformer.annotate_finalizer(
-                destrptr._obj._callable, [DESTR_ARG], lltype.Void)
-            g = self.transformer._last_annotated_graph
-            destrptr._obj.__dict__['graph'] = g
-            #
-        light = not FinalizerAnalyzer(self.translator).analyze_light_finalizer(g)
+            light = not FinalizerAnalyzer(self.translator).analyze_light_finalizer(g)
+        except lltype.DelayedPointer:
+            light = False    # XXX bah, too bad
         return fptr, light
 
     def make_custom_trace_funcptr_for_type(self, TYPE):
diff --git a/rpython/memory/gctransform/shadowstack.py b/rpython/memory/gctransform/shadowstack.py
--- a/rpython/memory/gctransform/shadowstack.py
+++ b/rpython/memory/gctransform/shadowstack.py
@@ -1,6 +1,7 @@
 from rpython.annotator import model as annmodel
 from rpython.rlib.debug import ll_assert
 from rpython.rlib.nonconst import NonConstant
+from rpython.rlib import rgc
 from rpython.rtyper import rmodel
 from rpython.rtyper.annlowlevel import llhelper
 from rpython.rtyper.lltypesystem import lltype, llmemory
@@ -400,8 +401,8 @@
         if h:
             _c.destroy(h)
 
-    DESTRFUNC = lltype.FuncType([SHADOWSTACKREFPTR], lltype.Void)
-    destrptr = llhelper(lltype.Ptr(DESTRFUNC), shadowstack_destructor)
+    destrptr = gctransformer.annotate_helper(shadowstack_destructor,
+                                             [SHADOWSTACKREFPTR], lltype.Void)
 
     lltype.attachRuntimeTypeInfo(SHADOWSTACKREF, customtraceptr=customtraceptr,
                                  destrptr=destrptr)
diff --git a/rpython/memory/gctransform/transform.py b/rpython/memory/gctransform/transform.py
--- a/rpython/memory/gctransform/transform.py
+++ b/rpython/memory/gctransform/transform.py
@@ -267,7 +267,6 @@
         if inline:
             self.graphs_to_inline[graph] = True
         FUNCTYPE = lltype.FuncType(ll_args, ll_result)
-        self._last_annotated_graph = graph
         return self.mixlevelannotator.graph2delayed(graph, FUNCTYPE=FUNCTYPE)
 
     def inittime_helper(self, ll_helper, ll_args, ll_result, inline=True):
@@ -282,6 +281,10 @@
     def finish_helpers(self, backendopt=True):
         if self.translator is not None:
             self.mixlevelannotator.finish_annotate()
+            if hasattr(self, '_hack_call_later'):
+                f = self._hack_call_later
+                del self._hack_call_later
+                f(self)
         self.finished_helpers = True
         if self.translator is not None:
             self.mixlevelannotator.finish_rtype()
diff --git a/rpython/rlib/_stacklet_asmgcc.py b/rpython/rlib/_stacklet_asmgcc.py
--- a/rpython/rlib/_stacklet_asmgcc.py
+++ b/rpython/rlib/_stacklet_asmgcc.py
@@ -1,8 +1,8 @@
-from rpython.rlib import _rffi_stacklet as _c
 from rpython.rlib.debug import ll_assert
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.rtyper.lltypesystem.lloperation import llop
-from rpython.rtyper.annlowlevel import llhelper
+from rpython.rtyper.annlowlevel import llhelper, MixLevelHelperAnnotator
+from rpython.annotator import model as annmodel
 
 
 _asmstackrootwalker = None    # BIG HACK: monkey-patched by asmgcroot.py
@@ -126,9 +126,20 @@
             return _c._translate_pointer(self.context, addr)
 
     _stackletrootwalker = StackletRootWalker()
+    _asmstackrootwalker.gctransformer._hack_call_later = complete_destrptr
     return _stackletrootwalker
 get_stackletrootwalker._annspecialcase_ = 'specialize:memo'
 
+def complete_destrptr(gctransformer):
+    translator = gctransformer.translator
+    mixlevelannotator = MixLevelHelperAnnotator(translator.rtyper)
+    args_s = [annmodel.lltype_to_annotation(lltype.Ptr(SUSPSTACK))]
+    s_result = annmodel.s_None
+    destrptr = mixlevelannotator.delayedfunction(suspstack_destructor,
+                                                 args_s, s_result)
+    mixlevelannotator.finish()
+    lltype.attachRuntimeTypeInfo(SUSPSTACK, destrptr=destrptr)
+
 
 def customtrace(obj, prev):
     stackletrootwalker = get_stackletrootwalker()
@@ -148,12 +159,7 @@
 CUSTOMTRACEFUNC = lltype.FuncType([llmemory.Address, llmemory.Address],
                                   llmemory.Address)
 customtraceptr = llhelper(lltype.Ptr(CUSTOMTRACEFUNC), customtrace)
-
-DESTRFUNC = lltype.FuncType([lltype.Ptr(SUSPSTACK)], lltype.Void)
-destrptr = llhelper(lltype.Ptr(DESTRFUNC), suspstack_destructor)
-
-lltype.attachRuntimeTypeInfo(SUSPSTACK, customtraceptr=customtraceptr,
-                             destrptr=destrptr)
+lltype.attachRuntimeTypeInfo(SUSPSTACK, customtraceptr=customtraceptr)
 
 ASM_FRAMEDATA_HEAD_PTR = lltype.Ptr(lltype.ForwardReference())
 ASM_FRAMEDATA_HEAD_PTR.TO.become(lltype.Struct('ASM_FRAMEDATA_HEAD',
diff --git a/rpython/translator/c/gc.py b/rpython/translator/c/gc.py
--- a/rpython/translator/c/gc.py
+++ b/rpython/translator/c/gc.py
@@ -318,8 +318,8 @@
             fptrs = gctransf.special_funcptr_for_type(TYPE)
             # make sure this is seen by the database early, i.e. before
             # finish_helpers() on the gctransformer
-            #destrptr = rtti._obj.destructor_funcptr
-            #self.db.get(destrptr)
+            destrptr = rtti._obj.destructor_funcptr
+            self.db.get(destrptr)
             # the following, on the other hand, will only discover ll_finalizer
             # helpers.  The get() sees and records a delayed pointer.  It is
             # still important to see it so that it can be followed as soon as


More information about the pypy-commit mailing list