Author: Maciej Fijalkowski <[email protected]>
Branch: 
Changeset: r59717:c760f8e27156
Date: 2013-01-05 12:15 +0100
http://bitbucket.org/pypy/pypy/changeset/c760f8e27156/

Log:    Initial fix for rffi functions that release the GIL: the JIT must
        never look inside _gctransformer_hint_close_stack_ functions.

diff --git a/pypy/jit/codewriter/call.py b/pypy/jit/codewriter/call.py
--- a/pypy/jit/codewriter/call.py
+++ b/pypy/jit/codewriter/call.py
@@ -134,9 +134,12 @@
             if getattr(funcobj, 'graph', None) is None:
                 return 'residual'
             targetgraph = funcobj.graph
-            if (hasattr(targetgraph, 'func') and
-                hasattr(targetgraph.func, 'oopspec')):
-                return 'builtin'
+            if hasattr(targetgraph, 'func'):
+                if getattr(targetgraph.func,
+                           '_gctransformer_hint_close_stack_', False):
+                    return 'residual'
+                if hasattr(targetgraph.func, 'oopspec'):
+                    return 'builtin'
         elif op.opname == 'oosend':
             SELFTYPE, methname, opargs = support.decompose_oosend(op)
             if SELFTYPE.oopspec_name is not None:
diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -3985,20 +3985,29 @@
         T = rffi.CArrayPtr(rffi.TIME_T)
         external = rffi.llexternal("time", [T], rffi.TIME_T)
 
-        l = []
+        class Oups(Exception):
+            pass
+        class State:
+            pass
+        state = State()
 
         def before():
-            l.append("before")
+            if we_are_jitted():
+                raise Oups
+            state.l.append("before")
 
         def after():
-            l.append("after")
+            if we_are_jitted():
+                raise Oups
+            state.l.append("after")
 
         def f():
+            state.l = []
+            invoke_around_extcall(before, after)
             external(lltype.nullptr(T.TO))
-            return 1
-
-        invoke_around_extcall(before, after)
-        self.interp_operations(f, [])
-        assert len(l) == 2
-        self.interp_operations(f, [])
-        
+            return len(state.l)
+
+        res = self.interp_operations(f, [])
+        assert res == 2
+        res = self.interp_operations(f, [])
+        assert res == 2
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to