[pypy-commit] pypy default: Fixes:
arigo
noreply at buildbot.pypy.org
Tue Sep 30 14:34:22 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r73745:b422496d47be
Date: 2014-09-30 14:21 +0200
http://bitbucket.org/pypy/pypy/changeset/b422496d47be/
Log: Fixes:
* don't zero out large external mallocs for no reason
* fix gc.malloc(), used only for testing, to respect the 'zero' flag
diff --git a/rpython/memory/gc/base.py b/rpython/memory/gc/base.py
--- a/rpython/memory/gc/base.py
+++ b/rpython/memory/gc/base.py
@@ -127,17 +127,10 @@
return self.get_size(obj)
def malloc(self, typeid, length=0, zero=False):
- """For testing. The interface used by the gctransformer is
+ """NOT_RPYTHON
+ For testing. The interface used by the gctransformer is
the four malloc_[fixed,var]size[_clear]() functions.
"""
- #TODO:check if the zero flag is unuseful now. If so, remove it
-
- # Rules about fallbacks in case of missing malloc methods:
- # * malloc_fixedsize_clear() and malloc_varsize_clear() are mandatory
- # * malloc_fixedsize() and malloc_varsize() fallback to the above
- # XXX: as of r49360, gctransformer.framework never inserts calls
- # to malloc_varsize(), but always uses malloc_varsize_clear()
-
size = self.fixed_size(typeid)
needs_finalizer = bool(self.getfinalizer(typeid))
finalizer_is_light = bool(self.getlightfinalizer(typeid))
@@ -154,6 +147,7 @@
malloc_varsize = self.malloc_varsize
ref = malloc_varsize(typeid, length, size, itemsize,
offset_to_length)
+ size += itemsize * length
else:
if self.malloc_zero_filled:
malloc_fixedsize = self.malloc_fixedsize_clear
@@ -163,7 +157,10 @@
finalizer_is_light,
contains_weakptr)
# lots of cast and reverse-cast around...
- return llmemory.cast_ptr_to_adr(ref)
+ ref = llmemory.cast_ptr_to_adr(ref)
+ if zero and not self.malloc_zero_filled:
+ llmemory.raw_memclear(ref, size)
+ return ref
def id(self, ptr):
return lltype.cast_ptr_to_int(ptr)
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -431,7 +431,7 @@
def _alloc_nursery(self):
# the start of the nursery: we actually allocate a bit more for
# the nursery than really needed, to simplify pointer arithmetic
- # in malloc_fixedsize_clear(). The few extra pages are never used
+ # in malloc_fixedsize(). The few extra pages are never used
# anyway so it doesn't even counct.
nursery = llarena.arena_malloc(self._nursery_memory_size(), 0)
if not nursery:
@@ -613,7 +613,7 @@
# 'minimal_size_in_nursery'
ll_assert(raw_malloc_usage(totalsize) >=
raw_malloc_usage(self.minimal_size_in_nursery),
- "malloc_varsize_clear(): totalsize < minimalsize")
+ "malloc_varsize(): totalsize < minimalsize")
#
# Get the memory from the nursery. If there is not enough space
# there, do a collect first.
@@ -687,7 +687,7 @@
raw_malloc(), possibly as an object with card marking enabled,
if it has gc pointers in its var-sized part. 'length' should be
specified as 0 if the object is not varsized. The returned
- object is fully initialized and zero-filled."""
+ object is fully initialized, but not zero-filled."""
#
# Here we really need a valid 'typeid', not 0 (as the JIT might
# try to send us if there is still a bug).
@@ -731,9 +731,8 @@
self.small_request_threshold,
"rounding up made totalsize > small_request_threshold")
#
- # Allocate from the ArenaCollection and clear the memory returned.
+ # Allocate from the ArenaCollection. Don't clear it.
result = self.ac.malloc(totalsize)
- llmemory.raw_memclear(result, totalsize)
#
# An object allocated from ArenaCollection is always old, even
# if 'can_make_young'. The interesting case of 'can_make_young'
@@ -779,19 +778,20 @@
# Allocate the object using arena_malloc(), which we assume here
# is just the same as raw_malloc(), but allows the extra
# flexibility of saying that we have extra words in the header.
- # The memory returned is cleared by a raw_memclear().
- arena = llarena.arena_malloc(allocsize, 2)
+ # The memory returned is not cleared.
+ arena = llarena.arena_malloc(allocsize, 0)
if not arena:
raise MemoryError("cannot allocate large object")
#
- # Reserve the card mark bits as a list of single bytes
- # (the loop is empty in C).
+ # Reserve the card mark bits as a list of single bytes,
+ # and clear these bytes.
i = 0
while i < cardheadersize:
llarena.arena_reserve(arena + i, llmemory.sizeof(lltype.Char))
+ arena.char[i] = '\x00'
i += 1
#
- # Reserve the actual object. (This is also a no-op in C).
+ # Reserve the actual object. (This is a no-op in C).
result = arena + cardheadersize
llarena.arena_reserve(result, totalsize)
#
More information about the pypy-commit
mailing list