[pypy-commit] pypy stm-gc: Fix signature of set_tls.

arigo noreply at buildbot.pypy.org
Sat Feb 4 21:51:58 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r52102:470ded236eeb
Date: 2012-02-04 20:52 +0100
http://bitbucket.org/pypy/pypy/changeset/470ded236eeb/

Log:	Fix signature of set_tls.

diff --git a/pypy/rpython/memory/gc/stmgc.py b/pypy/rpython/memory/gc/stmgc.py
--- a/pypy/rpython/memory/gc/stmgc.py
+++ b/pypy/rpython/memory/gc/stmgc.py
@@ -2,6 +2,7 @@
 from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.rpython.lltypesystem.llmemory import raw_malloc_usage
 from pypy.rpython.memory.gc.base import GCBase
+from pypy.rpython.annlowlevel import llhelper
 from pypy.rlib.rarithmetic import LONG_BIT
 from pypy.rlib.debug import ll_assert, debug_start, debug_stop
 from pypy.module.thread import ll_thread
@@ -66,6 +67,11 @@
         self.collector = Collector(self)
         self.max_nursery_size = max_nursery_size
         #
+        def _do_get_size(obj):     # indirection to hide 'self'
+            return self.get_size(obj)
+        GETSIZE = lltype.Ptr(lltype.FuncType([llmemory.Address],lltype.Signed))
+        self._do_get_size = llhelper(GETSIZE, _do_get_size)
+        #
         self.declare_readers()
         self.declare_write_barrier()
 
@@ -88,7 +94,8 @@
         """Setup a thread.  Allocates the thread-local data structures.
         Must be called only once per OS-level thread."""
         tls = lltype.malloc(self.GCTLS, flavor='raw')
-        self.stm_operations.set_tls(llmemory.cast_ptr_to_adr(tls))
+        self.stm_operations.set_tls(llmemory.cast_ptr_to_adr(tls),
+                                    self._do_get_size)
         tls.nursery_start = self._alloc_nursery()
         tls.nursery_size  = self.max_nursery_size
         tls.nursery_free  = tls.nursery_start
diff --git a/pypy/rpython/memory/gc/test/test_stmgc.py b/pypy/rpython/memory/gc/test/test_stmgc.py
--- a/pypy/rpython/memory/gc/test/test_stmgc.py
+++ b/pypy/rpython/memory/gc/test/test_stmgc.py
@@ -22,7 +22,7 @@
 
     threadnum = 0          # 0 = main thread; 1,2,3... = transactional threads
 
-    def set_tls(self, tls):
+    def set_tls(self, tls, getsize_fn):
         assert lltype.typeOf(tls) == llmemory.Address
         assert tls
         if self.threadnum == 0:
@@ -30,6 +30,7 @@
             self._tls_dict = {0: tls}
             self._tldicts = {0: {}}
             self._tldicts_iterators = {}
+            self._getsize_fn = getsize_fn
             self._transactional_copies = []
         else:
             self._tls_dict[self.threadnum] = tls
@@ -359,3 +360,8 @@
         self.checkflags(sr3, 1, 0, llmemory.NULL)
         self.checkflags(sr4, 1, 0, llmemory.NULL)
         self.checkflags(s  , 1, 0, llmemory.NULL)
+
+    def test_do_get_size(self):
+        s1, s1_adr = self.malloc(S)
+        assert (repr(self.gc.stm_operations._getsize_fn(s1_adr)) ==
+                repr(fake_get_size(s1_adr)))


More information about the pypy-commit mailing list