Author: Armin Rigo <[email protected]>
Branch: op_malloc_gc
Changeset: r49513:454b0eb8af85
Date: 2011-11-17 18:15 +0100
http://bitbucket.org/pypy/pypy/changeset/454b0eb8af85/
Log: Test and fix for allocating tiny structures --- they are smaller
than the minimal_size_in_nursery.
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
@@ -879,7 +879,6 @@
basesize = descr.get_base_size(self.tsc)
itemsize = descr.get_item_size(self.tsc)
fullsize = basesize + newlength * itemsize
- fullsize = self.round_up_for_allocation(fullsize)
self.gen_malloc_const(fullsize, op.result)
self.gen_initialize_tid(op.result, descr.tid)
self.gen_initialize_len(op.result, v_newlength, descr)
@@ -915,6 +914,7 @@
return self.newops
def gen_malloc_const(self, size, v_result):
+ size = self.round_up_for_allocation(size)
if self.op_malloc_gc is None:
# it is the first we see: emit MALLOC_GC
op = ResOperation(rop.MALLOC_GC,
diff --git a/pypy/jit/backend/llsupport/test/test_gc.py
b/pypy/jit/backend/llsupport/test/test_gc.py
--- a/pypy/jit/backend/llsupport/test/test_gc.py
+++ b/pypy/jit/backend/llsupport/test/test_gc.py
@@ -550,12 +550,14 @@
def check_rewrite(self, frm_operations, to_operations):
self.gc_ll_descr.translate_support_code = False
try:
- S = lltype.GcStruct('S', ('x', lltype.Signed))
+ S = lltype.GcStruct('S', ('x', lltype.Signed),
+ ('y', lltype.Signed))
sdescr = get_size_descr(self.gc_ll_descr, S)
sdescr.tid = 1234
#
T = lltype.GcStruct('T', ('y', lltype.Signed),
- ('z', lltype.Signed))
+ ('z', lltype.Signed),
+ ('t', lltype.Signed))
tdescr = get_size_descr(self.gc_ll_descr, T)
tdescr.tid = 5678
#
@@ -569,7 +571,12 @@
bdescr.tid = 8765
blendescr = get_field_arraylen_descr(self.gc_ll_descr, B)
#
+ E = lltype.GcStruct('Empty')
+ edescr = get_size_descr(self.gc_ll_descr, E)
+ edescr.tid = 9000
+ #
tiddescr = self.gc_ll_descr.fielddescr_tid
+ WORD = globals()['WORD']
#
ops = parse(frm_operations, namespace=locals())
expected = parse(to_operations % Evaluator(locals()),
@@ -681,6 +688,21 @@
jump()
""")
+ def test_rewrite_assembler_minimal_size(self):
+ self.check_rewrite("""
+ []
+ p0 = new(descr=edescr)
+ p1 = new(descr=edescr)
+ jump()
+ """, """
+ []
+ p0 = malloc_gc(%(4*WORD)d)
+ setfield_gc(p0, 9000, descr=tiddescr)
+ p1 = int_add(p0, %(2*WORD)d)
+ setfield_gc(p1, 9000, descr=tiddescr)
+ jump()
+ """)
+
def test_rewrite_assembler_initialization_store(self):
S = lltype.GcStruct('S', ('parent', OBJECT),
('x', lltype.Signed))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit