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

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Oct 9 10:57:30 CEST 2007


Author: cfbolz
Date: Tue Oct  9 10:57:29 2007
New Revision: 47325

Modified:
   pypy/dist/pypy/rpython/memory/gcwrapper.py
   pypy/dist/pypy/rpython/memory/test/test_gc.py
Log:
make collections possible


Modified: pypy/dist/pypy/rpython/memory/gcwrapper.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gcwrapper.py	(original)
+++ pypy/dist/pypy/rpython/memory/gcwrapper.py	Tue Oct  9 10:57:29 2007
@@ -61,6 +61,11 @@
         # XXX use write_barrier - but we need the address of the GcStruct
         array[index] = newitem
 
+    # XXX do we need a barrier for setinteriorfield too?
+
+    def collect(self):
+        self.gc.collect()
+
     # ____________________________________________________________
 
 

Modified: pypy/dist/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_gc.py	(original)
+++ pypy/dist/pypy/rpython/memory/test/test_gc.py	Tue Oct  9 10:57:29 2007
@@ -4,6 +4,9 @@
 #from pypy.rpython.memory.support import INT_SIZE
 from pypy.rpython.memory import gcwrapper
 from pypy.rpython.test.test_llinterp import get_interpreter
+from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem.lloperation import llop
+from pypy.rlib.objectmodel import we_are_translated
 
 
 def stdout_ignore_ll_functions(msg):
@@ -82,6 +85,24 @@
         assert res == concat(100)
         #assert simulator.current_size - curr < 16000 * INT_SIZE / 4
 
+
+    def test_collect(self):
+        #curr = simulator.current_size
+        def concat(j):
+            lst = []
+            for i in range(j):
+                lst.append(str(i))
+            result = len("".join(lst))
+            if we_are_translated():
+                # can't call llop.gc__collect directly
+                llop.gc__collect(lltype.Void)
+            return result
+        res = self.interpret(concat, [100])
+        assert res == concat(100)
+        #assert simulator.current_size - curr < 16000 * INT_SIZE / 4
+
+
+
 class TestMarkSweepGC(GCTest):
     from pypy.rpython.memory.gc import MarkSweepGC as GCClass
 



More information about the Pypy-commit mailing list