Author: Carl Friedrich Bolz <[email protected]>
Branch: guard-compatible
Changeset: r83017:27576d755874
Date: 2016-03-13 18:39 +0100
http://bitbucket.org/pypy/pypy/changeset/27576d755874/
Log: test interaction with guard_compatible if the elidable function
raises (it's never compatible then)
diff --git a/rpython/jit/metainterp/compatible.py
b/rpython/jit/metainterp/compatible.py
--- a/rpython/jit/metainterp/compatible.py
+++ b/rpython/jit/metainterp/compatible.py
@@ -56,12 +56,19 @@
self.pure_call_conditions.append((op, res))
def check_compat(self, cpu, ref):
+ from rpython.rlib.debug import debug_print, debug_start, debug_stop
for op, correct_res in self.pure_call_conditions:
calldescr = op.getdescr()
# change exactly the first argument
arglist = op.getarglist()
arglist[1] = newconst(ref)
- res = do_call(cpu, arglist, calldescr)
+ try:
+ res = do_call(cpu, arglist, calldescr)
+ except Exception:
+ debug_start("jit-guard-compatible")
+ debug_print("call to elidable_compatible function raised")
+ debug_stop("jit-guard-compatible")
+ return False
if not res.same_constant(correct_res):
return False
return True
diff --git a/rpython/jit/metainterp/test/test_compatible.py
b/rpython/jit/metainterp/test/test_compatible.py
--- a/rpython/jit/metainterp/test/test_compatible.py
+++ b/rpython/jit/metainterp/test/test_compatible.py
@@ -33,3 +33,36 @@
self.meta_interp(main, [])
# XXX check number of bridges
+ def test_exception(self):
+ S = lltype.GcStruct('S', ('x', lltype.Signed))
+ p1 = lltype.malloc(S)
+ p1.x = 5
+
+ p2 = lltype.malloc(S)
+ p2.x = 5
+
+ p3 = lltype.malloc(S)
+ p3.x = 6
+ driver = jit.JitDriver(greens = [], reds = ['n', 'x'])
+ @jit.elidable_compatible()
+ def g(s):
+ if s.x == 6:
+ raise Exception
+ return s.x
+
+ def f(n, x):
+ while n > 0:
+ driver.can_enter_jit(n=n, x=x)
+ driver.jit_merge_point(n=n, x=x)
+ try:
+ n -= g(x)
+ except:
+ n -= 1
+
+ def main():
+ f(100, p1)
+ f(100, p2)
+ f(100, p3)
+
+ self.meta_interp(main, [])
+ # XXX check number of bridges
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit