[pypy-svn] r77119 - in pypy/branch/gen2-gc/pypy/rpython/memory: gc test
arigo at codespeak.net
arigo at codespeak.net
Thu Sep 16 16:17:15 CEST 2010
Author: arigo
Date: Thu Sep 16 16:17:13 2010
New Revision: 77119
Modified:
pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimark.py
pypy/branch/gen2-gc/pypy/rpython/memory/test/test_gc.py
Log:
Malloc_nonmovable.
Modified: pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimark.py
==============================================================================
--- pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimark.py (original)
+++ pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimark.py Thu Sep 16 16:17:13 2010
@@ -345,6 +345,7 @@
if rawtotalsize <= self.small_request_threshold:
#
# Ask the ArenaCollection to do the malloc.
+ totalsize = llarena.round_up_for_allocation(totalsize)
result = self.ac.malloc(totalsize)
#
else:
@@ -373,7 +374,7 @@
XXX
def can_malloc_nonmovable(self):
- XXX
+ return True
def can_move(self, obj):
"""Overrides the parent can_move()."""
@@ -400,12 +401,36 @@
return True
+ def malloc_fixedsize_nonmovable(self, typeid):
+ size_gc_header = self.gcheaderbuilder.size_gc_header
+ totalsize = size_gc_header + self.fixed_size(typeid)
+ #
+ result = self._malloc_nonmovable(typeid, totalsize)
+ return result + size_gc_header
+
def malloc_varsize_nonmovable(self, typeid, length):
- XXX
+ size_gc_header = self.gcheaderbuilder.size_gc_header
+ nonvarsize = size_gc_header + self.fixed_size(typeid)
+ itemsize = self.varsize_item_sizes(typeid)
+ offset_to_length = self.varsize_offset_to_length(typeid)
+ try:
+ varsize = ovfcheck(itemsize * length)
+ totalsize = ovfcheck(nonvarsize + varsize)
+ except OverflowError:
+ raise MemoryError
+ #
+ result = self._malloc_nonmovable(typeid, totalsize)
+ obj = result + size_gc_header
+ (obj + offset_to_length).signed[0] = length
+ return obj
def malloc_nonmovable(self, typeid, length, zero):
# helper for testing, same as GCBase.malloc
- XXX
+ if self.is_varsize(typeid):
+ obj = self.malloc_varsize_nonmovable(typeid, length)
+ else:
+ obj = self.malloc_fixedsize_nonmovable(typeid)
+ return obj
# ----------
Modified: pypy/branch/gen2-gc/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/branch/gen2-gc/pypy/rpython/memory/test/test_gc.py (original)
+++ pypy/branch/gen2-gc/pypy/rpython/memory/test/test_gc.py Thu Sep 16 16:17:13 2010
@@ -772,3 +772,4 @@
class TestMiniMarkGC(TestSemiSpaceGC):
from pypy.rpython.memory.gc.minimark import MiniMarkGC as GCClass
GC_CAN_SHRINK_BIG_ARRAY = False
+ GC_CANNOT_MALLOC_NONMOVABLE = False
More information about the Pypy-commit
mailing list