[pypy-commit] pypy stmgc-c8: make some gc framework tests pass again

Raemi noreply at buildbot.pypy.org
Tue Nov 24 10:30:49 EST 2015


Author: Remi Meier <remi.meier at gmail.com>
Branch: stmgc-c8
Changeset: r80887:00e26e7cf877
Date: 2015-11-24 09:27 +0100
http://bitbucket.org/pypy/pypy/changeset/00e26e7cf877/

Log:	make some gc framework tests pass again

diff --git a/rpython/memory/gc/stmgc.py b/rpython/memory/gc/stmgc.py
--- a/rpython/memory/gc/stmgc.py
+++ b/rpython/memory/gc/stmgc.py
@@ -12,6 +12,8 @@
 from rpython.rtyper.extregistry import ExtRegistryEntry
 from rpython.translator.stm import stmgcintf
 from rpython.rlib import rstm
+from rpython.rlib.objectmodel import we_are_translated
+from rpython.rtyper.lltypesystem.llmemory import raw_malloc_usage
 
 WORD = LONG_BIT // 8
 NULL = llmemory.NULL
@@ -74,15 +76,16 @@
                                needs_finalizer=False,
                                is_finalizer_light=False,
                                contains_weakptr=False):
-        if size < 16:
-            size = 16     # minimum size (test usually constant-folded)
+        rawsize = raw_malloc_usage(size) # unwrap for tests
+        if rawsize < 16:
+            rawsize = 16     # minimum size (test usually constant-folded)
         if contains_weakptr:    # check constant-folded
-            return llop.stm_allocate_weakref(llmemory.GCREF, size, typeid16)
+            return llop.stm_allocate_weakref(llmemory.GCREF, rawsize, typeid16)
         if needs_finalizer:
             if is_finalizer_light:
-                return llop.stm_allocate_f_light(llmemory.GCREF, size, typeid16)
-            return llop.stm_allocate_finalizer(llmemory.GCREF, size, typeid16)
-        return llop.stm_allocate_tid(llmemory.GCREF, size, typeid16)
+                return llop.stm_allocate_f_light(llmemory.GCREF, rawsize, typeid16)
+            return llop.stm_allocate_finalizer(llmemory.GCREF, rawsize, typeid16)
+        return llop.stm_allocate_tid(llmemory.GCREF, rawsize, typeid16)
 
     def malloc_varsize(self, typeid16, length, size, itemsize,
                              offset_to_length):
diff --git a/rpython/memory/gctransform/test/test_framework.py b/rpython/memory/gctransform/test/test_framework.py
--- a/rpython/memory/gctransform/test/test_framework.py
+++ b/rpython/memory/gctransform/test/test_framework.py
@@ -12,7 +12,7 @@
 from rpython.memory.gctransform.transform import GcHighLevelOp
 from rpython.rtyper.rtyper import LowLevelOpList
 from rpython.translator.backendopt.all import backend_optimizations
-from rpython.translator.c.gc import BasicFrameworkGcPolicy
+from rpython.translator.c.gc import BasicFrameworkGcPolicy, StmFrameworkGcPolicy
 from rpython.translator.exceptiontransform import ExceptionTransformer
 from rpython.translator.translator import TranslationContext, graphof
 from rpython.translator.unsimplify import varoftype
@@ -39,10 +39,13 @@
     t = rtype(entrypoint, [s_list_of_strings])
     if gc == "stmgc":
         t.config.translation.stm = True
+        gcpolicy = StmFrameworkGcPolicy
+    else:
+        gcpolicy = FrameworkGcPolicy2
     t.config.translation.gc = gc
-    
+
     cbuild = CStandaloneBuilder(t, entrypoint, t.config,
-                                gcpolicy=FrameworkGcPolicy2)
+                                gcpolicy=gcpolicy)
     db = cbuild.generate_graphs_for_llinterp()
     entrypointptr = cbuild.getentrypointptr()
     entrygraph = entrypointptr._obj.graph
@@ -59,7 +62,7 @@
 
 def test_framework_simple_stm():
     test_framework_simple("stmgc")
-    
+
 def test_cancollect():
     S = lltype.GcStruct('S', ('x', lltype.Signed))
     def g():
@@ -72,7 +75,7 @@
         return -x
     t = rtype(g, [int])
     gg = graphof(t, g)
-    assert not CollectAnalyzer(t).analyze_direct_call(gg)    
+    assert not CollectAnalyzer(t).analyze_direct_call(gg)
 
 def test_cancollect_external():
     fext1 = rffi.llexternal('fext1', [], lltype.Void, releasegil=False)
@@ -99,7 +102,7 @@
     t = rtype(g, [])
     gg = graphof(t, g)
     assert CollectAnalyzer(t).analyze_direct_call(gg)
-    
+
 def test_no_collect(gc="minimark"):
     from rpython.rlib import rgc
     from rpython.translator.c.genc import CStandaloneBuilder
