[pypy-commit] pypy stm-gc: More tests until failure found.
arigo
noreply at buildbot.pypy.org
Thu Apr 26 10:44:33 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r54756:d9148faf5f90
Date: 2012-04-25 21:41 +0200
http://bitbucket.org/pypy/pypy/changeset/d9148faf5f90/
Log: More tests until failure found.
diff --git a/pypy/rpython/memory/gc/stmtls.py b/pypy/rpython/memory/gc/stmtls.py
--- a/pypy/rpython/memory/gc/stmtls.py
+++ b/pypy/rpython/memory/gc/stmtls.py
@@ -126,6 +126,9 @@
self._clear_version_for_global_object(hdr)
if not we_are_translated():
del self.mt_global_turned_local # don't use any more
+ #
+ if self.gc.DEBUG:
+ self.check_all_global_objects()
def leave_transactional_mode(self):
"""Restart using the main thread for mallocs."""
@@ -135,7 +138,10 @@
del StmGCTLS.nontranslated_dict[key]
self.start_transaction()
#
- # Do something special here after we restarted the "transaction"
+ if self.gc.DEBUG:
+ self.check_all_global_objects()
+ #
+ # Do something special here after we restarted the execution
# in the main thread. At this point, *all* objects are GLOBAL.
# The write_barrier will ensure that any write makes the written-to
# objects LOCAL again. However, it is possible that the write
@@ -602,3 +608,41 @@
self.sharedarea_tls.free_object(obj)
#
obj = next
+
+ # ------------------------------------------------------------
+
+ def _debug_check_all_global1(self, root):
+ self._debug_check_all_global(root, None)
+
+ def _debug_check_all_global(self, root, ignored):
+ obj = root.address[0]
+ if self.debug_seen.contains(obj):
+ return
+ hdr = self.gc.header(obj)
+ ll_assert(hdr.tid & GCFLAG_GLOBAL != 0,
+ "debug_check: missing GLOBAL")
+ ll_assert(hdr.tid & GCFLAG_WAS_COPIED == 0,
+ "debug_check: unexpected WAS_COPIED")
+ ll_assert(hdr.tid & GCFLAG_VISITED == 0,
+ "debug_check: unexpected VISITED")
+ ll_assert(hdr.tid & GCFLAG_HAS_SHADOW == 0,
+ "debug_check: unexpected HAS_SHADOW")
+ self.gc.get_size(obj) # extra checks
+ self.pending.append(obj)
+ self.debug_seen.setitem(obj, obj)
+
+ def check_all_global_objects(self):
+ self.pending = self.AddressStack()
+ self.debug_seen = self.AddressDict()
+ self.gc.root_walker.walk_current_stack_roots(
+ StmGCTLS._debug_check_all_global1, self)
+ while self.pending.non_empty():
+ obj = self.pending.pop()
+ offset = self.gc.weakpointer_offset(self.gc.get_type_id(obj))
+ if offset < 0: # common case: not a weakref
+ self.gc.trace(obj, self._debug_check_all_global, None)
+ else:
+ if (obj + offset).address[0]:
+ self._debug_check_all_global(obj + offset, None)
+ self.pending.delete()
+ self.debug_seen.delete()
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
@@ -125,7 +125,10 @@
callback(addr, arg)
def fake_weakpointer_offset(tid):
- return llmemory.offsetof(WR, 'wadr')
+ if tid == 124:
+ return llmemory.offsetof(WR, 'wadr')
+ else:
+ return -1
class FakeRootWalker:
def walk_current_stack_roots(self, *args):
@@ -161,7 +164,7 @@
# test helpers
def malloc(self, STRUCT, weakref=False, globl='auto'):
size = llarena.round_up_for_allocation(llmemory.sizeof(STRUCT))
- tid = lltype.cast_primitive(llgroup.HALFWORD, 123)
+ tid = lltype.cast_primitive(llgroup.HALFWORD, 123 + weakref)
if globl == 'auto':
globl = (self.gc.stm_operations.threadnum == 0)
if globl:
diff --git a/pypy/translator/stm/test/targetdemo.py b/pypy/translator/stm/test/targetdemo.py
--- a/pypy/translator/stm/test/targetdemo.py
+++ b/pypy/translator/stm/test/targetdemo.py
@@ -105,8 +105,13 @@
#
rstm.run_all_transactions(InitialTransaction(),
num_threads=glob.NUM_THREADS)
+ check_chained_list(glob.anchor.next)
#
+ glob.anchor.next = None
+ rstm.run_all_transactions(InitialTransaction(),
+ num_threads=glob.NUM_THREADS)
check_chained_list(glob.anchor.next)
+ #
return 0
# _____ Define and setup target ___
More information about the pypy-commit
mailing list