[pypy-svn] r77176 - in pypy/trunk/pypy: config doc/discussion rlib rpython/lltypesystem rpython/memory rpython/memory/gc rpython/memory/gc/test rpython/memory/test translator/c translator/c/test

arigo at codespeak.net arigo at codespeak.net
Sat Sep 18 16:35:10 CEST 2010


Author: arigo
Date: Sat Sep 18 16:35:08 2010
New Revision: 77176

Added:
   pypy/trunk/pypy/rpython/memory/gc/minimark.py
      - copied unchanged from r77175, pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimark.py
   pypy/trunk/pypy/rpython/memory/gc/minimarkpage.py
      - copied unchanged from r77175, pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimarkpage.py
   pypy/trunk/pypy/rpython/memory/gc/test/test_minimark.py
      - copied unchanged from r77175, pypy/branch/gen2-gc/pypy/rpython/memory/gc/test/test_minimark.py
   pypy/trunk/pypy/rpython/memory/gc/test/test_minimarkpage.py
      - copied unchanged from r77175, pypy/branch/gen2-gc/pypy/rpython/memory/gc/test/test_minimarkpage.py
Modified:
   pypy/trunk/pypy/config/translationoption.py
   pypy/trunk/pypy/doc/discussion/finalizer-order.txt
   pypy/trunk/pypy/rlib/rstring.py
   pypy/trunk/pypy/rpython/lltypesystem/llarena.py
   pypy/trunk/pypy/rpython/memory/gc/base.py
   pypy/trunk/pypy/rpython/memory/gc/generation.py
   pypy/trunk/pypy/rpython/memory/gc/test/test_direct.py
   pypy/trunk/pypy/rpython/memory/lltypelayout.py
   pypy/trunk/pypy/rpython/memory/support.py
   pypy/trunk/pypy/rpython/memory/test/test_gc.py
   pypy/trunk/pypy/rpython/memory/test/test_support.py
   pypy/trunk/pypy/rpython/memory/test/test_transformed_gc.py
   pypy/trunk/pypy/translator/c/funcgen.py
   pypy/trunk/pypy/translator/c/test/test_newgc.py
Log:
Merge the branch/gen2-gc containing the minimark GC.
(Not used by default so far.)


Modified: pypy/trunk/pypy/config/translationoption.py
==============================================================================
--- pypy/trunk/pypy/config/translationoption.py	(original)
+++ pypy/trunk/pypy/config/translationoption.py	Sat Sep 18 16:35:08 2010
@@ -52,7 +52,7 @@
     # gc
     ChoiceOption("gc", "Garbage Collection Strategy",
                  ["boehm", "ref", "marksweep", "semispace", "statistics",
-                  "generation", "hybrid", "markcompact", "none"],
+                  "generation", "hybrid", "markcompact", "minimark", "none"],
                   "ref", requires={
                      "ref": [("translation.rweakref", False), # XXX
                              ("translation.gctransformer", "ref")],
@@ -65,6 +65,7 @@
                      "hybrid": [("translation.gctransformer", "framework")],
                      "boehm": [("translation.gctransformer", "boehm")],
                      "markcompact": [("translation.gctransformer", "framework")],
+                     "minimark": [("translation.gctransformer", "framework")],
                      },
                   cmdline="--gc"),
     ChoiceOption("gctransformer", "GC transformer that is used - internal",

Modified: pypy/trunk/pypy/doc/discussion/finalizer-order.txt
==============================================================================
--- pypy/trunk/pypy/doc/discussion/finalizer-order.txt	(original)
+++ pypy/trunk/pypy/doc/discussion/finalizer-order.txt	Sat Sep 18 16:35:08 2010
@@ -133,8 +133,8 @@
 that doesn't change the state of an object, we don't follow its children
 recursively.
 
-In practice we can encode the 4 states with a single extra bit in the
-header:
+In practice, in the SemiSpace, Generation and Hybrid GCs, we can encode
+the 4 states with a single extra bit in the header:
 
       =====  =============  ========  ====================
       state  is_forwarded?  bit set?  bit set in the copy?
@@ -150,3 +150,17 @@
 bit in the copy at the end, to clean up before the next collection
 (which means recursively bumping the state from 2 to 3 in the final
 loop).
+
+In the MiniMark GC, the objects don't move (apart from when they are
+copied out of the nursery), but we use the flag GCFLAG_VISITED to mark
+objects that survive, so we can also have a single extra bit for
+finalizers:
+
+      =====  ==============  ============================
+      state  GCFLAG_VISITED  GCFLAG_FINALIZATION_ORDERING
+      =====  ==============  ============================
+        0        no              no
+        1        no              yes
+        2        yes             yes
+        3        yes             no
+      =====  =============   ============================

