[pypy-svn] r65173 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test
arigo at codespeak.net
arigo at codespeak.net
Fri May 8 23:16:38 CEST 2009
Author: arigo
Date: Fri May 8 23:16:38 2009
New Revision: 65173
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/policy.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
Log:
Add to policy.py the ability to look if the graph if using
an unsupported variable kind, like floats. If so, the graph
is simply skipped.
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/policy.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/policy.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/policy.py Fri May 8 23:16:38 2009
@@ -1,5 +1,5 @@
from pypy.translator.simplify import get_funcobj
-from pypy.jit.metainterp import support
+from pypy.jit.metainterp import support, history
class JitPolicy(object):
@@ -16,6 +16,8 @@
return True
def look_inside_graph(self, graph):
+ if contains_unsupported_variable_type(graph):
+ return False
try:
func = graph.func
except AttributeError:
@@ -65,6 +67,23 @@
return 'residual'
return 'regular'
+def contains_unsupported_variable_type(graph):
+ getkind = history.getkind
+ try:
+ for block in graph.iterblocks():
+ for v in block.inputargs:
+ getkind(v.concretetype)
+ for op in block.operations:
+ for v in op.args:
+ getkind(v.concretetype)
+ getkind(op.result.concretetype)
+ except NotImplementedError, e:
+ history.log.WARNING('%s, ignoring graph' % (e,))
+ history.log.WARNING(' %s' % (graph,))
+ return True
+ return False
+
+# ____________________________________________________________
class StopAtXPolicy(JitPolicy):
def __init__(self, *funcs):
@@ -90,7 +109,9 @@
def look_inside_graph(self, graph):
if graph in self.enabled_graphs:
return self.enabled_graphs[graph]
- return super(ManualJitPolicy, self).look_inside_graph(graph)
+ res = super(ManualJitPolicy, self).look_inside_graph(graph)
+ self.enabled_graphs[graph] = res # cache the result
+ return res
def fill_seen_graphs(self):
# subclasses should have their own
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py Fri May 8 23:16:38 2009
@@ -602,6 +602,20 @@
res = self.interp_operations(f, [5])
assert res == f(5)
+ def test_long_long(self):
+ from pypy.rlib.rarithmetic import r_longlong, intmask
+ def g(n, m, o):
+ # This function should be completely marked as residual by
+ # codewriter.py on 32-bit platforms. On 64-bit platforms,
+ # this function should be JITted and the test should pass too.
+ n = r_longlong(n)
+ m = r_longlong(m)
+ return intmask((n*m) // o)
+ def f(n, m, o):
+ return g(n, m, o) // 3
+ res = self.interp_operations(f, [1000000000, 90, 91])
+ assert res == (1000000000 * 90 // 91) // 3
+
class TestOOtype(BasicTests, OOJitMixin):
More information about the Pypy-commit
mailing list