[pypy-svn] r77419 - in pypy/trunk/pypy: config config/test jit/backend/llsupport jit/backend/llsupport/test jit/backend/x86/test jit/metainterp rpython/memory/gc rpython/memory/gc/test rpython/memory/test

arigo at codespeak.net arigo at codespeak.net
Mon Sep 27 18:37:59 CEST 2010


Author: arigo
Date: Mon Sep 27 18:37:56 2010
New Revision: 77419

Modified:
   pypy/trunk/pypy/config/test/test_pypyoption.py
   pypy/trunk/pypy/config/translationoption.py
   pypy/trunk/pypy/jit/backend/llsupport/gc.py
   pypy/trunk/pypy/jit/backend/llsupport/test/test_gc.py
   pypy/trunk/pypy/jit/backend/x86/test/test_zrpy_gc.py
   pypy/trunk/pypy/jit/backend/x86/test/test_ztranslation.py
   pypy/trunk/pypy/jit/metainterp/gc.py
   pypy/trunk/pypy/rpython/memory/gc/generation.py
   pypy/trunk/pypy/rpython/memory/gc/minimark.py
   pypy/trunk/pypy/rpython/memory/gc/minimarkpage.py
   pypy/trunk/pypy/rpython/memory/gc/test/test_minimarkpage.py
   pypy/trunk/pypy/rpython/memory/test/test_gc.py
Log:
Merge branch/minimark-jit:
    do some last fixes, notably with the JIT,
    and enable the "minimark" GC by default.


Modified: pypy/trunk/pypy/config/test/test_pypyoption.py
==============================================================================
--- pypy/trunk/pypy/config/test/test_pypyoption.py	(original)
+++ pypy/trunk/pypy/config/test/test_pypyoption.py	Mon Sep 27 18:37:56 2010
@@ -41,7 +41,7 @@
     assert not conf.translation.backendopt.none
     conf = get_pypy_config()
     set_opt_level(conf, 'mem')
-    assert conf.translation.gc == 'markcompact'
+    assert conf.translation.gcremovetypeptr
     assert not conf.translation.backendopt.none
 
 def test_set_pypy_opt_level():

Modified: pypy/trunk/pypy/config/translationoption.py
==============================================================================
--- pypy/trunk/pypy/config/translationoption.py	(original)
+++ pypy/trunk/pypy/config/translationoption.py	Mon Sep 27 18:37:56 2010
@@ -11,6 +11,8 @@
 DEFL_CLEVER_MALLOC_REMOVAL_INLINE_THRESHOLD = 32.4
 DEFL_LOW_INLINE_THRESHOLD = DEFL_INLINE_THRESHOLD / 2.0
 
