[pypy-commit] pypy default: minimark: Tweaks to reduce by one the number of checks in the common
arigo
noreply at buildbot.pypy.org
Thu Apr 5 10:23:23 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r54194:01a73d86d3c7
Date: 2012-04-04 19:23 +0200
http://bitbucket.org/pypy/pypy/changeset/01a73d86d3c7/
Log: minimark: Tweaks to reduce by one the number of checks 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
@@ -1426,23 +1426,25 @@
self._visit_young_rawmalloced_object(obj)
return
#
- # If 'obj' was already forwarded, change it to its forwarding address.
- if self.is_forwarded(obj):
+ size_gc_header = self.gcheaderbuilder.size_gc_header
+ if 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
- #
- # First visit to 'obj': we must move it out of the nursery.
- size_gc_header = self.gcheaderbuilder.size_gc_header
- size = self.get_size(obj)
- totalsize = size_gc_header + size
- #
- if self.header(obj).tid & GCFLAG_HAS_SHADOW == 0:
- #
- # Common case: allocate a new nonmovable location for it.
- newhdr = self._malloc_out_of_nursery(totalsize)
#
else:
- # The object has already a shadow.
+ # First visit to an object that has already a shadow.
newobj = self.nursery_objects_shadows.get(obj)
ll_assert(newobj != NULL, "GCFLAG_HAS_SHADOW but no shadow found")
newhdr = newobj - size_gc_header
@@ -1450,6 +1452,8 @@
# Remove the flag GCFLAG_HAS_SHADOW, so that it doesn't get
# copied to the shadow itself.
self.header(obj).tid &= ~GCFLAG_HAS_SHADOW
+ #
+ totalsize = size_gc_header + self.get_size(obj)
#
# Copy it. Note that references to other objects in the
# nursery are kept unchanged in this step.
More information about the pypy-commit
mailing list