[pypy-commit] pypy op_malloc_gc: In-progress.
arigo
noreply at buildbot.pypy.org
Sat Dec 17 18:52:30 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: op_malloc_gc
Changeset: r50628:ac65509a7f46
Date: 2011-12-17 16:13 +0100
http://bitbucket.org/pypy/pypy/changeset/ac65509a7f46/
Log: In-progress.
diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py
--- a/pypy/jit/backend/llsupport/gc.py
+++ b/pypy/jit/backend/llsupport/gc.py
@@ -690,6 +690,16 @@
self.generate_function('malloc_nursery', malloc_nursery,
[lltype.Signed])
+ def malloc_array(itemsize, tid, num_elem):
+ type_id = llop.extract_ushort(llgroup.HALFWORD, tid)
+ check_typeid(type_id)
+ return llop1.do_malloc_varsize_clear(
+ llmemory.GCREF,
+ type_id, num_elem, self.array_basesize, itemsize,
+ self.array_length_ofs)
+ self.generate_function('malloc_array', malloc_array,
+ [lltype.Signed] * 3)
+
## # make the fixed malloc function, with one argument
## def malloc_gc_fixed(size):
## type_id = rffi.cast(llgroup.HALFWORD, 0) # missing here
@@ -721,17 +731,6 @@
## self.write_barrier_descr = WriteBarrierDescr(self)
## self.fielddescr_tid = self.write_barrier_descr.fielddescr_tid
## #
-## def malloc_array(itemsize, tid, num_elem):
-## type_id = llop.extract_ushort(llgroup.HALFWORD, tid)
-## check_typeid(type_id)
-## return llop1.do_malloc_varsize_clear(
-## llmemory.GCREF,
-## type_id, num_elem, self.array_basesize, itemsize,
-## self.array_length_ofs)
-## ###self.malloc_array = malloc_array
-## self.GC_MALLOC_ARRAY = lltype.Ptr(lltype.FuncType(
-## [lltype.Signed] * 3, llmemory.GCREF))
-## #
## (str_basesize, str_itemsize, str_ofs_length
## ) = symbolic.get_array_token(rstr.STR, True)
## (unicode_basesize, unicode_itemsize, unicode_ofs_length
diff --git a/pypy/jit/backend/llsupport/rewrite.py b/pypy/jit/backend/llsupport/rewrite.py
--- a/pypy/jit/backend/llsupport/rewrite.py
+++ b/pypy/jit/backend/llsupport/rewrite.py
@@ -122,12 +122,10 @@
pass # total_size is still -1
if total_size >= 0:
self.gen_malloc_nursery(total_size, op.result)
+ self.gen_initialize_tid(op.result, tid)
+ self.gen_initialize_len(op.result, v_length, arraylen_descr)
else:
- xxx
- self.gen_new_array(base_size, op.result,
- v_length, ConstInt(item_size))
- self.gen_initialize_tid(op.result, tid)
- self.gen_initialize_len(op.result, v_length, arraylen_descr)
+ self.gen_malloc_array(item_size, tid, v_length, op.result)
# ----------
@@ -139,18 +137,27 @@
self._op_malloc_nursery = None
self.recent_mallocs.clear()
+ def _gen_call_malloc_gc(self, args, v_result):
+ """Generate a CALL_MALLOC_GC with the given args."""
+ self.emitting_an_operation_that_can_collect()
+ op = ResOperation(rop.CALL_MALLOC_GC, args, v_result)
+ self.newops.append(op)
+ # mark 'v_result' as freshly malloced
+ self.recent_mallocs[v_result] = None
+
def gen_malloc_fixedsize(self, size, v_result):
"""Generate a CALL_MALLOC_GC(malloc_fixedsize_fn, Const(size)).
Note that with the framework GC, this should be called very rarely.
"""
- self.emitting_an_operation_that_can_collect()
- c_size = ConstInt(size)
- op = ResOperation(rop.CALL_MALLOC_GC,
- [self.gc_ll_descr.c_malloc_fixedsize_fn, c_size],
- v_result)
- self.newops.append(op)
- # mark 'v_result' as freshly malloced
- self.recent_mallocs[v_result] = None
+ self._gen_call_malloc_gc([self.gc_ll_descr.c_malloc_fixedsize_fn,
+ ConstInt(size)], v_result)
+
+ def gen_malloc_array(self, itemsize, tid, v_num_elem, v_result):
+ """Generate a CALL_MALLOC_GC(malloc_array_fn, ...)."""
+ self._gen_call_malloc_gc([self.gc_ll_descr.c_malloc_array_fn,
+ ConstInt(itemsize),
+ ConstInt(tid),
+ v_num_elem], v_result)
def gen_malloc_nursery(self, size, v_result):
"""Try to generate or update a CALL_MALLOC_NURSERY.
diff --git a/pypy/jit/backend/llsupport/test/test_rewrite.py b/pypy/jit/backend/llsupport/test/test_rewrite.py
--- a/pypy/jit/backend/llsupport/test/test_rewrite.py
+++ b/pypy/jit/backend/llsupport/test/test_rewrite.py
@@ -319,9 +319,8 @@
jump(i0)
""", """
[i0]
- p0 = malloc_gc(%(bdescr.get_base_size(False))d, i0, 1)
- setfield_gc(p0, 8765, descr=tiddescr)
- setfield_gc(p0, i0, descr=blendescr)
+ p0 = call_malloc_gc(ConstClass(malloc_array), 1, \
+ %(bdescr.tid)d, i0)
jump(i0)
""")
More information about the pypy-commit
mailing list