@@ -113,13 +116,16 @@
 
     def entrypoint(argv):
         return g() + 2
-    
+
     t = rtype(entrypoint, [s_list_of_strings])
     if gc == "stmgc":
         t.config.translation.stm = True
+        gcpolicy = StmFrameworkGcPolicy
+    else:
+        gcpolicy = FrameworkGcPolicy2
     t.config.translation.gc = gc
     cbuild = CStandaloneBuilder(t, entrypoint, t.config,
-                                gcpolicy=FrameworkGcPolicy2)
+                                gcpolicy=gcpolicy)
     db = cbuild.generate_graphs_for_llinterp()
 
 def test_no_collect_stm():
@@ -142,20 +148,23 @@
 
     def entrypoint(argv):
         return g() + 2
-    
+
     t = rtype(entrypoint, [s_list_of_strings])
     if gc == "stmgc":
         t.config.translation.stm = True
+        gcpolicy = StmFrameworkGcPolicy
+    else:
+        gcpolicy = FrameworkGcPolicy2
     t.config.translation.gc = gc
     cbuild = CStandaloneBuilder(t, entrypoint, t.config,
-                                gcpolicy=FrameworkGcPolicy2)
+                                gcpolicy=gcpolicy)
     f = py.test.raises(Exception, cbuild.generate_graphs_for_llinterp)
     expected = "'no_collect' function can trigger collection: <function g at "
     assert str(f.value).startswith(expected)
 
 def test_no_collect_detection_stm():
     test_no_collect_detection("stmgc")
-    
+
 def test_custom_trace_function_no_collect():
     from rpython.rlib import rgc
     from rpython.translator.c.genc import CStandaloneBuilder
@@ -180,7 +189,7 @@
     assert 'can cause the GC to be called' in str(f.value)
     assert 'trace_func' in str(f.value)
     assert 'MyStructure' in str(f.value)
- 
+
 class WriteBarrierTransformer(ShadowStackFrameworkGCTransformer):
     clean_sets = {}
     GC_PARAMS = {}
@@ -258,10 +267,11 @@
         a.z = a
         if cond:
             a.y = a
-    def g():
+    def g(argv):
         f(glob_a_1, 5)
         f(glob_a_2, 0)
-    t = rtype(g, [])
+        return 0
+    t = rtype(g, [s_list_of_strings])
     t.config.translation.gc = "minimark"
     cbuild = CStandaloneBuilder(t, g, t.config,
                                 gcpolicy=FrameworkGcPolicy2)
@@ -288,7 +298,7 @@
     collect_analyzer = CollectAnalyzer(t)
     init_stores = find_initializing_stores(collect_analyzer, t.graphs[0],
                                            mkentrymap(t.graphs[0]))
-    assert len(init_stores) == 1
+    assert len(init_stores) == 4
 
 def test_find_initializing_stores_across_blocks():
 
@@ -314,12 +324,12 @@
     collect_analyzer = CollectAnalyzer(t)
     init_stores = find_initializing_stores(collect_analyzer, t.graphs[0],
                                            mkentrymap(t.graphs[0]))
-    assert len(init_stores) == 5
+    assert len(init_stores) == 9
 
 def test_find_clean_setarrayitems():
     S = lltype.GcStruct('S')
     A = lltype.GcArray(lltype.Ptr(S))
-    
+
     def f():
         l = lltype.malloc(A, 3)
         l[0] = lltype.malloc(S)
@@ -340,7 +350,7 @@
 def test_find_clean_setarrayitems_2():
     S = lltype.GcStruct('S')
     A = lltype.GcArray(lltype.Ptr(S))
-    
+
     def f():
         l = lltype.malloc(A, 3)
         l[0] = lltype.malloc(S)
@@ -362,7 +372,7 @@
 def test_find_clean_setarrayitems_3():
     S = lltype.GcStruct('S')
     A = lltype.GcArray(lltype.Ptr(S))
-    
+
     def f():
         l = lltype.malloc(A, 3)
         l[0] = lltype.malloc(S)
diff --git a/rpython/rtyper/llinterp.py b/rpython/rtyper/llinterp.py
--- a/rpython/rtyper/llinterp.py
+++ b/rpython/rtyper/llinterp.py
@@ -964,8 +964,10 @@
 
     def _stm_not_implemented(self, *args):
         raise NotImplementedError
-    op_stm_push_root = _stm_not_implemented
-    op_stm_pop_root_into = _stm_not_implemented
+    def _stm_ignore(self, *args):
+        return
+    op_stm_push_root = _stm_ignore
+    op_stm_pop_root_into = _stm_ignore
     op_stm_get_root_stack_top = _stm_not_implemented
     op_stm_enter_transactional_zone = _stm_not_implemented
     op_stm_leave_transactional_zone = _stm_not_implemented


More information about the pypy-commit mailing list