[pypy-svn] r78089 - in pypy/trunk/pypy/module/pypyjit: . test

arigo at codespeak.net arigo at codespeak.net
Tue Oct 19 17:16:49 CEST 2010


Author: arigo
Date: Tue Oct 19 17:16:48 2010
New Revision: 78089

Modified:
   pypy/trunk/pypy/module/pypyjit/__init__.py
   pypy/trunk/pypy/module/pypyjit/interp_jit.py
   pypy/trunk/pypy/module/pypyjit/test/test_pypy_c.py
Log:
Attempt to fix test_blockstack_virtualizable.
The idea was to force a residual call, which is hard to do nowadays.
So I added a debugging API to the pypyjit module doing that.


Modified: pypy/trunk/pypy/module/pypyjit/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/pypyjit/__init__.py	(original)
+++ pypy/trunk/pypy/module/pypyjit/__init__.py	Tue Oct 19 17:16:48 2010
@@ -6,6 +6,7 @@
 
     interpleveldefs = {
         'set_param':    'interp_jit.set_param',
+        'residual_call': 'interp_jit.residual_call',
     }
 
     def setup_after_space_initialization(self):

Modified: pypy/trunk/pypy/module/pypyjit/interp_jit.py
==============================================================================
--- pypy/trunk/pypy/module/pypyjit/interp_jit.py	(original)
+++ pypy/trunk/pypy/module/pypyjit/interp_jit.py	Tue Oct 19 17:16:48 2010
@@ -5,10 +5,10 @@
 
 from pypy.tool.pairtype import extendabletype
 from pypy.rlib.rarithmetic import r_uint, intmask
-from pypy.rlib.jit import JitDriver, hint, we_are_jitted
+from pypy.rlib.jit import JitDriver, hint, we_are_jitted, dont_look_inside
 import pypy.interpreter.pyopcode   # for side-effects
 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.gateway import ObjSpace, Arguments
+from pypy.interpreter.gateway import ObjSpace, Arguments, W_Root
 from pypy.interpreter.pycode import PyCode, CO_GENERATOR
 from pypy.interpreter.pyframe import PyFrame
 from pypy.interpreter.pyopcode import ExitFrame
@@ -131,3 +131,10 @@
                                   "no JIT parameter '%s'", key)
 
 set_param.unwrap_spec = [ObjSpace, Arguments]
+
+ at dont_look_inside
+def residual_call(space, w_callable, args):
+    '''For testing.  Invokes callable(...), but without letting
+    the JIT follow the call.'''
+    return space.call_args(w_callable, args)
+residual_call.unwrap_spec = [ObjSpace, W_Root, Arguments]

Modified: pypy/trunk/pypy/module/pypyjit/test/test_pypy_c.py
==============================================================================
--- pypy/trunk/pypy/module/pypyjit/test/test_pypy_c.py	(original)
+++ pypy/trunk/pypy/module/pypyjit/test/test_pypy_c.py	Tue Oct 19 17:16:48 2010
@@ -560,17 +560,13 @@
 
     def test_blockstack_virtualizable(self):
         self.run_source('''
-        def g(k):
-            s = 0
-            for i in range(k, k+2):
-                s += 1
-            return s
+        import pypyjit
 
         def main():
             i = 0
             while i < 100:
                 try:
-                    g(i)
+                    pypyjit.residual_call(len, [])
                 except:
                     pass
                 i += 1
@@ -1185,6 +1181,17 @@
         cls.pypy_c = option.pypy_c
 
 
+def test_interface_residual_call():
+    space = gettestobjspace(usemodules=['pypyjit'])
+    space.appexec([], """():
+        import pypyjit
+        def f(*args, **kwds):
+            return (args, kwds)
+        res = pypyjit.residual_call(f, 4, x=6)
+        assert res == ((4,), {'x': 6})
+    """)
+
+
 def has_info(pypy_c, option):
     g = os.popen('"%s" --info' % pypy_c, 'r')
     lines = g.readlines()



More information about the Pypy-commit mailing list