Author: Nicolas Truessel <[email protected]>
Branch: quad-color-gc
Changeset: r86306:07613d93dc9d
Date: 2016-08-19 10:16 +0200
http://bitbucket.org/pypy/pypy/changeset/07613d93dc9d/

Log:    Compile qcgc (WIP)

diff --git a/rpython/rtyper/tool/rffi_platform.py 
b/rpython/rtyper/tool/rffi_platform.py
--- a/rpython/rtyper/tool/rffi_platform.py
+++ b/rpython/rtyper/tool/rffi_platform.py
@@ -879,6 +879,33 @@
         [dict(prefix='gc-', include_dir='include', library_dir=library_dir)],
         symbol='GC_init')
 
+def configure_qcgc():
+    library_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), 
'..',
+        '..', 'translator', 'c', 'src', 'qcgc'))
+
+    separate_source = """
+    #include "qcgc.h"
+
+    extern void pypy_trace_cb(void *, void (*)(void *));
+
+    void qcgc_trace_cb(object_t *object, void (*visit)(object_t *object)) {
+        pypy_trace_cb((void *) object, (void (*)(void *)) visit);
+    }
+    """
+
+    eci = ExternalCompilationInfo(
+            include_dirs = [library_dir],
+            #includes = []
+            separate_module_sources = [separate_source],
+            separate_module_files = [os.path.join(library_dir, f) for f in
+                ["qcgc.c", "arena.c", "allocator.c", "bag.c", "event_logger.c",
+                    "gray_stack.c", "shadow_stack.c"]],
+            )
+    return configure_external_library(
+            'qcgc', eci, [dict(prefix='qcgc-', include_dir='include',
+                library_dir=library_dir)],
+            symbol='qcgc_initialize')
+
 if __name__ == '__main__':
     doc = """Example:
 
diff --git a/rpython/translator/c/test/test_qcgc.py 
b/rpython/translator/c/test/test_qcgc.py
new file mode 100644
--- /dev/null
+++ b/rpython/translator/c/test/test_qcgc.py
@@ -0,0 +1,54 @@
+import weakref
+
+import py
+
+from rpython.rlib import rgc, debug
+from rpython.rlib.objectmodel import (keepalive_until_here, compute_unique_id,
+    compute_hash, current_object_addr_as_int)
+from rpython.rtyper.lltypesystem import lltype, llmemory
+from rpython.rtyper.lltypesystem.lloperation import llop
+from rpython.rtyper.lltypesystem.rstr import STR
+from rpython.translator.c.test.test_genc import compile
+
+
+def setup_module(mod):
+    from rpython.rtyper.tool.rffi_platform import configure_qcgc
+    from rpython.translator.platform import CompilationError
+    configure_qcgc()
+
+
+class AbstractGCTestClass(object):
+    gcpolicy = "qcgc"
+    use_threads = False
+    extra_options = {}
+
+    # deal with cleanups
+    def setup_method(self, meth):
+        self._cleanups = []
+
+    def teardown_method(self, meth):
+        while self._cleanups:
+            #print "CLEANUP"
+            self._cleanups.pop()()
+
+    def getcompiled(self, func, argstypelist=[], annotatorpolicy=None,
+                    extra_options={}):
+        return compile(func, argstypelist, gcpolicy=self.gcpolicy,
+                       thread=self.use_threads, **extra_options)
+
+
+class TestUsingBoehm(AbstractGCTestClass):
+    gcpolicy = "boehm"
+
+    def test_malloc_a_lot(self):
+        def malloc_a_lot():
+            i = 0
+            while i < 10:
+                i += 1
+                a = [1] * 10
+                j = 0
+                while j < 20:
+                    j += 1
+                    a.append(j)
+        fn = self.getcompiled(malloc_a_lot)
+        fn()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to