[pypy-svn] pypy default: add an in-progress test

antocuni commits-noreply at bitbucket.org
Thu Feb 24 18:25:34 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r42260:69b171e9f11b
Date: 2011-02-24 15:21 +0100
http://bitbucket.org/pypy/pypy/changeset/69b171e9f11b/

Log:	add an in-progress test

diff --git a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
--- a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
@@ -70,6 +70,38 @@
             jump(p0, p1, p2, p3, i13, p11)
         """)
 
+
+    def test_recursive_call(self):
+        py.test.skip('in-progress')
+        def fn():
+            def rec(n):
+                if n == 0:
+                    return 0
+                return 1 + rec(n-1)
+            #
+            # this loop is traced and then aborted, because the trace is too
+            # long. But then "rec" is marked as "don't inline"
+            i = 0
+            j = 0
+            while i < 20:
+                i += 1
+                j += rec(100)
+            #
+            # next time we try to trace "rec", instead of inlining we compile
+            # it separately and generate a call_assembler
+            i = 0
+            j = 0
+            while i < 20:
+                i += 1
+                j += rec(100) # ID: call_rec
+                a = 0
+            return j
+        #
+        log = self.run(fn, [], threshold=18)
+        loop, = log.loops_by_filename(self.filepath)
+        import pdb;pdb.set_trace()
+
+
     def test_cmp_exc(self):
         def f1(n):
             # So we don't get a LOAD_GLOBAL op

diff --git a/pypy/module/pypyjit/test_pypy_c/test_model.py b/pypy/module/pypyjit/test_pypy_c/test_model.py
--- a/pypy/module/pypyjit/test_pypy_c/test_model.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_model.py
@@ -18,7 +18,7 @@
     def setup_method(self, meth):
         self.filepath = self.tmpdir.join(meth.im_func.func_name + '.py')
 
-    def run(self, func, args=[], threshold=1000):
+    def run(self, func, args=[], **jitopts):
         # write the snippet
         arglist = ', '.join(map(repr, args))
         with self.filepath.open("w") as f:
@@ -27,10 +27,13 @@
         #
         # run a child pypy-c with logging enabled
         logfile = self.filepath.new(ext='.log')
+        #
+        cmdline = [sys.executable, '-S']
+        for key, value in jitopts.iteritems():
+            cmdline += ['--jit', '%s=%s' % (key, value)]
+        cmdline.append(str(self.filepath))
+        #
         env={'PYPYLOG': 'jit-log-opt,jit-summary:' + str(logfile)}
-        cmdline = [sys.executable, '-S',
-                   '--jit', 'threshold=%d' % threshold,
-                   str(self.filepath)]
         pipe = subprocess.Popen(cmdline,
                                 env=env,
                                 stdout=subprocess.PIPE,


More information about the Pypy-commit mailing list