Author: Armin Rigo <[email protected]>
Branch: gc-del
Changeset: r63680:2e7d8798d967
Date: 2013-04-27 12:55 +0200
http://bitbucket.org/pypy/pypy/changeset/2e7d8798d967/
Log: Constant-fold some more checks of GCFLAG_HAS_CARDS for the case
where we're compiled without card support.
diff --git a/rpython/memory/gc/minimark.py b/rpython/memory/gc/minimark.py
--- a/rpython/memory/gc/minimark.py
+++ b/rpython/memory/gc/minimark.py
@@ -1020,7 +1020,7 @@
ll_assert(self.header(obj).tid & GCFLAG_CARDS_SET == 0,
"unexpected GCFLAG_CARDS_SET")
# if the GCFLAG_HAS_CARDS is set, check that all bits are zero now
- if self.header(obj).tid & GCFLAG_HAS_CARDS:
+ if self.has_card(self.header(obj)):
if self.card_page_indices <= 0:
ll_assert(False, "GCFLAG_HAS_CARDS but not using card marking")
return
@@ -1085,6 +1085,12 @@
def JIT_minimal_size_in_nursery(cls):
return cls.minimal_size_in_nursery
+ def has_card(self, objhdr):
+ if self.card_page_indices <= 0: # check constant-folded
+ return False
+ else:
+ return (objhdr.tid & GCFLAG_HAS_CARDS) != 0
+
def write_barrier(self, newvalue, addr_struct):
if self.header(addr_struct).tid & GCFLAG_TRACK_YOUNG_PTRS:
self.remember_young_pointer(addr_struct, newvalue)
@@ -1109,7 +1115,7 @@
#
if DEBUG: # note: PYPY_GC_DEBUG=1 does not enable this
ll_assert(self.debug_is_old_object(addr_struct) or
- self.header(addr_struct).tid & GCFLAG_HAS_CARDS != 0,
+ self.has_card(self.header(addr_struct)),
"young object with GCFLAG_TRACK_YOUNG_PTRS and no cards")
#
# If it seems that what we are writing is a pointer to a young obj
@@ -1159,7 +1165,7 @@
# We know that 'addr_array' has GCFLAG_TRACK_YOUNG_PTRS so far.
#
objhdr = self.header(addr_array)
- if objhdr.tid & GCFLAG_HAS_CARDS == 0:
+ if not self.has_card(objhdr):
#
if DEBUG: # note: PYPY_GC_DEBUG=1 does not enable this
ll_assert(self.debug_is_old_object(addr_array),
@@ -1207,7 +1213,7 @@
# GCFLAG_CARDS_SET if possible; otherwise, it falls back
# to jit_remember_young_pointer().
objhdr = self.header(addr_array)
- if objhdr.tid & GCFLAG_HAS_CARDS:
+ if self.has_card(objhdr):
self.old_objects_with_cards_set.append(addr_array)
objhdr.tid |= GCFLAG_CARDS_SET
else:
@@ -1248,7 +1254,7 @@
return True
# ^^^ a fast path of write-barrier
#
- if source_hdr.tid & GCFLAG_HAS_CARDS != 0:
+ if self.has_card(source_hdr):
#
if source_hdr.tid & GCFLAG_TRACK_YOUNG_PTRS == 0:
# The source object may have random young pointers.
@@ -1259,7 +1265,7 @@
# The source object has no young pointers at all. Done.
return True
#
- if dest_hdr.tid & GCFLAG_HAS_CARDS == 0:
+ if not self.has_card(dest_hdr):
# The dest object doesn't have cards. Do it manually.
return False
#
@@ -1593,7 +1599,7 @@
self.old_objects_pointing_to_young.append(obj)
added_somewhere = True
#
- if hdr.tid & GCFLAG_HAS_CARDS != 0:
+ if self.has_card(hdr):
ll_assert(hdr.tid & GCFLAG_CARDS_SET != 0,
"young array: GCFLAG_HAS_CARDS without GCFLAG_CARDS_SET")
self.old_objects_with_cards_set.append(obj)
@@ -1772,8 +1778,7 @@
arena = llarena.getfakearenaaddress(obj - size_gc_header)
#
# Must also include the card marker area, if any
- if (self.card_page_indices > 0 # <- this is constant-folded
- and self.header(obj).tid & GCFLAG_HAS_CARDS):
+ if self.has_card(self.header(obj)):
#
# Get the length and compute the number of extra bytes
typeid = self.get_type_id(obj)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit