[pypy-commit] pypy stm-gc: Piece together malloc_varsize_clear().
arigo
noreply at buildbot.pypy.org
Thu Feb 9 17:13:45 CET 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r52311:1106dbbc343f
Date: 2012-02-09 17:03 +0100
http://bitbucket.org/pypy/pypy/changeset/1106dbbc343f/
Log: Piece together malloc_varsize_clear().
diff --git a/pypy/rpython/memory/gc/stmgc.py b/pypy/rpython/memory/gc/stmgc.py
--- a/pypy/rpython/memory/gc/stmgc.py
+++ b/pypy/rpython/memory/gc/stmgc.py
@@ -187,7 +187,20 @@
def malloc_varsize_clear(self, typeid, length, size, itemsize,
offset_to_length):
- raise NotImplementedError
+ # XXX blindly copied from malloc_fixedsize_clear() for now.
+ # XXX Be more subtle, e.g. detecting overflows, at least
+ tls = self.collector.get_tls()
+ flags = tls.malloc_flags
+ size_gc_header = self.gcheaderbuilder.size_gc_header
+ nonvarsize = size_gc_header + size
+ totalsize = nonvarsize + itemsize * length
+ totalsize = llarena.round_up_for_allocation(totalsize)
+ result = self._allocate_bump_pointer(tls, totalsize)
+ llarena.arena_reserve(result, totalsize)
+ obj = result + size_gc_header
+ self.init_gc_object(result, typeid, flags=flags)
+ (obj + offset_to_length).signed[0] = length
+ return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
def _malloc_local_raw(self, tls, size):
More information about the pypy-commit
mailing list