Author: Nicolas Truessel <[email protected]>
Branch: quad-color-gc
Changeset: r86349:3c501a577097
Date: 2016-08-20 17:03 +0200
http://bitbucket.org/pypy/pypy/changeset/3c501a577097/

Log:    Try implementing allocation

diff --git a/rpython/memory/gc/qcgc.py b/rpython/memory/gc/qcgc.py
--- a/rpython/memory/gc/qcgc.py
+++ b/rpython/memory/gc/qcgc.py
@@ -23,11 +23,12 @@
             ('hash', lltype.Signed))
     #HDR = rffi.COpaque('object_t')
 
-    def malloc_fixedsize_clear(self, typeid16, size,
+    def malloc_fixedsize_clear(self, typeid, size,
                                needs_finalizer=False,
                                is_finalizer_light=False,
                                contains_weakptr=False):
-        raise NotImplementedError
+        # What is the llmemory.GCREF for?
+        return llop.qcgc_allocate(llmemory.GCREF, size, typeid)
         ## XXX finalizers are ignored for now
         ##ll_assert(not needs_finalizer, 'XXX needs_finalizer')
         ##ll_assert(not is_finalizer_light, 'XXX is_finalizer_light')
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
@@ -514,6 +514,9 @@
     # NOTE NOTE NOTE! don't forget *** canmallocgc=True *** for anything that
     # can malloc a GC object.
 
+    # __________ qcgc operations __________
+    'qcgc_allocate':    LLOp(canmallocgc=True),
+
     # __________ weakrefs __________
 
     'weakref_create':       LLOp(sideeffects=False, canmallocgc=True),
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
@@ -950,3 +950,11 @@
 
     def OP_QCGC_POP_ROOT(self, op):
         return 'qcgc_shadowstack_pop();'
+
+    def OP_QCGC_ALLOCATE(self, op):
+        # XXX: SET typeid
+        size = self.expr(op.args[0])
+        typeid = self.expr(op.args[1])
+        result = self.expr(op.result)
+        return ('%s = qcgc_allocate(%s);' % (result, size) +
+                '((PYPYHDR *)%s)->tid = %s;' % (result, typeid))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to