[pypy-commit] pypy gc-minimark-pinning: Start a branch to experiment with pinning on the GC. Boilerplate so far

fijal noreply at buildbot.pypy.org
Thu Apr 12 14:15:51 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: gc-minimark-pinning
Changeset: r54304:43d51ad02ec5
Date: 2012-04-12 14:14 +0200
http://bitbucket.org/pypy/pypy/changeset/43d51ad02ec5/

Log:	Start a branch to experiment with pinning on the GC. Boilerplate so
	far

diff --git a/pypy/rlib/rgc.py b/pypy/rlib/rgc.py
--- a/pypy/rlib/rgc.py
+++ b/pypy/rlib/rgc.py
@@ -493,3 +493,25 @@
     def specialize_call(self, hop):
         hop.exception_is_here()
         return hop.genop('gc_typeids_z', [], resulttype = hop.r_result)
+
+class PinEntry(ExtRegistryEntry):
+    _about_ = pin
+
+    def compute_result_annotation(self, s_arg):
+        pass
+
+    def specialize_call(self, hop):
+        hop.exception_cannot_occur()
+        v_obj, = hop.inputargs(hop.args_r[0])
+        hop.genop('gc_pin', [v_obj])
+
+class UnpinEntry(ExtRegistryEntry):
+    _about_ = unpin
+
+    def compute_result_annotation(self, s_arg):
+        pass
+
+    def specialize_call(self, hop):
+        hop.exception_cannot_occur()
+        v_obj, = hop.inputargs(hop.args_r[0])
+        hop.genop('gc_unpin', [v_obj])
diff --git a/pypy/rlib/test/test_rgc.py b/pypy/rlib/test/test_rgc.py
--- a/pypy/rlib/test/test_rgc.py
+++ b/pypy/rlib/test/test_rgc.py
@@ -177,3 +177,12 @@
     with rgc.pinned_object(l):
         l.append(3)
     assert l == [3]
+
+def test_interp_pin_obj():
+    def f(i):
+        l = []
+        with rgc.pinned_object(l):
+            l.append(i)
+        return l[0]
+    
+    assert interpret(f, [3]) == 3
diff --git a/pypy/rpython/llinterp.py b/pypy/rpython/llinterp.py
--- a/pypy/rpython/llinterp.py
+++ b/pypy/rpython/llinterp.py
@@ -890,6 +890,12 @@
     def op_gc_stack_bottom(self):
         pass       # marker for trackgcroot.py
 
+    def op_gc_pin(self, obj):
+        self.heap.pin(obj)
+
+    def op_gc_unpin(self, obj):
+        self.heap.unpin(obj)
+
     def op_gc_shadowstackref_new(self):   # stacklet+shadowstack
         raise NotImplementedError("gc_shadowstackref_new")
     def op_gc_shadowstackref_context(self):
diff --git a/pypy/rpython/lltypesystem/llheap.py b/pypy/rpython/lltypesystem/llheap.py
--- a/pypy/rpython/lltypesystem/llheap.py
+++ b/pypy/rpython/lltypesystem/llheap.py
@@ -35,3 +35,10 @@
 
 def thread_die():
     pass
+
+def pin(obj):
+    pass
+
+def unpin(obj):
+    pass
+
diff --git a/pypy/rpython/lltypesystem/lloperation.py b/pypy/rpython/lltypesystem/lloperation.py
--- a/pypy/rpython/lltypesystem/lloperation.py
+++ b/pypy/rpython/lltypesystem/lloperation.py
@@ -469,6 +469,8 @@
     'gc_assume_young_pointers': LLOp(canrun=True),
     'gc_writebarrier_before_copy': LLOp(canrun=True),
     'gc_heap_stats'       : LLOp(canmallocgc=True),
+    'gc_pin'              : LLOp(canrun=True),
+    'gc_unpin'            : LLOp(canrun=True),
 
     'gc_get_rpy_roots'    : LLOp(),
     'gc_get_rpy_referents': LLOp(),


More information about the pypy-commit mailing list