[pypy-svn] r69757 - in pypy/branch/virtual-forcing/pypy/rpython/memory/gctransform: . test
arigo at codespeak.net
arigo at codespeak.net
Mon Nov 30 12:06:48 CET 2009
Author: arigo
Date: Mon Nov 30 12:06:47 2009
New Revision: 69757
Modified:
pypy/branch/virtual-forcing/pypy/rpython/memory/gctransform/framework.py
pypy/branch/virtual-forcing/pypy/rpython/memory/gctransform/test/test_framework.py
Log:
Test and fix: the CollectAnalyzer must say "yes" when seeing an
external call to a function that can release the GIL, because
around such calls we must write the stack push/pops too.
Fixes pypy/module/thread/test/test_gil.py.
Modified: pypy/branch/virtual-forcing/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/rpython/memory/gctransform/framework.py (original)
+++ pypy/branch/virtual-forcing/pypy/rpython/memory/gctransform/framework.py Mon Nov 30 12:06:47 2009
@@ -29,12 +29,15 @@
def analyze_direct_call(self, graph, seen=None):
try:
func = graph.func
+ except AttributeError:
+ pass
+ else:
if func is rstack.stack_check:
return self.translator.config.translation.stackless
- if func._gctransformer_hint_cannot_collect_:
+ if getattr(func, '_gctransformer_hint_cannot_collect_', False):
return False
- except AttributeError:
- pass
+ if getattr(func, '_gctransformer_hint_close_stack_', False):
+ return True
return graphanalyze.GraphAnalyzer.analyze_direct_call(self, graph,
seen)
Modified: pypy/branch/virtual-forcing/pypy/rpython/memory/gctransform/test/test_framework.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/rpython/memory/gctransform/test/test_framework.py (original)
+++ pypy/branch/virtual-forcing/pypy/rpython/memory/gctransform/test/test_framework.py Mon Nov 30 12:06:47 2009
@@ -6,7 +6,7 @@
from pypy.rpython.memory.gctransform.transform import GcHighLevelOp
from pypy.rpython.memory.gctransform.framework import FrameworkGCTransformer, \
CollectAnalyzer, find_initializing_stores, find_clean_setarrayitems
-from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem import lltype, rffi
from pypy.rpython.rtyper import LowLevelOpList
from pypy.translator.c.gc import FrameworkGcPolicy
from pypy.translator.translator import TranslationContext, graphof
@@ -87,6 +87,33 @@
can_collect = CollectAnalyzer(t).analyze_direct_call(with_check_graph)
assert can_collect
+def test_cancollect_external():
+ fext1 = rffi.llexternal('fext1', [], lltype.Void, threadsafe=False)
+ def g():
+ fext1()
+ t = rtype(g, [])
+ gg = graphof(t, g)
+ assert not CollectAnalyzer(t).analyze_direct_call(gg)
+
+ fext2 = rffi.llexternal('fext2', [], lltype.Void, threadsafe=True)
+ def g():
+ fext2()
+ t = rtype(g, [])
+ gg = graphof(t, g)
+ assert CollectAnalyzer(t).analyze_direct_call(gg)
+
+ S = lltype.GcStruct('S', ('x', lltype.Signed))
+ FUNC = lltype.Ptr(lltype.FuncType([lltype.Signed], lltype.Void))
+ fext3 = rffi.llexternal('fext3', [FUNC], lltype.Void, threadsafe=False)
+ def h(x):
+ lltype.malloc(S, zero=True)
+ def g():
+ fext3(h)
+ t = rtype(g, [])
+ gg = graphof(t, g)
+ assert CollectAnalyzer(t).analyze_direct_call(gg)
+
+
class WriteBarrierTransformer(FrameworkGCTransformer):
clean_sets = {}
GC_PARAMS = {}
More information about the Pypy-commit
mailing list