Author: Armin Rigo <ar...@tunes.org>
Branch: conditional_call_value_2
Changeset: r86992:64fbf35bf49e
Date: 2016-09-11 11:08 +0200
http://bitbucket.org/pypy/pypy/changeset/64fbf35bf49e/

Log:    Tests, progress

diff --git a/rpython/jit/metainterp/test/test_call.py 
b/rpython/jit/metainterp/test/test_call.py
--- a/rpython/jit/metainterp/test/test_call.py
+++ b/rpython/jit/metainterp/test/test_call.py
@@ -52,3 +52,31 @@
 
         assert self.meta_interp(main, [10]) == 42
         self.check_resops(guard_no_exception=0)
+
+    def test_cond_call_i(self):
+        def f(l, n):
+            l.append(n)
+            return 1000
+
+        def main(n):
+            l = []
+            x = jit.conditional_call_value(n, 10, f, l, n)
+            return x + len(l)
+
+        assert self.interp_operations(main, [10]) == 1001
+        assert self.interp_operations(main, [5]) == 5
+
+    def test_cond_call_r(self):
+        def f(n):
+            return [n]
+
+        def main(n):
+            if n == 10:
+                l = []
+            else:
+                l = None
+            l = jit.conditional_call_value(l, None, f, n)
+            return len(l)
+
+        assert self.interp_operations(main, [10]) == 0
+        assert self.interp_operations(main, [5]) == 1
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -3,7 +3,8 @@
 import py
 
 from rpython.rlib.nonconst import NonConstant
-from rpython.rlib.objectmodel import CDefinedIntSymbolic, 
keepalive_until_here, specialize
+from rpython.rlib.objectmodel import CDefinedIntSymbolic, keepalive_until_here
+from rpython.rlib.objectmodel import specialize, we_are_translated
 from rpython.rlib.unroll import unrolling_iterable
 from rpython.rtyper.extregistry import ExtRegistryEntry
 from rpython.tool.sourcetools import rpython_wrapper
@@ -1198,8 +1199,12 @@
         return _jit_conditional_call_value(value, special_constant,
                                            function, *args)
     else:
-        if value == special_constant:
-            value = function(*args)
+        if not we_are_translated() or isinstance(value, int):
+            if value == special_constant:
+                value = function(*args)
+        else:
+            if value is special_constant:
+                value = function(*args)
         return value
 conditional_call_value._always_inline_ = True
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to