[pypy-svn] r27241 - in pypy/dist/pypy/rpython/memory: . test

pedronis at codespeak.net pedronis at codespeak.net
Mon May 15 17:48:32 CEST 2006


Author: pedronis
Date: Mon May 15 17:48:30 2006
New Revision: 27241

Added:
   pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py
      - copied, changed from r27234, pypy/dist/pypy/rpython/memory/test/test_gc.py
Modified:
   pypy/dist/pypy/rpython/memory/gc.py
   pypy/dist/pypy/rpython/memory/gctransform.py
   pypy/dist/pypy/rpython/memory/lltypelayout.py
Log:
start of refactoring to allow gcs to be tested through the transformer on top of llinterp. Collection
still is crashing because of misconstructed fakeaddresses.

half-way to making it easier to swap in gcs when using the Framework policy and transformer.

fix in lltypelayout.sizeof

added statics functionality support at least in mark-and-sweep gc.



Modified: pypy/dist/pypy/rpython/memory/gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc.py	(original)
+++ pypy/dist/pypy/rpython/memory/gc.py	Mon May 15 17:48:30 2006
@@ -245,6 +245,11 @@
         # the strings!  so it must be at the end
         os.write(2, "freed %s bytes. the heap is now %s bytes.\n" % (freed_size, curr_heap_size))
 
+    STATISTICS_NUMBERS = 2
+
+    def statistics(self):
+        return self.heap_size, self.bytes_malloced
+
     def size_gc_header(self, typeid=0):
         return MarkSweepGC._size_gc_header
 

Modified: pypy/dist/pypy/rpython/memory/gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform.py	Mon May 15 17:48:30 2006
@@ -731,14 +731,16 @@
     use_stackless = False
     extra_static_slots = 0
 
+    from pypy.rpython.memory.gc import MarkSweepGC as GCClass
+    GC_PARAMS = {'start_heap_size': 8*1024*1024 # XXX adjust
+                 }
+    
     def __init__(self, translator):
         from pypy.rpython.memory.support import get_address_linked_list
         super(FrameworkGCTransformer, self).__init__(translator, inline=True)
         AddressLinkedList = get_address_linked_list()
+        GCClass = self.GCClass
         class GCData(object):
-            from pypy.rpython.memory.gc import MarkSweepGC as GCClass
-            startheapsize = 8*1024*1024 # XXX adjust
-
             # types of the GC information tables
             OFFSETS_TO_GC_PTR = lltype.Array(lltype.Signed)
             TYPE_INFO = lltype.Struct("type_info",
@@ -796,7 +798,7 @@
         sizeofaddr = llmemory.sizeof(llmemory.Address)
 
         StackRootIterator = self.build_stack_root_iterator()
-        gcdata.gc = GCData.GCClass(AddressLinkedList, GCData.startheapsize, StackRootIterator)
+        gcdata.gc = GCClass(AddressLinkedList, get_roots=StackRootIterator, **self.GC_PARAMS)
 
         def frameworkgc_setup():
             # run-time initialization code
@@ -854,26 +856,31 @@
                                       annmodel.s_None,
                                       inline = True)
 
-        classdef = bk.getuniqueclassdef(GCData.GCClass)
+        classdef = bk.getuniqueclassdef(GCClass)
         s_gcdata = annmodel.SomeInstance(classdef)
         self.malloc_fixedsize_ptr = getfn(
-            GCData.GCClass.malloc_fixedsize.im_func,
+            GCClass.malloc_fixedsize.im_func,
             [s_gcdata, annmodel.SomeInteger(nonneg=True),
              annmodel.SomeInteger(nonneg=True),
              annmodel.SomeBool()], annmodel.SomeAddress(),
             inline = True)
         self.malloc_varsize_ptr = getfn(
-            GCData.GCClass.malloc_varsize.im_func,
+            GCClass.malloc_varsize.im_func,
             [s_gcdata] + [annmodel.SomeInteger(nonneg=True) for i in range(5)]
             + [annmodel.SomeBool()], annmodel.SomeAddress())
-        self.collect_ptr = getfn(GCData.GCClass.collect.im_func,
+        self.collect_ptr = getfn(GCClass.collect.im_func,
             [s_gcdata], annmodel.s_None)
+
+        statics_s = (annmodel.SomeInteger(),)*GCClass.STATISTICS_NUMBERS
+        self.statistics_ptr = getfn(GCClass.statistics.im_func,
+                                    [s_gcdata], annmodel.SomeTuple(statics_s))
+                                   
         annhelper.finish()   # at this point, annotate all mix-level helpers
 
         self.collect_analyzer = CollectAnalyzer(self.translator)
         self.collect_analyzer.analyze_all()
 
-        s_gc = self.translator.annotator.bookkeeper.valueoftype(self.gcdata.GCClass)
+        s_gc = self.translator.annotator.bookkeeper.valueoftype(GCClass)
         r_gc = self.translator.rtyper.getrepr(s_gc)
         self.c_const_gc = rmodel.inputconst(r_gc, self.gcdata.gc)
 

Modified: pypy/dist/pypy/rpython/memory/lltypelayout.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/lltypelayout.py	(original)
+++ pypy/dist/pypy/rpython/memory/lltypelayout.py	Mon May 15 17:48:30 2006
@@ -75,6 +75,8 @@
         return 0
     elif isinstance(TYPE, lltype.PyObjectType):
         return 0
+    elif isinstance(TYPE, lltype.Ptr):
+        return 0
     else:
         assert 0, "not yet implemented"
 



More information about the Pypy-commit mailing list