Modified: pypy/trunk/pypy/rlib/rstring.py
==============================================================================
--- pypy/trunk/pypy/rlib/rstring.py	(original)
+++ pypy/trunk/pypy/rlib/rstring.py	Sat Sep 18 16:35:08 2010
@@ -46,7 +46,9 @@
 
 # -------------- public API ---------------------------------
 
-INIT_SIZE = 100 # XXX tweak
+# the following number is the maximum size of an RPython unicode
+# string that goes into the nursery of the minimark GC.
+INIT_SIZE = 56
 
 class AbstractStringBuilder(object):
     def __init__(self, init_size=INIT_SIZE):

Modified: pypy/trunk/pypy/rpython/lltypesystem/llarena.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/llarena.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/llarena.py	Sat Sep 18 16:35:08 2010
@@ -16,8 +16,11 @@
 class Arena(object):
     object_arena_location = {}     # {container: (arena, offset)}
     old_object_arena_location = weakref.WeakKeyDictionary()
+    _count_arenas = 0
 
     def __init__(self, nbytes, zero):
+        Arena._count_arenas += 1
+        self._arena_index = Arena._count_arenas
         self.nbytes = nbytes
         self.usagemap = array.array('c')
         self.objectptrs = {}        # {offset: ptr-to-container}
@@ -25,6 +28,9 @@
         self.freed = False
         self.reset(zero)
 
+    def __repr__(self):
+        return '<Arena #%d [%d bytes]>' % (self._arena_index, self.nbytes)
+
     def reset(self, zero, start=0, size=None):
         self.check()
         if size is None:
@@ -297,6 +303,7 @@
     assert isinstance(arena_addr, fakearenaaddress)
     assert arena_addr.offset == 0
     arena_addr.arena.reset(False)
+    assert not arena_addr.arena.objectptrs
     arena_addr.arena.freed = True
 
 def arena_reset(arena_addr, size, zero):
@@ -357,6 +364,11 @@
     # This only works with linux's madvise(), which is really not a memory
     # usage hint but a real command.  It guarantees that after MADV_DONTNEED
     # the pages are cleared again.
+
+    # Note that the trick of the general 'posix' section below, i.e.
+    # reading /dev/zero, does not seem to have the correct effect of
+    # lazily-allocating pages on all Linux systems.
+
     from pypy.rpython.tool import rffi_platform
     from pypy.translator.tool.cbuild import ExternalCompilationInfo
     _eci = ExternalCompilationInfo(includes=['sys/mman.h'])

Modified: pypy/trunk/pypy/rpython/memory/gc/base.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gc/base.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gc/base.py	Sat Sep 18 16:35:08 2010
@@ -5,6 +5,7 @@
 from pypy.rpython.memory.support import get_address_stack, get_address_deque
 from pypy.rpython.memory.support import AddressDict
 from pypy.rpython.lltypesystem.llmemory import NULL, raw_malloc_usage
+from pypy.rlib.rarithmetic import r_uint
 
 TYPEID_MAP = lltype.GcStruct('TYPEID_MAP', ('count', lltype.Signed),
                              ('size', lltype.Signed),
@@ -151,7 +152,7 @@
         return False
 
     def set_max_heap_size(self, size):
-        pass
+        raise NotImplementedError
 
     def x_swap_pool(self, newpool):
         return newpool
@@ -345,6 +346,7 @@
                "generation": "generation.GenerationGC",
                "hybrid": "hybrid.HybridGC",
                "markcompact" : "markcompact.MarkCompactGC",
+               "minimark" : "minimark.MiniMarkGC",
                }
     try:
         modulename, classname = classes[config.translation.gc].split('.')
@@ -356,10 +358,12 @@
     GCClass = getattr(module, classname)
     return GCClass, GCClass.TRANSLATION_PARAMS
 
