[pypy-svn] r47294 - pypy/branch/kill-keepalives-again/pypy/rpython/memory
arigo at codespeak.net
arigo at codespeak.net
Mon Oct 8 17:35:52 CEST 2007
Author: arigo
Date: Mon Oct 8 17:35:52 2007
New Revision: 47294
Modified:
pypy/branch/kill-keepalives-again/pypy/rpython/memory/gc.py
Log:
* Use the new llarena interface.
* Fixes in the "are we running out of space" logic.
Modified: pypy/branch/kill-keepalives-again/pypy/rpython/memory/gc.py
==============================================================================
--- pypy/branch/kill-keepalives-again/pypy/rpython/memory/gc.py (original)
+++ pypy/branch/kill-keepalives-again/pypy/rpython/memory/gc.py Mon Oct 8 17:35:52 2007
@@ -1048,13 +1048,15 @@
raise NotImplementedError("weakptr in SemiSpaceGC")
size_gc_header = self.gcheaderbuilder.size_gc_header
totalsize = size_gc_header + size
- if can_collect and self.free + totalsize > self.top_of_space:
+ if raw_malloc_usage(totalsize) > self.top_of_space - self.free:
+ if not can_collect:
+ raise memoryError
self.collect()
#XXX need to increase the space size if the object is too big
#for bonus points do big objects differently
- if self.free + totalsize > self.top_of_space:
+ if raw_malloc_usage(totalsize) > self.top_of_space - self.free:
raise memoryError
- result = self.free
+ result = llarena.arena_reserve(self.free, totalsize)
self.init_gc_object(result, typeid)
self.free += totalsize
return llmemory.cast_adr_to_ptr(result+size_gc_header, llmemory.GCREF)
@@ -1070,14 +1072,15 @@
totalsize = ovfcheck(nonvarsize + varsize)
except OverflowError:
raise memoryError
- # XXX we can't use ovfcheck() for self.free + totalsize...
- if can_collect and self.free + totalsize > self.top_of_space:
+ if raw_malloc_usage(totalsize) > self.top_of_space - self.free:
+ if not can_collect:
+ raise memoryError
self.collect()
#XXX need to increase the space size if the object is too big
#for bonus points do big objects differently
- if self.free + totalsize > self.top_of_space:
+ if raw_malloc_usage(totalsize) > self.top_of_space - self.free:
raise memoryError
- result = self.free
+ result = llarena.arena_reserve(self.free, totalsize)
self.init_gc_object(result, typeid)
(result + size_gc_header + offset_to_length).signed[0] = length
self.free += totalsize
More information about the Pypy-commit
mailing list