[pypy-commit] pypy gc-minimark-pinning: Just move the blocks around to keep the number of flag checks
arigo
noreply at buildbot.pypy.org
Fri Apr 13 16:06:27 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: gc-minimark-pinning
Changeset: r54333:549ac1d84b87
Date: 2012-04-13 16:06 +0200
http://bitbucket.org/pypy/pypy/changeset/549ac1d84b87/
Log: Just move the blocks around to keep the number of flag checks
minimal in the common case.
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
@@ -1487,7 +1487,23 @@
return
#
size_gc_header = self.gcheaderbuilder.size_gc_header
- if self.header(obj).tid & GCFLAG_PINNED:
+ if self.header(obj).tid & (GCFLAG_HAS_SHADOW|GCFLAG_PINNED) == 0:
+ #
+ # Common case: 'obj' was not already forwarded (otherwise
+ # tid == -42, containing all flags), and it doesn't have the
+ # HAS_SHADOW or PINNED flags either. We must move it out of
+ # the nursery, into a new nonmovable location.
+ totalsize = size_gc_header + self.get_size(obj)
+ newhdr = self._malloc_out_of_nursery(totalsize)
+ #
+ elif self.is_forwarded(obj):
+ #
+ # 'obj' was already forwarded. Change the original reference
+ # to point to its forwarding address, and we're done.
+ root.address[0] = self.get_forwarding_address(obj)
+ return
+ #
+ elif self.header(obj).tid & GCFLAG_PINNED:
hdr = self.header(obj)
if hdr.tid & GCFLAG_VISITED:
return
@@ -1497,21 +1513,6 @@
self.surviving_pinned_objects.insert(
llarena.getfakearenaaddress(obj - size_gc_header))
return
- elif self.header(obj).tid & GCFLAG_HAS_SHADOW == 0:
- #
- # Common case: 'obj' was not already forwarded (otherwise
- # tid == -42, containing all flags), and it doesn't have the
- # HAS_SHADOW flag either. We must move it out of the nursery,
- # into a new nonmovable location.
- totalsize = size_gc_header + self.get_size(obj)
- newhdr = self._malloc_out_of_nursery(totalsize)
- #
- elif self.is_forwarded(obj):
- #
- # 'obj' was already forwarded. Change the original reference
- # to point to its forwarding address, and we're done.
- root.address[0] = self.get_forwarding_address(obj)
- return
#
else:
# First visit to an object that has already a shadow.
More information about the pypy-commit
mailing list