def test_auto_inlining_small_call_big_call_count(self): def leaf(n): total = 0 i = 0 while i < n: total += i if total > 100: raise OverflowError i += 1 return total def g(n): return leaf(n) def f(n): try: return g(n) except OverflowError: return -1 eval_func, t = self.check_auto_inlining(f, [int], multiplier=10, call_count_check=True) f_graph = graphof(t, f) assert len(collect_called_graphs(f_graph, t)) == 0 result = eval_func([10]) assert result == 45 result = eval_func([15]) assert result == -1
def check_access_directly_sanity(self, graphs): from pypy.translator.backendopt.inline import collect_called_graphs jit_graphs = set(graphs) for graph in collect_called_graphs(self.translator.graphs[0], self.translator): if graph in jit_graphs: continue assert not getattr(graph, 'access_directly', False)
def test_list_iteration(self): def f(): tot = 0 for item in [1, 2, 3]: tot += item return tot eval_func, t = self.check_auto_inlining(f, [], checkvirtual=True) f_graph = graphof(t, f) called_graphs = collect_called_graphs(f_graph, t, include_oosend=False) assert len(called_graphs) == 0 result = eval_func([]) assert result == 6
def test_list_iteration(self): def f(): tot = 0 for item in [1,2,3]: tot += item return tot eval_func, t = self.check_auto_inlining(f, [], checkvirtual=True) f_graph = graphof(t, f) called_graphs = collect_called_graphs(f_graph, t, include_oosend=False) assert len(called_graphs) == 0 result = eval_func([]) assert result == 6