[pypy-svn] r68404 - in pypy/branch/inline-fastpath-malloc/pypy/rpython/memory: gctransform test
fijal at codespeak.net
fijal at codespeak.net
Tue Oct 13 23:29:11 CEST 2009
Author: fijal
Date: Tue Oct 13 23:29:10 2009
New Revision: 68404
Modified:
pypy/branch/inline-fastpath-malloc/pypy/rpython/memory/gctransform/framework.py
pypy/branch/inline-fastpath-malloc/pypy/rpython/memory/test/test_transformed_gc.py
Log:
A test for new gc operations. Need to assert stuff,
working on it
Modified: pypy/branch/inline-fastpath-malloc/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/branch/inline-fastpath-malloc/pypy/rpython/memory/gctransform/framework.py (original)
+++ pypy/branch/inline-fastpath-malloc/pypy/rpython/memory/gctransform/framework.py Tue Oct 13 23:29:10 2009
@@ -599,6 +599,28 @@
hop.genop("direct_call", [self.assume_young_pointers_ptr,
self.c_const_gc, v_addr])
+ def gct_gc_adr_of_nursery_free(self, hop):
+ if getattr(self.gcdata.gc, 'nursery_free', None) is None:
+ raise NotImplementedError("gc_adr_of_nursery_free only for generational gcs")
+ op = hop.spaceop
+ ofs = llmemory.offsetof(self.c_const_gc.concretetype.TO,
+ 'inst_nursery_free')
+ c_ofs = rmodel.inputconst(lltype.Signed, ofs)
+ v_gc_adr = hop.genop('cast_ptr_to_adr', [self.c_const_gc],
+ resulttype=llmemory.Address)
+ hop.genop('adr_add', [v_gc_adr, c_ofs], resultvar=op.result)
+
+ def gct_gc_adr_of_nursery_top(self, hop):
+ if getattr(self.gcdata.gc, 'nursery_top', None) is None:
+ raise NotImplementedError("gc_adr_of_nursery_top only for generational gcs")
+ op = hop.spaceop
+ ofs = llmemory.offsetof(self.c_const_gc.concretetype.TO,
+ 'inst_nursery_top')
+ c_ofs = rmodel.inputconst(lltype.Signed, ofs)
+ v_gc_adr = hop.genop('cast_ptr_to_adr', [self.c_const_gc],
+ resulttype=llmemory.Address)
+ hop.genop('adr_add', [v_gc_adr, c_ofs], resultvar=op.result)
+
def _can_realloc(self):
return self.gcdata.gc.can_realloc
Modified: pypy/branch/inline-fastpath-malloc/pypy/rpython/memory/test/test_transformed_gc.py
==============================================================================
--- pypy/branch/inline-fastpath-malloc/pypy/rpython/memory/test/test_transformed_gc.py (original)
+++ pypy/branch/inline-fastpath-malloc/pypy/rpython/memory/test/test_transformed_gc.py Tue Oct 13 23:29:10 2009
@@ -1043,6 +1043,23 @@
# * the GcArray pointer from gc.wr_to_objects_with_id
# * the GcArray pointer from gc.object_id_dict.
+ def test_adr_of_nursery(self):
+ def f():
+ # allocate a couple of objs
+ nf0 = llop.gc_adr_of_nursery_free(llmemory.Address)
+ nt0 = llop.gc_adr_of_nursery_top(llmemory.Address)
+ l0 = [a for a in range(10)]
+ l1 = [a for a in range(10)]
+ nf1 = llop.gc_adr_of_nursery_free(llmemory.Address)
+ nt1 = llop.gc_adr_of_nursery_top(llmemory.Address)
+ #assert nf1 > nf0
+ #assert nt0 > nf1
+ #assert nt0 == nt1
+ #assert nf1 != nf0
+ # er, assert something here
+ run = self.runner(f, nbargs=0)
+ res = run([])
+
class TestGenerationalNoFullCollectGC(GCTest):
# test that nursery is doing its job and that no full collection
# is needed when most allocated objects die quickly
More information about the Pypy-commit
mailing list