[pypy-commit] pypy quad-color-gc: Hack around dereferencing (do it with custom llop)

ntruessel pypy.commits at gmail.com
Tue Aug 23 06:14:31 EDT 2016


Author: Nicolas Truessel <ntruessel at njsm.de>
Branch: quad-color-gc
Changeset: r86441:fd79eaeb9674
Date: 2016-08-23 12:01 +0200
http://bitbucket.org/pypy/pypy/changeset/fd79eaeb9674/

Log:	Hack around dereferencing (do it with custom llop)

diff --git a/rpython/memory/gctransform/qcgcframework.py b/rpython/memory/gctransform/qcgcframework.py
--- a/rpython/memory/gctransform/qcgcframework.py
+++ b/rpython/memory/gctransform/qcgcframework.py
@@ -1,5 +1,6 @@
 from rpython.rtyper.llannotation import SomePtr, SomeAddress, s_None
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
+from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.memory.gctransform.framework import (BaseFrameworkGCTransformer, BaseRootWalker)
 
 VISIT_FPTR = lltype.Ptr(lltype.FuncType([llmemory.Address], lltype.Void))
@@ -22,7 +23,8 @@
         #     s_gcref], s_gcref)
         #
         def invokecallback(root, visit_fn):
-            visit_fn(root) # FIXME: Dereference root before invoking visit_fn
+            obj = llop.qcgc_dereference(llmemory.Address, root)
+            visit_fn(obj)
         def pypy_trace_cb(obj, visit_fn):
             gc.trace(obj, invokecallback, visit_fn)
         pypy_trace_cb.c_name = "pypy_trace_cb"
diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -517,6 +517,7 @@
     # __________ qcgc operations __________
     'qcgc_allocate':    LLOp(canmallocgc=True),
     'qcgc_collect':     LLOp(), # XXX: No allocations, so no canmallocgc ?
+    'qcgc_dereference': LLOp(),
 
     # __________ weakrefs __________
 
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -959,3 +959,8 @@
 
     def OP_QCGC_COLLECT(self, op):
         return 'qcgc_collect();'
+
+    def OP_QCGC_DEREFERENCE(self, op):
+        arg = self.expr(op.args[0])
+        result = self.expr(op.result)
+        return '%s = *((object_t **) %s);' % (result, arg)


More information about the pypy-commit mailing list