[pypy-commit] pypy default: (alex, mike, fijal, arigo): fix interaction of JIT look inside iff and oopspecs
alex_gaynor
noreply at buildbot.pypy.org
Sun Dec 2 20:21:35 CET 2012
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r59227:61758d80f0a1
Date: 2012-12-02 11:21 -0800
http://bitbucket.org/pypy/pypy/changeset/61758d80f0a1/
Log: (alex, mike, fijal, arigo): fix interaction of JIT look inside iff
and oopspecs
diff --git a/pypy/jit/metainterp/test/support.py b/pypy/jit/metainterp/test/support.py
--- a/pypy/jit/metainterp/test/support.py
+++ b/pypy/jit/metainterp/test/support.py
@@ -10,6 +10,8 @@
from pypy.jit.codewriter.policy import JitPolicy
from pypy.jit.codewriter import codewriter, longlong
from pypy.rlib.rfloat import isnan
+from pypy.translator.backendopt.all import backend_optimizations
+
def _get_jitcodes(testself, CPUClass, func, values, type_system,
supports_longlong=False, translationoptions={}, **kwds):
@@ -68,7 +70,9 @@
policy = JitPolicy()
policy.set_supports_floats(True)
policy.set_supports_longlong(supports_longlong)
- cw.find_all_graphs(policy)
+ graphs = cw.find_all_graphs(policy)
+ if kwds.get("backendopt"):
+ backend_optimizations(rtyper.annotator.translator, graphs=graphs)
#
testself.warmrunnerstate = FakeWarmRunnerState()
testself.warmrunnerstate.cpu = cpu
diff --git a/pypy/jit/metainterp/test/test_list.py b/pypy/jit/metainterp/test/test_list.py
--- a/pypy/jit/metainterp/test/test_list.py
+++ b/pypy/jit/metainterp/test/test_list.py
@@ -1,6 +1,6 @@
import py
from pypy.rlib.objectmodel import newlist_hint
-from pypy.rlib.jit import JitDriver
+from pypy.rlib.jit import JitDriver, promote
from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
@@ -79,7 +79,7 @@
self.check_loops(setarrayitem_gc=0, call=0)
def test_vlist_with_default_read(self):
- jitdriver = JitDriver(greens = [], reds = ['n'])
+ jitdriver = JitDriver(greens=[], reds=['n'])
def f(n):
l = [1] * 20
while n > 0:
@@ -93,7 +93,7 @@
n -= 1
return l[0]
- res = self.meta_interp(f, [10], listops=True)
+ res = self.meta_interp(f, [10], listops=True, backendopt=True)
assert res == f(10)
self.check_resops(setarrayitem_gc=0, call=0, getarrayitem_gc=0)
@@ -272,6 +272,22 @@
r = self.interp_operations(f, [-1])
assert r == 0
+ def test_list_mul_nonzero(self):
+ driver = JitDriver(greens=[], reds=['i', 'n'])
+
+ def f(n):
+ i = 0
+ while i < n:
+ driver.jit_merge_point(i=i, n=n)
+ x = promote(n)
+ l = [-1] * x
+ i -= l[2]
+ return i
+ res = self.meta_interp(f, [5])
+ assert res == 5
+ self.check_resops(call=0)
+
+
class TestOOtype(ListTests, OOJitMixin):
pass
diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py
--- a/pypy/jit/metainterp/test/test_tracingopts.py
+++ b/pypy/jit/metainterp/test/test_tracingopts.py
@@ -339,7 +339,7 @@
res = self.interp_operations(fn, [7])
assert res == 7 + 7 + 1
self.check_operations_history(setarrayitem_gc=2,
- setfield_gc=2)
+ setfield_gc=0)
def test_virtualizable_with_array_heap_cache(self):
myjitdriver = jit.JitDriver(greens = [], reds = ['n', 'x', 'i', 'frame'],
@@ -559,7 +559,7 @@
a1 = [0] * n
g.a = a1
return len(a1) + res
- res = self.interp_operations(fn, [7])
+ res = self.interp_operations(fn, [7], backendopt=True)
assert res == 7 * 3
self.check_operations_history(arraylen_gc=1)
@@ -574,7 +574,7 @@
x = [0] * n
x[2] = 21
return len(a[:n]) + x[2]
- res = self.interp_operations(fn, [3])
+ res = self.interp_operations(fn, [3], backendopt=True)
assert res == 24
self.check_operations_history(getarrayitem_gc=0)
diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py
--- a/pypy/rlib/jit.py
+++ b/pypy/rlib/jit.py
@@ -161,8 +161,7 @@
def trampoline(%(arguments)s):
return func(%(arguments)s)
if hasattr(func, "oopspec"):
- # XXX: This seems like it should be here, but it causes errors.
- # trampoline.oopspec = func.oopspec
+ trampoline.oopspec = func.oopspec
del func.oopspec
trampoline.__name__ = func.__name__ + "_trampoline"
trampoline._annspecialcase_ = "specialize:call_location"
@@ -173,6 +172,7 @@
else:
return trampoline(%(arguments)s)
f.__name__ = func.__name__ + "_look_inside_iff"
+ f._always_inline = True
""" % {"arguments": ", ".join(args)}).compile() in d
return d["f"]
return inner
More information about the pypy-commit
mailing list