[pypy-svn] r70970 - in pypy/branch/gc-huge-list/pypy: rlib rlib/test rpython/lltypesystem rpython/memory/gc

fijal at codespeak.net fijal at codespeak.net
Fri Jan 29 15:07:31 CET 2010


Author: fijal
Date: Fri Jan 29 15:07:31 2010
New Revision: 70970

Modified:
   pypy/branch/gc-huge-list/pypy/rlib/rgc.py
   pypy/branch/gc-huge-list/pypy/rlib/test/test_rgc.py
   pypy/branch/gc-huge-list/pypy/rpython/lltypesystem/opimpl.py
   pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py
Log:
Merge changes from trunk


Modified: pypy/branch/gc-huge-list/pypy/rlib/rgc.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rlib/rgc.py	(original)
+++ pypy/branch/gc-huge-list/pypy/rlib/rgc.py	Fri Jan 29 15:07:31 2010
@@ -258,7 +258,7 @@
     if isinstance(TP.OF, lltype.Ptr) and TP.OF.TO._gckind == 'gc':
         # perform a write barrier that copies necessary flags from
         # source to dest
-        if not llop.gc_writebarrier_before_copy(lltype.Void, source, dest,
+        if not llop.gc_writebarrier_before_copy(lltype.Bool, source, dest,
                                                 source_start, dest_start,
                                                 length):
             # if the write barrier is not supported, copy by hand

Modified: pypy/branch/gc-huge-list/pypy/rlib/test/test_rgc.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rlib/test/test_rgc.py	(original)
+++ pypy/branch/gc-huge-list/pypy/rlib/test/test_rgc.py	Fri Jan 29 15:07:31 2010
@@ -1,5 +1,5 @@
 from pypy.rpython.test.test_llinterp import gengraph, interpret
-from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rlib import rgc # Force registration of gc.collect
 import gc
 import py, sys
@@ -114,6 +114,28 @@
         else:
             assert a2[i] == org2[i]
 
+def test_ll_arraycopy_5(monkeypatch):
+    S = lltype.GcStruct('S')
+    TYPE = lltype.GcArray(lltype.Ptr(S))
+    def f():
+        a1 = lltype.malloc(TYPE, 10)
+        a2 = lltype.malloc(TYPE, 6)
+        rgc.ll_arraycopy(a2, a1, 0, 1, 5)
+
+    CHK = lltype.Struct('CHK', ('called', lltype.Bool))
+    check = lltype.malloc(CHK, immortal=True)
+
+    def raw_memcopy(*args):
+        check.called = True
+
+    monkeypatch.setattr(llmemory, "raw_memcopy", raw_memcopy)
+
+    interpret(f, [])
+
+    assert check.called
+
+
+
 def test_ll_shrink_array_1():
     py.test.skip("implement ll_shrink_array for GcStructs or GcArrays that "
                  "don't have the shape of STR or UNICODE")

Modified: pypy/branch/gc-huge-list/pypy/rpython/lltypesystem/opimpl.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/lltypesystem/opimpl.py	(original)
+++ pypy/branch/gc-huge-list/pypy/rpython/lltypesystem/opimpl.py	Fri Jan 29 15:07:31 2010
@@ -398,7 +398,8 @@
     checkadr(addr2)
     return addr1 - addr2
 
-def op_gc_writebarrier_before_copy(source, dest):
+def op_gc_writebarrier_before_copy(source, dest, source_start, dest_start,
+                                   length):
     A = lltype.typeOf(source)
     assert A == lltype.typeOf(dest)
     assert isinstance(A.TO, lltype.GcArray)

Modified: pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py	(original)
+++ pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py	Fri Jan 29 15:07:31 2010
@@ -244,11 +244,7 @@
     def malloc_varsize_marknsweep(self, totalsize, large_with_gcptrs):
         # In order to free the large objects from time to time, we
         # arbitrarily force a full collect() if none occurs when we have
-        # allocated 'self.space_size' bytes of large objects.
-        # XXX we should probably track the total raw_malloc'ed size
-        # XXX and adjust sizes based on it; otherwise we risk doing
-        # XXX many many collections if the program allocates a lot
-        # XXX more than the current self.space_size.
+        # allocated self.space_size + rawmalloced bytes of large objects.
         self._check_rawsize_alloced(raw_malloc_usage(totalsize))
         if large_with_gcptrs:
             result = self.malloc_arena_with_cardmarking(totalsize)
@@ -441,13 +437,13 @@
         debug_print("| [hybrid] made nonmoving:         ",
                     self._nonmoving_copy_size, "bytes in",
                     self._nonmoving_copy_count, "objs")
+        rawmalloced_trigger = 0
         # sweep the nonmarked rawmalloced objects
         if self.is_collecting_gen3():
-            self.sweep_rawmalloced_objects(generation=3)
-        self.sweep_rawmalloced_objects(generation=2)
-        # As we just collected, it's fine to raw_malloc'ate up to space_size
-        # bytes again before we should force another collect.
-        self.large_objects_collect_trigger = self.space_size
+            rawmalloced_trigger += self.sweep_rawmalloced_objects(generation=3)
+        rawmalloced_trigger += self.sweep_rawmalloced_objects(generation=2)
+        self.large_objects_collect_trigger = (rawmalloced_trigger +
+                                              self.space_size)
         if self.is_collecting_gen3():
             self.count_semispaceonly_collects = 0
         self._initial_trigger = self.large_objects_collect_trigger
@@ -476,7 +472,7 @@
             self.last_generation_root_objects = newgen3roots
         else:
             ll_assert(False, "bogus 'generation'")
-            return
+            return 0 # to please the flowspace
 
         surviving_objects = self.AddressStack()
         # Help the flow space
@@ -503,7 +499,7 @@
             else:
                 if debug:
                     alive_count+=1
-                    alive_size+=raw_malloc_usage(self.get_size_incl_hash(obj))
+                alive_size+=raw_malloc_usage(self.get_size_incl_hash(obj))
                 if generation == 3:
                     surviving_objects.append(obj)
                 elif generation == 2:
@@ -533,6 +529,7 @@
                     "nonmoving freed:     ",
                     dead_size, "bytes in",
                     dead_count, "objs")
+        return alive_size
 
     def id(self, ptr):
         obj = llmemory.cast_ptr_to_adr(ptr)



More information about the Pypy-commit mailing list