[pypy-svn] r57896 - in pypy/branch/garden-call-code-2/pypy: rpython/memory/gctransform rpython/memory/gctransform/test translator/test

pedronis at codespeak.net pedronis at codespeak.net
Sat Sep 6 18:58:14 CEST 2008


Author: pedronis
Date: Sat Sep  6 18:58:12 2008
New Revision: 57896

Modified:
   pypy/branch/garden-call-code-2/pypy/rpython/memory/gctransform/framework.py
   pypy/branch/garden-call-code-2/pypy/rpython/memory/gctransform/test/test_framework.py
   pypy/branch/garden-call-code-2/pypy/translator/test/test_stackcheck.py
Log:
avoid the root reloading around stack checks in the non-stackless case



Modified: pypy/branch/garden-call-code-2/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/branch/garden-call-code-2/pypy/rpython/memory/gctransform/framework.py	(original)
+++ pypy/branch/garden-call-code-2/pypy/rpython/memory/gctransform/framework.py	Sat Sep  6 18:58:12 2008
@@ -7,6 +7,7 @@
 from pypy.rpython.memory.gc import marksweep
 from pypy.rpython.memory.gcheader import GCHeaderBuilder
 from pypy.rlib.rarithmetic import ovfcheck
+from pypy.rlib import rstack
 from pypy.rlib.debug import ll_assert
 from pypy.translator.backendopt import graphanalyze
 from pypy.translator.backendopt.support import var_needsgc
@@ -25,7 +26,10 @@
 
     def analyze_direct_call(self, graph, seen=None):
         try:
-            if graph.func._gctransformer_hint_cannot_collect_:
+            func = graph.func
+            if func is rstack.stack_check:
+                return self.translator.config.translation.stackless
+            if func._gctransformer_hint_cannot_collect_:
                 return False
         except AttributeError:
             pass

Modified: pypy/branch/garden-call-code-2/pypy/rpython/memory/gctransform/test/test_framework.py
==============================================================================
--- pypy/branch/garden-call-code-2/pypy/rpython/memory/gctransform/test/test_framework.py	(original)
+++ pypy/branch/garden-call-code-2/pypy/rpython/memory/gctransform/test/test_framework.py	Sat Sep  6 18:58:12 2008
@@ -63,6 +63,28 @@
     gg = graphof(t, g)
     assert CollectAnalyzer(t).analyze_direct_call(gg)
 
+    def g(x):
+        return -x
+    t = rtype(g, [int])
+    gg = graphof(t, g)
+    assert not CollectAnalyzer(t).analyze_direct_call(gg)    
+
+def test_cancollect_stack_check():
+    from pypy.rlib import rstack
+
+    def with_check():
+        rstack.stack_check()
+
+    t = rtype(with_check, [])
+    with_check_graph = graphof(t, with_check)
+
+    assert not t.config.translation.stackless
+    can_collect = CollectAnalyzer(t).analyze_direct_call(with_check_graph)
+    assert not can_collect
+    
+    t.config.translation.stackless = True
+    can_collect = CollectAnalyzer(t).analyze_direct_call(with_check_graph)
+    assert can_collect
 
 class WriteBarrierTransformer(FrameworkGCTransformer):
     initializing_stores = {}

Modified: pypy/branch/garden-call-code-2/pypy/translator/test/test_stackcheck.py
==============================================================================
--- pypy/branch/garden-call-code-2/pypy/translator/test/test_stackcheck.py	(original)
+++ pypy/branch/garden-call-code-2/pypy/translator/test/test_stackcheck.py	Sat Sep  6 18:58:12 2008
@@ -118,7 +118,7 @@
             if in_between and spaceop.opname == 'gc_reload_possibly_moved':
                 reload += 1
                 
-        assert reload == 1 # we would like this to be zero
+        assert reload == 0
         
 def test_stackless():
     t = TranslationContext()
@@ -132,6 +132,7 @@
     t.checkgraphs()
     assert n == 1
 
+    t.config.translation.stackless = True
     stacklesstransf = StacklessTransformer(t, g)
         
     f_graph = graphof(t, f)



More information about the Pypy-commit mailing list