-def read_from_env(varname):
+def _read_float_and_factor_from_env(varname):
     import os
     value = os.environ.get(varname)
     if value:
+        if len(value) > 1 and value[-1] in 'bB':
+            value = value[:-1]
         realvalue = value[:-1]
         if value[-1] in 'kK':
             factor = 1024
@@ -371,7 +375,21 @@
             factor = 1
             realvalue = value
         try:
-            return int(float(realvalue) * factor)
+            return (float(realvalue), factor)
         except ValueError:
             pass
-    return -1
+    return (0.0, 0)
+
+def read_from_env(varname):
+    value, factor = _read_float_and_factor_from_env(varname)
+    return int(value * factor)
+
+def read_uint_from_env(varname):
+    value, factor = _read_float_and_factor_from_env(varname)
+    return r_uint(value * factor)
+
+def read_float_from_env(varname):
+    value, factor = _read_float_and_factor_from_env(varname)
+    if factor != 1:
+        return 0.0
+    return value

Modified: pypy/trunk/pypy/rpython/memory/gc/generation.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gc/generation.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gc/generation.py	Sat Sep 18 16:35:08 2010
@@ -449,7 +449,7 @@
 
     # for the JIT: a minimal description of the write_barrier() method
     # (the JIT assumes it is of the shape
-    #  "if newvalue.int0 & JIT_WB_IF_FLAG: remember_young_pointer()")
+    #  "if addr_struct.int0 & JIT_WB_IF_FLAG: remember_young_pointer()")
     JIT_WB_IF_FLAG = GCFLAG_NO_YOUNG_PTRS
 
     def write_barrier(self, newvalue, addr_struct):

Modified: pypy/trunk/pypy/rpython/memory/gc/test/test_direct.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gc/test/test_direct.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gc/test/test_direct.py	Sat Sep 18 16:35:08 2010
@@ -326,6 +326,27 @@
         self.gc.collect()
         assert hash == self.gc.identityhash(self.stackroots[-1])
         self.stackroots.pop()
+        # (6) ask for the hash of varsized objects, larger and larger
+        for i in range(10):
+            self.gc.collect()
+            p = self.malloc(VAR, i)
+            self.stackroots.append(p)
+            hash = self.gc.identityhash(p)
+            self.gc.collect()
+            assert hash == self.gc.identityhash(self.stackroots[-1])
+            self.stackroots.pop()
+
+    def test_memory_alignment(self):
+        A1 = lltype.GcArray(lltype.Char)
+        for i in range(50):
+            p1 = self.malloc(A1, i)
+            if i:
+                p1[i-1] = chr(i)
+            self.stackroots.append(p1)
+        self.gc.collect()
+        for i in range(1, 50):
+            p = self.stackroots[-50+i]
+            assert p[i-1] == chr(i)
 
 class TestSemiSpaceGC(DirectGCTest):
     from pypy.rpython.memory.gc.semispace import SemiSpaceGC as GCClass
@@ -456,3 +477,13 @@
     def test_varsized_from_prebuilt_gc(self):
         DirectGCTest.test_varsized_from_prebuilt_gc(self)
     test_varsized_from_prebuilt_gc.GC_PARAMS = {'space_size': 3 * 1024 * WORD}
+
+
+class TestMiniMarkGCSimple(DirectGCTest):
+    from pypy.rpython.memory.gc.minimark import MiniMarkGC as GCClass
+    from pypy.rpython.memory.gc.minimark import SimpleArenaCollection
+    # test the GC itself, providing a simple class for ArenaCollection
+    GC_PARAMS = {'ArenaCollectionClass': SimpleArenaCollection}
+
+class TestMiniMarkGCFull(DirectGCTest):
+    from pypy.rpython.memory.gc.minimark import MiniMarkGC as GCClass

