[pypy-commit] pypy default: Simplify a bit, computing a "toobig" value in a way that is
arigo
noreply at buildbot.pypy.org
Tue Aug 2 11:25:09 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r46185:6df7a687dcae
Date: 2011-08-01 21:41 +0200
http://bitbucket.org/pypy/pypy/changeset/6df7a687dcae/
Log: Simplify a bit, computing a "toobig" value in a way that is clearly
constant-foldable, followed by a r_uint comparison.
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
@@ -517,13 +517,15 @@
# constant-folded because self.nonlarge_max, size and itemsize
# are all constants (the arguments are constant due to
# inlining).
- too_many_items = raw_malloc_usage(nonvarsize) > self.nonlarge_max
- if not too_many_items and raw_malloc_usage(itemsize) > 0:
- maxlength = self.nonlarge_max - raw_malloc_usage(nonvarsize)
- maxlength = maxlength // raw_malloc_usage(itemsize)
- too_many_items = r_uint(length) > r_uint(maxlength)
+ maxsize = self.nonlarge_max - raw_malloc_usage(nonvarsize)
+ if maxsize < 0:
+ toobig = r_uint(0) # the nonvarsize alone is too big
+ elif raw_malloc_usage(itemsize):
+ toobig = r_uint(maxsize // raw_malloc_usage(itemsize)) + 1
+ else:
+ toobig = r_uint(sys.maxint) + 1
- if too_many_items:
+ if r_uint(length) >= r_uint(toobig):
#
# If the total size of the object would be larger than
# 'nonlarge_max', then allocate it externally. We also
More information about the pypy-commit
mailing list