diff options
author | 2017-09-06 09:00:41 +0200 | |
---|---|---|
committer | 2017-09-06 09:00:41 +0200 | |
commit | dabc4a161df786a09c3d521a2ece7de01791a5ef (patch) | |
tree | ec7621df133c1819681e340ab22e09e66f41ab62 /rpython/jit/codewriter | |
parent | make sure that get_strategy_from_list_objects does not have random effects :-( (diff) | |
download | pypy-dabc4a161df786a09c3d521a2ece7de01791a5ef.tar.gz pypy-dabc4a161df786a09c3d521a2ece7de01791a5ef.tar.bz2 pypy-dabc4a161df786a09c3d521a2ece7de01791a5ef.zip |
improve error message: include name of calling graph, not just op
Diffstat (limited to 'rpython/jit/codewriter')
-rw-r--r-- | rpython/jit/codewriter/call.py | 29 | ||||
-rw-r--r-- | rpython/jit/codewriter/jtransform.py | 14 | ||||
-rw-r--r-- | rpython/jit/codewriter/test/test_call.py | 10 | ||||
-rw-r--r-- | rpython/jit/codewriter/test/test_flatten.py | 2 | ||||
-rw-r--r-- | rpython/jit/codewriter/test/test_jtransform.py | 4 | ||||
-rw-r--r-- | rpython/jit/codewriter/test/test_list.py | 2 |
6 files changed, 34 insertions, 27 deletions
diff --git a/rpython/jit/codewriter/call.py b/rpython/jit/codewriter/call.py index 014c5f46f2..39d44d774e 100644 --- a/rpython/jit/codewriter/call.py +++ b/rpython/jit/codewriter/call.py @@ -186,7 +186,8 @@ class CallControl(object): return (fnaddr, calldescr) def getcalldescr(self, op, oopspecindex=EffectInfo.OS_NONE, - extraeffect=None, extradescr=None): + extraeffect=None, extradescr=None, + calling_graph=None): """Return the calldescr that describes all calls done by 'op'. This returns a calldescr that we can put in the corresponding call operation in the calling jitcode. It gets an effectinfo @@ -202,13 +203,13 @@ class CallControl(object): ARGS = FUNC.ARGS if NON_VOID_ARGS != [T for T in ARGS if T is not lltype.Void]: raise Exception( - "in operation %r: calling a function with signature %r, " + "operation %r in %s: calling a function with signature %r, " "but passing actual arguments (ignoring voids) of types %r" - % (op, FUNC, NON_VOID_ARGS)) + % (op, calling_graph, FUNC, NON_VOID_ARGS)) if RESULT != FUNC.RESULT: raise Exception( - "in operation %r: calling a function with signature %r, " - "but the actual return type is %r" % (op, FUNC, RESULT)) + "%r in %s: calling a function with signature %r, " + "but the actual return type is %r" % (op, calling_graph, FUNC, RESULT)) # ok # get the 'elidable' and 'loopinvariant' flags from the function object elidable = False @@ -217,7 +218,7 @@ class CallControl(object): if op.opname == "direct_call": funcobj = op.args[0].value._obj assert getattr(funcobj, 'calling_conv', 'c') == 'c', ( - "%r: getcalldescr() with a non-default call ABI" % (op,)) + "%r in %s: getcalldescr() with a non-default call ABI" % (op, calling_graph)) func = getattr(funcobj, '_callable', None) elidable = getattr(func, "_elidable_function_", False) loopinvariant = getattr(func, "_jit_loop_invariant_", False) @@ -245,11 +246,11 @@ class CallControl(object): if not error: continue raise Exception( - "%r is an indirect call to a family of functions " + "%r in %s is an indirect call to a family of functions " "(or methods) that includes %r. However, the latter " "is marked %r. You need to use an indirection: replace " "it with a non-marked function/method which calls the " - "marked function." % (op, graph, error)) + "marked function." % (op, calling_graph, graph, error)) # build the extraeffect random_effects = self.randomeffects_analyzer.analyze(op) if random_effects: @@ -278,21 +279,21 @@ class CallControl(object): if loopinvariant: if extraeffect != EffectInfo.EF_LOOPINVARIANT: raise Exception( - "in operation %r: this calls a _jit_loop_invariant_ function," + "operation %r in %s: this calls a _jit_loop_invariant_ function," " but this contradicts other sources (e.g. it can have random" - " effects): EF=%s" % (op, extraeffect)) + " effects): EF=%s" % (op, calling_graph, extraeffect)) if elidable: if extraeffect not in (EffectInfo.EF_ELIDABLE_CANNOT_RAISE, EffectInfo.EF_ELIDABLE_OR_MEMORYERROR, EffectInfo.EF_ELIDABLE_CAN_RAISE): raise Exception( - "in operation %r: this calls an elidable function," + "operation %r in %s: this calls an elidable function," " but this contradicts other sources (e.g. it can have random" - " effects): EF=%s" % (op, extraeffect)) + " effects): EF=%s" % (op, calling_graph, extraeffect)) elif RESULT is lltype.Void: raise Exception( - "in operation %r: this calls an elidable function " - "but the function has no result" % (op, )) + "operation %r in %s: this calls an elidable function " + "but the function has no result" % (op, calling_graph)) # effectinfo = effectinfo_from_writeanalyze( self.readwrite_analyzer.analyze(op, self.seen_rw), self.cpu, diff --git a/rpython/jit/codewriter/jtransform.py b/rpython/jit/codewriter/jtransform.py index e99fc54d05..a30329a8e3 100644 --- a/rpython/jit/codewriter/jtransform.py +++ b/rpython/jit/codewriter/jtransform.py @@ -64,6 +64,7 @@ class Transformer(object): self.cpu = cpu self.callcontrol = callcontrol self.portal_jd = portal_jd # non-None only for the portal graph(s) + self.graph = None def transform(self, graph): self.graph = graph @@ -424,7 +425,8 @@ class Transformer(object): of 'residual_call_xxx' are the function to call, and its calldescr.""" calldescr = self.callcontrol.getcalldescr(op, oopspecindex=oopspecindex, extraeffect=extraeffect, - extradescr=extradescr) + extradescr=extradescr, + calling_graph=self.graph) op1 = self.rewrite_call(op, 'residual_call', [op.args[0]] + extraargs, calldescr=calldescr) if may_call_jitcodes or self.callcontrol.calldescr_canraise(calldescr): @@ -1613,7 +1615,9 @@ class Transformer(object): if len(op.args) > 4 + 2 or have_floats: raise Exception("Conditional call does not support floats or more than 4 arguments") callop = SpaceOperation('direct_call', op.args[1:], op.result) - calldescr = self.callcontrol.getcalldescr(callop) + calldescr = self.callcontrol.getcalldescr( + callop, + calling_graph=self.graph) assert not calldescr.get_extra_info().check_forces_virtual_or_virtualizable() op1 = self.rewrite_call(op, rewritten_opname, op.args[:2], args=op.args[2:], @@ -1924,7 +1928,8 @@ class Transformer(object): extradescr=None): calldescr = self.callcontrol.getcalldescr(op, oopspecindex, extraeffect, - extradescr=extradescr) + extradescr=extradescr, + calling_graph=self.graph) if extraeffect is not None: assert (is_test_calldescr(calldescr) # for tests or calldescr.get_extra_info().extraeffect == extraeffect) @@ -1954,7 +1959,8 @@ class Transformer(object): [c_func] + [varoftype(T) for T in argtypes], varoftype(resulttype)) calldescr = self.callcontrol.getcalldescr(op, oopspecindex, - effectinfo) + effectinfo, + calling_graph=self.graph) if isinstance(c_func.value, str): # in tests only func = c_func.value else: diff --git a/rpython/jit/codewriter/test/test_call.py b/rpython/jit/codewriter/test/test_call.py index cf28300704..23a804f52c 100644 --- a/rpython/jit/codewriter/test/test_call.py +++ b/rpython/jit/codewriter/test/test_call.py @@ -329,19 +329,19 @@ def test_raise_elidable_no_result(): @jit.elidable def f1(n, m): l.append(n) - def f(n, m): + def fancy_graph_name(n, m): f1(n, m) return n + m - rtyper = support.annotate(f, [7, 9]) + rtyper = support.annotate(fancy_graph_name, [7, 9]) jitdriver_sd = FakeJitDriverSD(rtyper.annotator.translator.graphs[0]) cc = CallControl(LLGraphCPU(rtyper), jitdrivers_sd=[jitdriver_sd]) res = cc.find_all_graphs(FakePolicy()) - [f_graph] = [x for x in res if x.func is f] + [f_graph] = [x for x in res if x.func is fancy_graph_name] call_op = f_graph.startblock.operations[0] assert call_op.opname == 'direct_call' - with py.test.raises(Exception): - call_descr = cc.getcalldescr(call_op) + x = py.test.raises(Exception, cc.getcalldescr, call_op, calling_graph=f_graph) + assert "fancy_graph_name" in str(x.value) def test_can_or_cannot_collect(): from rpython.jit.backend.llgraph.runner import LLGraphCPU diff --git a/rpython/jit/codewriter/test/test_flatten.py b/rpython/jit/codewriter/test/test_flatten.py index 648c1b1931..faa5f8e561 100644 --- a/rpython/jit/codewriter/test/test_flatten.py +++ b/rpython/jit/codewriter/test/test_flatten.py @@ -73,7 +73,7 @@ class FakeCallControl: def guess_call_kind(self, op): return 'residual' def getcalldescr(self, op, oopspecindex=EffectInfo.OS_NONE, - extraeffect=None, extradescr=None): + extraeffect=None, extradescr=None, calling_graph=None): try: name = op.args[0].value._obj._name if 'cannot_raise' in name or name.startswith('cast_'): diff --git a/rpython/jit/codewriter/test/test_jtransform.py b/rpython/jit/codewriter/test/test_jtransform.py index d41ba474b5..eb38275395 100644 --- a/rpython/jit/codewriter/test/test_jtransform.py +++ b/rpython/jit/codewriter/test/test_jtransform.py @@ -48,7 +48,7 @@ class FakeResidualCallControl: def guess_call_kind(self, op): return 'residual' def getcalldescr(self, op, oopspecindex=None, extraeffect=None, - extradescr=None): + extradescr=None, calling_graph=None): return 'calldescr' def calldescr_canraise(self, calldescr): return True @@ -106,7 +106,7 @@ class FakeBuiltinCallControl: def guess_call_kind(self, op): return 'builtin' def getcalldescr(self, op, oopspecindex=None, extraeffect=None, - extradescr=None): + extradescr=None, calling_graph=None): assert oopspecindex is not None # in this test EI = effectinfo.EffectInfo if oopspecindex != EI.OS_ARRAYCOPY: diff --git a/rpython/jit/codewriter/test/test_list.py b/rpython/jit/codewriter/test/test_list.py index 41d9204302..b4b1e8b0e4 100644 --- a/rpython/jit/codewriter/test/test_list.py +++ b/rpython/jit/codewriter/test/test_list.py @@ -39,7 +39,7 @@ class FakeCPU: class FakeCallControl: class getcalldescr(AbstractDescr): def __init__(self, op, oopspecindex=0, extraeffect=None, - extradescr=None): + extradescr=None, calling_graph=None): self.op = op self.oopspecindex = oopspecindex def __repr__(self): |