Modified: pypy/trunk/pypy/rpython/memory/lltypelayout.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/lltypelayout.py	(original)
+++ pypy/trunk/pypy/rpython/memory/lltypelayout.py	Sat Sep 18 16:35:08 2010
@@ -7,7 +7,7 @@
 primitive_to_fmt = {lltype.Signed:          "l",
                     lltype.Unsigned:        "L",
                     lltype.Char:            "c",
-                    lltype.UniChar:         "H",     # maybe
+                    lltype.UniChar:         "i",     # 4 bytes
                     lltype.Bool:            "B",
                     lltype.Float:           "d",
                     llmemory.Address:       "P",

Modified: pypy/trunk/pypy/rpython/memory/support.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/support.py	(original)
+++ pypy/trunk/pypy/rpython/memory/support.py	Sat Sep 18 16:35:08 2010
@@ -216,6 +216,24 @@
             self.index_in_oldest = index + 1
             return result
 
+        def foreach(self, callback, arg):
+            """Invoke 'callback(address, arg)' for all addresses in the deque.
+            Typically, 'callback' is a bound method and 'arg' can be None.
+            """
+            chunk = self.oldest_chunk
+            index = self.index_in_oldest
+            while chunk is not self.newest_chunk:
+                while index < chunk_size:
+                    callback(chunk.items[index], arg)
+                    index += 1
+                chunk = chunk.next
+                index = 0
+            limit = self.index_in_newest
+            while index < limit:
+                callback(chunk.items[index], arg)
+                index += 1
+        foreach._annspecialcase_ = 'specialize:arg(1)'
+
         def delete(self):
             cur = self.oldest_chunk
             while cur:

Modified: pypy/trunk/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/test/test_gc.py	(original)
+++ pypy/trunk/pypy/rpython/memory/test/test_gc.py	Sat Sep 18 16:35:08 2010
@@ -26,8 +26,9 @@
 class GCTest(object):
     GC_PARAMS = {}
     GC_CAN_MOVE = False
-    GC_CANNOT_MALLOC_NONMOVABLE = False
+    GC_CAN_MALLOC_NONMOVABLE = True
     GC_CAN_SHRINK_ARRAY = False
+    GC_CAN_SHRINK_BIG_ARRAY = False
 
     def setup_class(cls):
         cls._saved_logstate = py.log._getstate()
@@ -451,10 +452,10 @@
             a = rgc.malloc_nonmovable(TP, 3)
             if a:
                 assert not rgc.can_move(a)
-                return 0
-            return 1
+                return 1
+            return 0
 
-        assert self.interpret(func, []) == int(self.GC_CANNOT_MALLOC_NONMOVABLE)
+        assert self.interpret(func, []) == int(self.GC_CAN_MALLOC_NONMOVABLE)
 
     def test_malloc_nonmovable_fixsize(self):
         S = lltype.GcStruct('S', ('x', lltype.Float))
@@ -465,37 +466,36 @@
                 rgc.collect()
                 if a:
                     assert not rgc.can_move(a)
-                    return 0
-                return 1
+                    return 1
+                return 0
             except Exception, e:
                 return 2
 
-        assert self.interpret(func, []) == int(self.GC_CANNOT_MALLOC_NONMOVABLE)
+        assert self.interpret(func, []) == int(self.GC_CAN_MALLOC_NONMOVABLE)
 
     def test_shrink_array(self):
         from pypy.rpython.lltypesystem.rstr import STR
-        GC_CAN_SHRINK_ARRAY = self.GC_CAN_SHRINK_ARRAY
 
-        def f(n, m):
+        def f(n, m, gc_can_shrink_array):
             ptr = lltype.malloc(STR, n)
             ptr.hash = 0x62
             ptr.chars[0] = 'A'
             ptr.chars[1] = 'B'
             ptr.chars[2] = 'C'
             ptr2 = rgc.ll_shrink_array(ptr, 2)
-            assert (ptr == ptr2) == GC_CAN_SHRINK_ARRAY
+            assert (ptr == ptr2) == gc_can_shrink_array
             rgc.collect()
             return ( ord(ptr2.chars[0])       +
                     (ord(ptr2.chars[1]) << 8) +
                     (len(ptr2.chars)   << 16) +
                     (ptr2.hash         << 24))
 
-        assert self.interpret(f, [3, 0]) == 0x62024241
-        # don't test with larger numbers of top of the Hybrid GC, because
-        # the default settings make it a too-large varsized object that
-        # gets allocated outside the semispace
-        if not isinstance(self, TestHybridGC):
-            assert self.interpret(f, [12, 0]) == 0x62024241
+        flag = self.GC_CAN_SHRINK_ARRAY
+        assert self.interpret(f, [3, 0, flag]) == 0x62024241
+        # with larger numbers, it gets allocated outside the semispace
+        # with some GCs.
+        flag = self.GC_CAN_SHRINK_BIG_ARRAY
+        assert self.interpret(f, [12, 0, flag]) == 0x62024241
 
     def test_tagged_simple(self):
         from pypy.rlib.objectmodel import UnboxedValue
@@ -568,7 +568,7 @@
         assert res == 111
 
     def test_writebarrier_before_copy(self):
-        S = lltype.GcStruct('S')
+        S = lltype.GcStruct('S', ('x', lltype.Char))
         TP = lltype.GcArray(lltype.Ptr(S))
         def fn():
             l = lltype.malloc(TP, 100)
@@ -628,8 +628,9 @@
 class TestSemiSpaceGC(GCTest, snippet.SemiSpaceGCTests):
     from pypy.rpython.memory.gc.semispace import SemiSpaceGC as GCClass
     GC_CAN_MOVE = True
-    GC_CANNOT_MALLOC_NONMOVABLE = True
+    GC_CAN_MALLOC_NONMOVABLE = False
     GC_CAN_SHRINK_ARRAY = True
+    GC_CAN_SHRINK_BIG_ARRAY = True
 
 class TestGrowingSemiSpaceGC(TestSemiSpaceGC):
     GC_PARAMS = {'space_size': 16*WORD}
@@ -641,16 +642,15 @@
     from pypy.rpython.memory.gc.markcompact import MarkCompactGC as GCClass
     GC_PARAMS = {'space_size': 65536+16384}
     GC_CAN_SHRINK_ARRAY = False
+    GC_CAN_SHRINK_BIG_ARRAY = False
 
     def test_finalizer_order(self):
         py.test.skip("Not implemented yet")
-    def test_writebarrier_before_copy(self):
-        py.test.skip("Not relevant, and crashes because llarena does not "
-                     "support empty GcStructs")
 
 class TestHybridGC(TestGenerationalGC):
     from pypy.rpython.memory.gc.hybrid import HybridGC as GCClass
-    GC_CANNOT_MALLOC_NONMOVABLE = False
+    GC_CAN_MALLOC_NONMOVABLE = True
+    GC_CAN_SHRINK_BIG_ARRAY = False
 
     def test_ref_from_rawmalloced_to_regular(self):
         import gc
@@ -720,7 +720,7 @@
     from pypy.rpython.memory.gc.hybrid import HybridGC as GCClass
     GC_CAN_MOVE = False # with this size of heap, stuff gets allocated
                         # in 3rd gen.
-    GC_CANNOT_MALLOC_NONMOVABLE = False
+    GC_CAN_MALLOC_NONMOVABLE = True
     GC_PARAMS = {'space_size': 48*WORD,
                  'min_nursery_size': 12*WORD,
                  'nursery_size': 12*WORD,
@@ -764,3 +764,9 @@
 
     def test_malloc_nonmovable_fixsize(self):
         py.test.skip("Not supported")
+
+
+class TestMiniMarkGC(TestSemiSpaceGC):
+    from pypy.rpython.memory.gc.minimark import MiniMarkGC as GCClass
+    GC_CAN_SHRINK_BIG_ARRAY = False
+    GC_CAN_MALLOC_NONMOVABLE = True

Modified: pypy/trunk/pypy/rpython/memory/test/test_support.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/test/test_support.py	(original)
+++ pypy/trunk/pypy/rpython/memory/test/test_support.py	Sat Sep 18 16:35:08 2010
@@ -113,6 +113,27 @@
                 deque.append(x)
                 expected.append(x)
 
+    def test_foreach(self):
+        AddressDeque = get_address_deque(10)
+        ll = AddressDeque()
+        for num_entries in range(30, -1, -1):
+            addrs = [raw_malloc(llmemory.sizeof(lltype.Signed))
+                     for i in range(num_entries)]
+            for a in addrs:
+                ll.append(a)
+
+            seen = []
+            def callback(addr, fortytwo):
+                assert fortytwo == 42
+                seen.append(addr)
+
+            ll.foreach(callback, 42)
+            assert seen == addrs
+            for a in addrs:
+                b = ll.popleft()
+                assert a == b
+            assert not ll.non_empty()
+
 
 def test_stack_annotate():
     AddressStack = get_address_stack(60)

Modified: pypy/trunk/pypy/rpython/memory/test/test_transformed_gc.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/test/test_transformed_gc.py	(original)
+++ pypy/trunk/pypy/rpython/memory/test/test_transformed_gc.py	Sat Sep 18 16:35:08 2010
@@ -47,7 +47,7 @@
     gcpolicy = None
     stacklessgc = False
     GC_CAN_MOVE = False
-    GC_CANNOT_MALLOC_NONMOVABLE = False
+    GC_CAN_MALLOC_NONMOVABLE = True
     taggedpointers = False
     
     def setup_class(cls):
@@ -602,8 +602,8 @@
             rgc.collect()
             if a:
                 assert not rgc.can_move(a)
-                return 0
-            return 1
+                return 1
+            return 0
             #except Exception, e:
             #    return 2
 
@@ -611,7 +611,7 @@
     
     def test_malloc_nonmovable(self):
         run = self.runner("malloc_nonmovable")
-        assert int(self.GC_CANNOT_MALLOC_NONMOVABLE) == run([])
+        assert int(self.GC_CAN_MALLOC_NONMOVABLE) == run([])
 
     def define_malloc_nonmovable_fixsize(cls):
         S = lltype.GcStruct('S', ('x', lltype.Float))
@@ -622,8 +622,8 @@
                 rgc.collect()
                 if a:
                     assert not rgc.can_move(a)
-                    return 0
-                return 1
+                    return 1
+                return 0
             except Exception, e:
                 return 2
 
@@ -631,7 +631,7 @@
     
     def test_malloc_nonmovable_fixsize(self):
         run = self.runner("malloc_nonmovable_fixsize")
-        assert run([]) == int(self.GC_CANNOT_MALLOC_NONMOVABLE)
+        assert run([]) == int(self.GC_CAN_MALLOC_NONMOVABLE)
 
     def define_shrink_array(cls):
         from pypy.rpython.lltypesystem.rstr import STR
@@ -680,7 +680,8 @@
 
 class GenericMovingGCTests(GenericGCTests):
     GC_CAN_MOVE = True
-    GC_CANNOT_MALLOC_NONMOVABLE = True
+    GC_CAN_MALLOC_NONMOVABLE = False
+    GC_CAN_TEST_ID = False
 
     def define_many_ids(cls):
         class A(object):
@@ -710,7 +711,8 @@
         return f
     
     def test_many_ids(self):
-        py.test.skip("fails for bad reasons in lltype.py :-(")
+        if not self.GC_CAN_TEST_ID:
+            py.test.skip("fails for bad reasons in lltype.py :-(")
         run = self.runner("many_ids")
         run([])
 
@@ -856,7 +858,7 @@
         #     (and give fixedsize)
 
     def define_writebarrier_before_copy(cls):
-        S = lltype.GcStruct('S')
+        S = lltype.GcStruct('S', ('x', lltype.Char))
         TP = lltype.GcArray(lltype.Ptr(S))
         def fn():
             l = lltype.malloc(TP, 100)
@@ -1144,10 +1146,6 @@
             GC_PARAMS = {'space_size': 4096*WORD}
             root_stack_depth = 200
 
-    def test_writebarrier_before_copy(self):
-        py.test.skip("Not relevant, and crashes because llarena does not "
-                     "support empty GcStructs")
-
 class TestGenerationGC(GenericMovingGCTests):
     gcname = "generation"
     GC_CAN_SHRINK_ARRAY = True
@@ -1379,7 +1377,7 @@
 
 class TestHybridGC(TestGenerationGC):
     gcname = "hybrid"
-    GC_CANNOT_MALLOC_NONMOVABLE = False
+    GC_CAN_MALLOC_NONMOVABLE = True
 
     class gcpolicy(gc.FrameworkGcPolicy):
         class transformerclass(framework.FrameworkGCTransformer):
@@ -1444,6 +1442,21 @@
     def test_malloc_nonmovable_fixsize(self):
         py.test.skip("not supported")
 
+
+class TestMiniMarkGC(TestHybridGC):
+    gcname = "minimark"
+    GC_CAN_TEST_ID = True
+
+    class gcpolicy(gc.FrameworkGcPolicy):
+        class transformerclass(framework.FrameworkGCTransformer):
+            from pypy.rpython.memory.gc.minimark import MiniMarkGC as GCClass
+            GC_PARAMS = {'nursery_size': 32*WORD,
+                         'page_size': 16*WORD,
+                         'arena_size': 64*WORD,
+                         'small_request_threshold': 5*WORD,
+                         }
+            root_stack_depth = 200
+
 # ________________________________________________________________
 # tagged pointers
 

Modified: pypy/trunk/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/trunk/pypy/translator/c/funcgen.py	(original)
+++ pypy/trunk/pypy/translator/c/funcgen.py	Sat Sep 18 16:35:08 2010
@@ -733,6 +733,8 @@
                 continue
             elif T == Signed:
                 format.append('%ld')
+            elif T == Unsigned:
+                format.append('%lu')
             elif T == Float:
                 format.append('%f')
             elif isinstance(T, Ptr) or T == Address:

Modified: pypy/trunk/pypy/translator/c/test/test_newgc.py
==============================================================================
--- pypy/trunk/pypy/translator/c/test/test_newgc.py	(original)
+++ pypy/trunk/pypy/translator/c/test/test_newgc.py	Sat Sep 18 16:35:08 2010
@@ -19,7 +19,7 @@
     removetypeptr = False
     taggedpointers = False
     GC_CAN_MOVE = False
-    GC_CANNOT_MALLOC_NONMOVABLE = False
+    GC_CAN_MALLOC_NONMOVABLE = True
     GC_CAN_SHRINK_ARRAY = False
 
     _isolated_func = None
@@ -112,6 +112,7 @@
     def teardown_class(cls):
         if hasattr(cls.c_allfuncs, 'close_isolate'):
             cls.c_allfuncs.close_isolate()
+            cls.c_allfuncs = None
 
     def run(self, name, *args):
         if not args:
@@ -691,8 +692,8 @@
                 rgc.collect()
                 if a:
                     assert not rgc.can_move(a)
-                    return 0
-                return 1
+                    return 1
+                return 0
             except Exception, e:
                 return 2
 
@@ -700,7 +701,7 @@
 
     def test_malloc_nonmovable(self):
         res = self.run('malloc_nonmovable')
-        assert res == self.GC_CANNOT_MALLOC_NONMOVABLE
+        assert res == self.GC_CAN_MALLOC_NONMOVABLE
 
     def define_resizable_buffer(cls):
         from pypy.rpython.lltypesystem.rstr import STR
@@ -1093,7 +1094,7 @@
     gcpolicy = "semispace"
     should_be_moving = True
     GC_CAN_MOVE = True
-    GC_CANNOT_MALLOC_NONMOVABLE = True
+    GC_CAN_MALLOC_NONMOVABLE = False
     GC_CAN_SHRINK_ARRAY = True
 
     # for snippets
@@ -1252,7 +1253,7 @@
 class TestHybridGC(TestGenerationalGC):
     gcpolicy = "hybrid"
     should_be_moving = True
-    GC_CANNOT_MALLOC_NONMOVABLE = False
+    GC_CAN_MALLOC_NONMOVABLE = True
 
     def test_gc_set_max_heap_size(self):
         py.test.skip("not implemented")
@@ -1323,6 +1324,15 @@
         res = self.run("adding_a_hash")
         assert res == 0
 
+class TestMiniMarkGC(TestSemiSpaceGC):
+    gcpolicy = "minimark"
+    should_be_moving = True
+    GC_CAN_MALLOC_NONMOVABLE = True
+    GC_CAN_SHRINK_ARRAY = True
+
+    def test_gc_heap_stats(self):
+        py.test.skip("not implemented")
+
 # ____________________________________________________________________
 
 class TaggedPointersTest(object):
@@ -1377,3 +1387,6 @@
 
 class TestMarkCompactGCMostCompact(TaggedPointersTest, TestMarkCompactGC):
     removetypeptr = True
+
+class TestMiniMarkGCMostCompact(TaggedPointersTest, TestMiniMarkGC):
+    removetypeptr = True



More information about the Pypy-commit mailing list