+DEFL_GC = "minimark"
+
 IS_64_BITS = sys.maxint > 2147483647
 
 PLATFORMS = [
@@ -105,7 +107,7 @@
     # JIT generation: use -Ojit to enable it
     BoolOption("jit", "generate a JIT",
                default=False,
-               suggests=[("translation.gc", "hybrid"),
+               suggests=[("translation.gc", DEFL_GC),
                          ("translation.gcrootfinder", "asmgcc"),
                          ("translation.list_comprehension_operations", True)]),
     ChoiceOption("jit_backend", "choose the backend for the JIT",
@@ -337,10 +339,10 @@
     '0':    'boehm       nobackendopt',
     '1':    'boehm       lowinline',
     'size': 'boehm       lowinline     remove_asserts',
-    'mem':  'markcompact lowinline     remove_asserts    removetypeptr',
-    '2':    'hybrid      extraopts',
-    '3':    'hybrid      extraopts     remove_asserts',
-    'jit':  'hybrid      extraopts     jit',
+    'mem':  DEFL_GC + '  lowinline     remove_asserts    removetypeptr',
+    '2':    DEFL_GC + '  extraopts',
+    '3':    DEFL_GC + '  extraopts     remove_asserts',
+    'jit':  DEFL_GC + '  extraopts     jit',
     }
 
 def final_check_config(config):

Modified: pypy/trunk/pypy/jit/backend/llsupport/gc.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/llsupport/gc.py	(original)
+++ pypy/trunk/pypy/jit/backend/llsupport/gc.py	Mon Sep 27 18:37:56 2010
@@ -133,7 +133,7 @@
 
 
 # ____________________________________________________________
-# All code below is for the hybrid GC
+# All code below is for the hybrid or minimark GC
 
 
 class GcRefList:
@@ -167,7 +167,7 @@
 
     def alloc_gcref_list(self, n):
         # Important: the GRREF_LISTs allocated are *non-movable*.  This
-        # requires support in the gc (only the hybrid GC supports it so far).
+        # requires support in the gc (hybrid GC or minimark GC so far).
         if we_are_translated():
             list = rgc.malloc_nonmovable(self.GCREF_LIST, n)
             assert list, "malloc_nonmovable failed!"
@@ -350,8 +350,9 @@
         self.translator = translator
         self.llop1 = llop1
 
-        # we need the hybrid GC for GcRefList.alloc_gcref_list() to work
-        if gcdescr.config.translation.gc != 'hybrid':
+        # we need the hybrid or minimark GC for GcRefList.alloc_gcref_list()
+        # to work
+        if gcdescr.config.translation.gc not in ('hybrid', 'minimark'):
             raise NotImplementedError("--gc=%s not implemented with the JIT" %
                                       (gcdescr.config.translation.gc,))
 
@@ -382,8 +383,7 @@
         self.gcheaderbuilder = GCHeaderBuilder(self.HDRPTR.TO)
         (self.array_basesize, _, self.array_length_ofs) = \
              symbolic.get_array_token(lltype.GcArray(lltype.Signed), True)
-        min_ns = self.GCClass.TRANSLATION_PARAMS['min_nursery_size']
-        self.max_size_of_young_obj = self.GCClass.get_young_fixedsize(min_ns)
+        self.max_size_of_young_obj = self.GCClass.JIT_max_size_of_young_obj()
 
         # make a malloc function, with three arguments
         def malloc_basic(size, tid):

Modified: pypy/trunk/pypy/jit/backend/llsupport/test/test_gc.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/llsupport/test/test_gc.py	(original)
+++ pypy/trunk/pypy/jit/backend/llsupport/test/test_gc.py	Mon Sep 27 18:37:56 2010
@@ -149,11 +149,12 @@
 
 
 class TestFramework:
+    gc = 'hybrid'
 
     def setup_method(self, meth):
         class config_:
             class translation:
-                gc = 'hybrid'
+                gc = self.gc
                 gcrootfinder = 'asmgcc'
                 gctransformer = 'framework'
                 gcremovetypeptr = False
@@ -387,3 +388,7 @@
         assert operations[1].getarg(1) == v_index
         assert operations[1].getarg(2) == v_value
         assert operations[1].getdescr() == array_descr
+
+
+class TestFrameworkMiniMark(TestFramework):
+    gc = 'minimark'

Modified: pypy/trunk/pypy/jit/backend/x86/test/test_zrpy_gc.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/test/test_zrpy_gc.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/test/test_zrpy_gc.py	Mon Sep 27 18:37:56 2010
@@ -18,6 +18,7 @@
 from pypy.jit.backend.llsupport.gc import GcLLDescr_framework
 from pypy.tool.udir import udir
 from pypy.jit.backend.x86.arch import IS_X86_64
+from pypy.config.translationoption import DEFL_GC
 import py.test
 
 class X(object):
@@ -126,7 +127,8 @@
 
 # ______________________________________________________________________
 
-class TestCompileHybrid(object):
+class TestCompileFramework(object):
+    # Test suite using (so far) the minimark GC.
     def setup_class(cls):
         funcs = []
         name_to_func = {}
@@ -175,13 +177,13 @@
         OLD_DEBUG = GcLLDescr_framework.DEBUG
         try:
             GcLLDescr_framework.DEBUG = True
-            cls.cbuilder = compile(get_entry(allfuncs), "hybrid",
+            cls.cbuilder = compile(get_entry(allfuncs), DEFL_GC,
                                    gcrootfinder="asmgcc", jit=True)
         finally:
             GcLLDescr_framework.DEBUG = OLD_DEBUG
 
     def run(self, name, n=2000):
-        pypylog = udir.join('TestCompileHybrid.log')
+        pypylog = udir.join('TestCompileFramework.log')
         res = self.cbuilder.cmdexec("%s %d" %(name, n),
                                     env={'PYPYLOG': ':%s' % pypylog})
         assert int(res) == 20
@@ -189,7 +191,7 @@
     def run_orig(self, name, n, x):
         self.main_allfuncs(name, n, x)
 
-    def define_compile_hybrid_1(cls):
+    def define_compile_framework_1(cls):
         # a moving GC.  Supports malloc_varsize_nonmovable.  Simple test, works
         # without write_barriers and root stack enumeration.
         def f(n, x, *args):
@@ -199,10 +201,10 @@
             return (n, x) + args
         return None, f, None
 
-    def test_compile_hybrid_1(self):
-        self.run('compile_hybrid_1')
+    def test_compile_framework_1(self):
+        self.run('compile_framework_1')
 
-    def define_compile_hybrid_2(cls):
+    def define_compile_framework_2(cls):
         # More complex test, requires root stack enumeration but
         # not write_barriers.
         def f(n, x, *args):
@@ -215,10 +217,10 @@
             return (n, x) + args
         return None, f, None
 
-    def test_compile_hybrid_2(self):
-        self.run('compile_hybrid_2')
+    def test_compile_framework_2(self):
+        self.run('compile_framework_2')
 
-    def define_compile_hybrid_3(cls):
+    def define_compile_framework_3(cls):
         # Third version of the test.  Really requires write_barriers.
         def f(n, x, *args):
             x.next = None
@@ -241,13 +243,13 @@
 
 
 
-    def test_compile_hybrid_3(self):
+    def test_compile_framework_3(self):
         x_test = X()
         x_test.foo = 5
-        self.run_orig('compile_hybrid_3', 6, x_test)     # check that it does not raise CheckError
-        self.run('compile_hybrid_3')
+        self.run_orig('compile_framework_3', 6, x_test)     # check that it does not raise CheckError
+        self.run('compile_framework_3')
 
-    def define_compile_hybrid_3_extra(cls):
+    def define_compile_framework_3_extra(cls):
         # Extra version of the test, with tons of live vars around the residual
         # call that all contain a GC pointer.
         @dont_look_inside
@@ -287,11 +289,11 @@
             return n, None, x0, x1, x2, x3, x4, x5, x6, x7, None, None
         return before, f, None
 
-    def test_compile_hybrid_3_extra(self):
-        self.run_orig('compile_hybrid_3_extra', 6, None)     # check that it does not raise CheckError
-        self.run('compile_hybrid_3_extra')
+    def test_compile_framework_3_extra(self):
+        self.run_orig('compile_framework_3_extra', 6, None)     # check that it does not raise CheckError
+        self.run('compile_framework_3_extra')
 
-    def define_compile_hybrid_4(cls):
+    def define_compile_framework_4(cls):
         # Fourth version of the test, with __del__.
         from pypy.rlib.debug import debug_print
         class Counter:
@@ -311,10 +313,10 @@
             return (n, x) + args
         return before, f, None
 
-    def test_compile_hybrid_4(self):
-        self.run('compile_hybrid_4')
+    def test_compile_framework_4(self):
+        self.run('compile_framework_4')
 
-    def define_compile_hybrid_5(cls):
+    def define_compile_framework_5(cls):
         # Test string manipulation.
         def f(n, x, x0, x1, x2, x3, x4, x5, x6, x7, l, s):
             n -= x.foo
@@ -324,10 +326,10 @@
             check(len(s) == 1*5 + 2*45 + 3*450 + 4*500)
         return None, f, after
 
-    def test_compile_hybrid_5(self):
-        self.run('compile_hybrid_5')
+    def test_compile_framework_5(self):
+        self.run('compile_framework_5')
 
-    def define_compile_hybrid_7(cls):
+    def define_compile_framework_7(cls):
         # Array of pointers (test the write barrier for setarrayitem_gc)
         def before(n, x):
             return n, x, None, None, None, None, None, None, None, None, [X(123)], None
@@ -391,10 +393,10 @@
             check(l[15].x == 142)
         return before, f, after
 
-    def test_compile_hybrid_7(self):
-        self.run('compile_hybrid_7')
+    def test_compile_framework_7(self):
+        self.run('compile_framework_7')
 
-    def define_compile_hybrid_external_exception_handling(cls):
+    def define_compile_framework_external_exception_handling(cls):
         def before(n, x):
             x = X(0)
             return n, x, None, None, None, None, None, None, None, None, None, None        
@@ -427,10 +429,10 @@
 
         return before, f, None
 
-    def test_compile_hybrid_external_exception_handling(self):
-        self.run('compile_hybrid_external_exception_handling')
+    def test_compile_framework_external_exception_handling(self):
+        self.run('compile_framework_external_exception_handling')
             
-    def define_compile_hybrid_bug1(self):
+    def define_compile_framework_bug1(self):
         @purefunction
         def nonmoving():
             x = X(1)
@@ -453,10 +455,10 @@
 
         return None, f, None
 
-    def test_compile_hybrid_bug1(self):
-        self.run('compile_hybrid_bug1', 200)
+    def test_compile_framework_bug1(self):
+        self.run('compile_framework_bug1', 200)
 
-    def define_compile_hybrid_vref(self):
+    def define_compile_framework_vref(self):
         from pypy.rlib.jit import virtual_ref, virtual_ref_finish
         class A:
             pass
@@ -469,10 +471,10 @@
             return n, x, x0, x1, x2, x3, x4, x5, x6, x7, l, s
         return None, f, None
 
-    def test_compile_hybrid_vref(self):
-        self.run('compile_hybrid_vref', 200)
+    def test_compile_framework_vref(self):
+        self.run('compile_framework_vref', 200)
 
-    def define_compile_hybrid_float(self):
+    def define_compile_framework_float(self):
         # test for a bug: the fastpath_malloc does not save and restore
         # xmm registers around the actual call to the slow path
         class A:
@@ -519,5 +521,5 @@
             return n, x, x0, x1, x2, x3, x4, x5, x6, x7, l, s
         return None, f, None
 
-    def test_compile_hybrid_float(self):
-        self.run('compile_hybrid_float')
+    def test_compile_framework_float(self):
+        self.run('compile_framework_float')

Modified: pypy/trunk/pypy/jit/backend/x86/test/test_ztranslation.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/test/test_ztranslation.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/test/test_ztranslation.py	Mon Sep 27 18:37:56 2010
@@ -8,6 +8,7 @@
 from pypy.jit.codewriter.policy import StopAtXPolicy
 from pypy.translator.translator import TranslationContext
 from pypy.jit.backend.x86.arch import IS_X86_32, IS_X86_64
+from pypy.config.translationoption import DEFL_GC
 
 class TestTranslationX86(CCompiledMixin):
     CPUClass = getcpuclass()
@@ -118,7 +119,7 @@
 
     def _get_TranslationContext(self):
         t = TranslationContext()
-        t.config.translation.gc = 'hybrid'
+        t.config.translation.gc = DEFL_GC   # 'hybrid' or 'minimark'
         t.config.translation.gcrootfinder = 'asmgcc'
         t.config.translation.list_comprehension_operations = True
         t.config.translation.gcremovetypeptr = True

Modified: pypy/trunk/pypy/jit/metainterp/gc.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/gc.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/gc.py	Mon Sep 27 18:37:56 2010
@@ -19,6 +19,9 @@
 class GC_hybrid(GcDescription):
     malloc_zero_filled = True
 
+class GC_minimark(GcDescription):
+    malloc_zero_filled = True
+
 
 def get_description(config):
     name = config.translation.gc

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	Mon Sep 27 18:37:56 2010
@@ -147,6 +147,11 @@
     def get_young_var_basesize(nursery_size):
         return nursery_size // 4 - 1
 
+    @classmethod
+    def JIT_max_size_of_young_obj(cls):
+        min_nurs_size = cls.TRANSLATION_PARAMS['min_nursery_size']
+        return cls.get_young_fixedsize(min_nurs_size)
+
     def is_in_nursery(self, addr):
         ll_assert(llmemory.cast_adr_to_int(addr) & 1 == 0,
                   "odd-valued (i.e. tagged) pointer unexpected here")

Modified: pypy/trunk/pypy/rpython/memory/gc/minimark.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gc/minimark.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gc/minimark.py	Mon Sep 27 18:37:56 2010
@@ -719,6 +719,10 @@
     #  "if addr_struct.int0 & JIT_WB_IF_FLAG: remember_young_pointer()")
     JIT_WB_IF_FLAG = GCFLAG_NO_YOUNG_PTRS
 
+    @classmethod
+    def JIT_max_size_of_young_obj(cls):
+        return cls.TRANSLATION_PARAMS['large_object']
+
     def write_barrier(self, addr_struct):
         if self.header(addr_struct).tid & GCFLAG_NO_YOUNG_PTRS:
             self.remember_young_pointer(addr_struct)

Modified: pypy/trunk/pypy/rpython/memory/gc/minimarkpage.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gc/minimarkpage.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gc/minimarkpage.py	Mon Sep 27 18:37:56 2010
@@ -336,7 +336,7 @@
 
 def _start_of_page_untranslated(addr, page_size):
     assert isinstance(addr, llarena.fakearenaaddress)
-    shift = 4     # for testing, we assume that the whole arena is not
+    shift = WORD  # for testing, we assume that the whole arena is not
                   # on a page boundary
     ofs = ((addr.offset - shift) // page_size) * page_size + shift
     return llarena.fakearenaaddress(addr.arena, ofs)

Modified: pypy/trunk/pypy/rpython/memory/gc/test/test_minimarkpage.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gc/test/test_minimarkpage.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gc/test/test_minimarkpage.py	Mon Sep 27 18:37:56 2010
@@ -7,22 +7,22 @@
 from pypy.rpython.lltypesystem.llmemory import cast_ptr_to_adr
 
 NULL = llmemory.NULL
-SHIFT = 4
+SHIFT = WORD
 hdrsize = llmemory.raw_malloc_usage(llmemory.sizeof(PAGE_HEADER))
 
 
 def test_allocate_arena():
-    ac = ArenaCollection(SHIFT + 8*20, 8, 1)
+    ac = ArenaCollection(SHIFT + 16*20, 16, 1)
     ac.allocate_new_arena()
     assert ac.num_uninitialized_pages == 20
-    ac.uninitialized_pages + 8*20   # does not raise
-    py.test.raises(llarena.ArenaError, "ac.uninitialized_pages + 8*20 + 1")
+    ac.uninitialized_pages + 16*20   # does not raise
+    py.test.raises(llarena.ArenaError, "ac.uninitialized_pages + 16*20 + 1")
     #
-    ac = ArenaCollection(SHIFT + 8*20 + 7, 8, 1)
+    ac = ArenaCollection(SHIFT + 16*20 + 7, 16, 1)
     ac.allocate_new_arena()
     assert ac.num_uninitialized_pages == 20
-    ac.uninitialized_pages + 8*20 + 7   # does not raise
-    py.test.raises(llarena.ArenaError, "ac.uninitialized_pages + 8*20 + 8")
+    ac.uninitialized_pages + 16*20 + 7   # does not raise
+    py.test.raises(llarena.ArenaError, "ac.uninitialized_pages + 16*20 + 16")
 
 
 def test_allocate_new_page():

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	Mon Sep 27 18:37:56 2010
@@ -29,7 +29,7 @@
     GC_CAN_MALLOC_NONMOVABLE = True
     GC_CAN_SHRINK_ARRAY = False
     GC_CAN_SHRINK_BIG_ARRAY = False
-    BUT_HOW_BIG_IS_A_BIG_STRING = 12
+    BUT_HOW_BIG_IS_A_BIG_STRING = 3*WORD
 
     def setup_class(cls):
         cls._saved_logstate = py.log._getstate()



More information about the Pypy-commit mailing list