[pypy-svn] pypy default: Add more precise asserts, designed to catch most cases where 'obj' is nonsense (it points inside an object, where there is a pointer).
arigo
commits-noreply at bitbucket.org
Mon Feb 21 13:37:19 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r42190:375a03b5f02e
Date: 2011-02-20 14:17 +0100
http://bitbucket.org/pypy/pypy/changeset/375a03b5f02e/
Log: Add more precise asserts, designed to catch most cases where 'obj'
is nonsense (it points inside an object, where there is a pointer).
diff --git a/pypy/rpython/memory/gc/minimark.py b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -108,6 +108,8 @@
GCFLAG_HAS_CARDS = first_gcflag << 5
GCFLAG_CARDS_SET = first_gcflag << 6 # <- at least one card bit is set
+TID_MASK = (first_gcflag << 7) - 1
+
FORWARDSTUB = lltype.GcStruct('forwarding_stub',
('forw', llmemory.Address))
@@ -820,9 +822,13 @@
that can never be set on a young object -- except if tid == -42.
"""
assert self.is_in_nursery(obj)
- result = (self.header(obj).tid & GCFLAG_FINALIZATION_ORDERING != 0)
+ tid = self.header(obj).tid
+ result = (tid & GCFLAG_FINALIZATION_ORDERING != 0)
if result:
- ll_assert(self.header(obj).tid == -42, "bogus header for young obj")
+ ll_assert(tid == -42, "bogus header for young obj")
+ else:
+ ll_assert(tid != 0, "bogus header (1)")
+ ll_assert(tid & ~TID_MASK == 0, "bogus header (2)")
return result
def get_forwarding_address(self, obj):
More information about the Pypy-commit
mailing list