[pypy-svn] pypy jit-longlong: Adapt policy.py.

arigo commits-noreply at bitbucket.org
Thu Jan 6 21:35:46 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: jit-longlong
Changeset: r40425:ba60c8fbeb04
Date: 2011-01-06 20:02 +0100
http://bitbucket.org/pypy/pypy/changeset/ba60c8fbeb04/

Log:	Adapt policy.py.

diff --git a/pypy/jit/codewriter/test/test_policy.py b/pypy/jit/codewriter/test/test_policy.py
--- a/pypy/jit/codewriter/test/test_policy.py
+++ b/pypy/jit/codewriter/test/test_policy.py
@@ -1,23 +1,34 @@
+import sys
 from pypy.jit.codewriter.policy import contains_unsupported_variable_type
 from pypy.jit.codewriter.policy import JitPolicy
 from pypy.jit.codewriter import support
-from pypy.rlib.rarithmetic import r_singlefloat
+from pypy.rlib.rarithmetic import r_singlefloat, r_longlong
 from pypy.rlib import jit
 
 def test_contains_unsupported_variable_type():
     def f(x):
         return x
     graph = support.getgraph(f, [5])
-    assert not contains_unsupported_variable_type(graph, True)
-    assert not contains_unsupported_variable_type(graph, False)
+    for sf in [False, True]:
+        for sll in [False, True]:
+            assert not contains_unsupported_variable_type(graph, sf, sll)
     #
     graph = support.getgraph(f, [5.5])
-    assert not contains_unsupported_variable_type(graph, True)
-    assert contains_unsupported_variable_type(graph, False)
+    for sf in [False, True]:
+        for sll in [False, True]:
+            res = contains_unsupported_variable_type(graph, sf, sll)
+            assert res is not sf
     #
     graph = support.getgraph(f, [r_singlefloat(5.5)])
-    assert contains_unsupported_variable_type(graph, True)
-    assert contains_unsupported_variable_type(graph, False)
+    for sf in [False, True]:
+        for sll in [False, True]:
+            assert contains_unsupported_variable_type(graph, sf, sll)
+    #
+    graph = support.getgraph(f, [r_longlong(5)])
+    for sf in [False, True]:
+        for sll in [False, True]:
+            res = contains_unsupported_variable_type(graph, sf, sll)
+            assert res == (sys.maxint == 2147483647 and not sll)
 
 
 def test_regular_function():

diff --git a/pypy/jit/codewriter/policy.py b/pypy/jit/codewriter/policy.py
--- a/pypy/jit/codewriter/policy.py
+++ b/pypy/jit/codewriter/policy.py
@@ -13,10 +13,14 @@
     def __init__(self):
         self.unsafe_loopy_graphs = set()
         self.supports_floats = False
+        self.supports_longlong = False
 
     def set_supports_floats(self, flag):
         self.supports_floats = flag
 
+    def set_supports_longlong(self, flag):
+        self.supports_longlong = flag
+
     def dump_unsafe_loops(self):
         f = udir.join("unsafe-loops.txt").open('w')
         strs = [str(graph) for graph in self.unsafe_loopy_graphs]
@@ -63,21 +67,24 @@
                     func, '_jit_unroll_safe_', False)
 
         res = see_function and not contains_unsupported_variable_type(graph,
-                                                         self.supports_floats)
+                                                        self.supports_floats,
+                                                        self.supports_longlong)
         if res and contains_loop:
             self.unsafe_loopy_graphs.add(graph)
         return res and not contains_loop
 
-def contains_unsupported_variable_type(graph, supports_floats):
+def contains_unsupported_variable_type(graph, supports_floats,
+                                       supports_longlong):
     getkind = history.getkind
     try:
         for block in graph.iterblocks():
             for v in block.inputargs:
-                getkind(v.concretetype, supports_floats)
+                getkind(v.concretetype, supports_floats, supports_longlong)
             for op in block.operations:
                 for v in op.args:
-                    getkind(v.concretetype, supports_floats)
-                getkind(op.result.concretetype, supports_floats)
+                    getkind(v.concretetype, supports_floats, supports_longlong)
+                v = op.result
+                getkind(v.concretetype, supports_floats, supports_longlong)
     except NotImplementedError, e:
         log.WARNING('%s, ignoring graph' % (e,))
         log.WARNING('  %s' % (graph,))


More information about the Pypy-commit mailing list