Author: Lukas Diekmann <lukas.diekm...@uni-duesseldorf.de> Branch: Changeset: r50011:6d12edf0639c Date: 2011-11-30 15:14 +0100 http://bitbucket.org/pypy/pypy/changeset/6d12edf0639c/
Log: merge diff --git a/pypy/annotation/specialize.py b/pypy/annotation/specialize.py --- a/pypy/annotation/specialize.py +++ b/pypy/annotation/specialize.py @@ -36,9 +36,7 @@ newtup = SpaceOperation('newtuple', starargs, argscopy[-1]) newstartblock.operations.append(newtup) newstartblock.closeblock(Link(argscopy, graph.startblock)) - graph.startblock.isstartblock = False graph.startblock = newstartblock - newstartblock.isstartblock = True argnames = argnames + ['.star%d' % i for i in range(nb_extra_args)] graph.signature = Signature(argnames) # note that we can mostly ignore defaults: if nb_extra_args > 0, diff --git a/pypy/jit/metainterp/warmspot.py b/pypy/jit/metainterp/warmspot.py --- a/pypy/jit/metainterp/warmspot.py +++ b/pypy/jit/metainterp/warmspot.py @@ -255,10 +255,8 @@ s_binding = self.translator.annotator.binding jd._portal_args_s = [s_binding(v) for v in args] graph = copygraph(graph) - graph.startblock.isstartblock = False [jmpp] = find_jit_merge_points([graph]) graph.startblock = support.split_before_jit_merge_point(*jmpp) - graph.startblock.isstartblock = True # a crash in the following checkgraph() means that you forgot # to list some variable in greens=[] or reds=[] in JitDriver, # or that a jit_merge_point() takes a constant as an argument. diff --git a/pypy/objspace/flow/model.py b/pypy/objspace/flow/model.py --- a/pypy/objspace/flow/model.py +++ b/pypy/objspace/flow/model.py @@ -38,7 +38,6 @@ def __init__(self, name, startblock, return_var=None): self.name = name # function name (possibly mangled already) self.startblock = startblock - self.startblock.isstartblock = True # build default returnblock self.returnblock = Block([return_var or Variable()]) self.returnblock.operations = () @@ -171,11 +170,10 @@ class Block(object): - __slots__ = """isstartblock inputargs operations exitswitch + __slots__ = """inputargs operations exitswitch exits blockcolor""".split() def __init__(self, inputargs): - self.isstartblock = False self.inputargs = list(inputargs) # mixed list of variable/const XXX self.operations = [] # list of SpaceOperation(s) self.exitswitch = None # a variable or @@ -452,7 +450,6 @@ newblock.closeblock(*newlinks) newstartblock = blockmap[graph.startblock] - newstartblock.isstartblock = True newgraph = FunctionGraph(graph.name, newstartblock) newgraph.returnblock = blockmap[graph.returnblock] newgraph.exceptblock = blockmap[graph.exceptblock] @@ -490,7 +487,6 @@ for block in graph.iterblocks(): - assert bool(block.isstartblock) == (block is graph.startblock) assert type(block.exits) is tuple, ( "block.exits is a %s (closeblock() or recloseblock() missing?)" % (type(block.exits).__name__,)) diff --git a/pypy/objspace/flow/test/test_checkgraph.py b/pypy/objspace/flow/test/test_checkgraph.py --- a/pypy/objspace/flow/test/test_checkgraph.py +++ b/pypy/objspace/flow/test/test_checkgraph.py @@ -13,20 +13,6 @@ py.test.raises(AssertionError, checkgraph, g) -def test_nostartblock(): - g = FunctionGraph("g", Block([])) - g.startblock.closeblock(Link([Constant(1)], g.returnblock)) - g.startblock.isstartblock = False - py.test.raises(AssertionError, checkgraph, g) - -def test_twostartblocks(): - g = FunctionGraph("g", Block([])) - b = Block([]) - b.isstartblock = True - g.startblock.closeblock(Link([], b)) - b.closeblock(Link([Constant(1)], g.returnblock)) - py.test.raises(AssertionError, checkgraph, g) - def test_exitlessblocknotexitblock(): g = FunctionGraph("g", Block([])) py.test.raises(AssertionError, checkgraph, g) diff --git a/pypy/rpython/memory/gctransform/asmgcroot.py b/pypy/rpython/memory/gctransform/asmgcroot.py --- a/pypy/rpython/memory/gctransform/asmgcroot.py +++ b/pypy/rpython/memory/gctransform/asmgcroot.py @@ -92,7 +92,6 @@ # make a copy of the graph that will reload the values graph2 = copygraph(fnptr._obj.graph) block2 = graph2.startblock - block2.isstartblock = False block1 = Block([]) reloadedvars = [] for v, c_p in zip(block2.inputargs, sra): @@ -109,7 +108,6 @@ [w], v)) reloadedvars.append(v) block1.closeblock(Link(reloadedvars, block2)) - block1.isstartblock = True graph2.startblock = block1 FUNC2 = lltype.FuncType([], FUNC1.RESULT) fnptr2 = lltype.functionptr(FUNC2, diff --git a/pypy/rpython/memory/gctransform/test/test_transform.py b/pypy/rpython/memory/gctransform/test/test_transform.py --- a/pypy/rpython/memory/gctransform/test/test_transform.py +++ b/pypy/rpython/memory/gctransform/test/test_transform.py @@ -102,12 +102,12 @@ llops.genop("gc_pop_alive", [var]) -def checkblock(block, is_borrowed): +def checkblock(block, is_borrowed, is_start_block): if block.operations == (): # a return/exception block -- don't want to think about them # (even though the test passes for somewhat accidental reasons) return - if block.isstartblock: + if is_start_block: refs_in = 0 else: refs_in = len([v for v in block.inputargs if isinstance(v, Variable) @@ -167,7 +167,7 @@ if check: for graph, is_borrowed in graphs_borrowed.iteritems(): for block in graph.iterblocks(): - checkblock(block, is_borrowed) + checkblock(block, is_borrowed, block is graph.startblock) return t, transformer def getops(graph): diff --git a/pypy/rpython/memory/gctransform/transform.py b/pypy/rpython/memory/gctransform/transform.py --- a/pypy/rpython/memory/gctransform/transform.py +++ b/pypy/rpython/memory/gctransform/transform.py @@ -263,9 +263,7 @@ # still be empty (but let's check) if starts_with_empty_block(graph) and inserted_empty_startblock: old_startblock = graph.startblock - graph.startblock.isstartblock = False graph.startblock = graph.startblock.exits[0].target - graph.startblock.isstartblock = True checkgraph(graph) diff --git a/pypy/rpython/normalizecalls.py b/pypy/rpython/normalizecalls.py --- a/pypy/rpython/normalizecalls.py +++ b/pypy/rpython/normalizecalls.py @@ -116,8 +116,6 @@ v = Constant(default) outlist.append(v) newblock.closeblock(Link(outlist, oldblock)) - oldblock.isstartblock = False - newblock.isstartblock = True graph.startblock = newblock for i in range(len(newdefaults)-1,-1,-1): if newdefaults[i] is NODEFAULT: @@ -171,8 +169,6 @@ # prepare the output args of newblock and link outlist = inlist[:] newblock.closeblock(Link(outlist, oldblock)) - oldblock.isstartblock = False - newblock.isstartblock = True graph.startblock = newblock # finished checkgraph(graph) diff --git a/pypy/translator/backendopt/inline.py b/pypy/translator/backendopt/inline.py --- a/pypy/translator/backendopt/inline.py +++ b/pypy/translator/backendopt/inline.py @@ -453,7 +453,6 @@ #vars that need to be passed through the blocks of the inlined function linktoinlined = splitlink copiedstartblock = self.copy_block(self.graph_to_inline.startblock) - copiedstartblock.isstartblock = False #find args passed to startblock of inlined function passon_args = [] for arg in self.op.args[1:]: diff --git a/pypy/translator/backendopt/mallocv.py b/pypy/translator/backendopt/mallocv.py --- a/pypy/translator/backendopt/mallocv.py +++ b/pypy/translator/backendopt/mallocv.py @@ -391,7 +391,6 @@ virtualframe = VirtualFrame(graph2.startblock, 0, nodelist) graphbuilder = GraphBuilder(self, graph2) specblock = graphbuilder.start_from_virtualframe(virtualframe) - specblock.isstartblock = True specgraph = graph2 specgraph.name += '_mallocv' specgraph.startblock = specblock diff --git a/pypy/translator/backendopt/test/test_malloc.py b/pypy/translator/backendopt/test/test_malloc.py --- a/pypy/translator/backendopt/test/test_malloc.py +++ b/pypy/translator/backendopt/test/test_malloc.py @@ -50,7 +50,8 @@ # we do the loop ourselves instead of calling remove_simple_mallocs() while True: progress = remover.remove_mallocs_once(graph) - simplify.transform_dead_op_vars_in_blocks(list(graph.iterblocks())) + simplify.transform_dead_op_vars_in_blocks(list(graph.iterblocks()), + [graph]) if progress and option.view: t.view() if expected_result is not Ellipsis: diff --git a/pypy/translator/c/test/test_refcount.py b/pypy/translator/c/test/test_refcount.py --- a/pypy/translator/c/test/test_refcount.py +++ b/pypy/translator/c/test/test_refcount.py @@ -229,7 +229,6 @@ graph = t.buildflowgraph(g) assert graph.startblock.operations == [] graph.startblock = graph.startblock.exits[0].target - graph.startblock.isstartblock = True from pypy.objspace.flow.model import checkgraph checkgraph(graph) t._prebuilt_graphs[g] = graph diff --git a/pypy/translator/simplify.py b/pypy/translator/simplify.py --- a/pypy/translator/simplify.py +++ b/pypy/translator/simplify.py @@ -397,7 +397,8 @@ def transform_dead_op_vars(graph, translator=None): """Remove dead operations and variables that are passed over a link but not used in the target block. Input is a graph.""" - return transform_dead_op_vars_in_blocks(list(graph.iterblocks()), translator) + return transform_dead_op_vars_in_blocks(list(graph.iterblocks()), + [graph], translator) # the set of operations that can safely be removed # (they have no side effects, at least in R-Python) @@ -419,11 +420,19 @@ hasattr: True, } -def transform_dead_op_vars_in_blocks(blocks, translator=None): +def find_start_blocks(graphs): + start_blocks = set() + for graph in graphs: + start_blocks.add(graph.startblock) + return start_blocks + +def transform_dead_op_vars_in_blocks(blocks, graphs, translator=None): """Remove dead operations and variables that are passed over a link but not used in the target block. Input is a set of blocks""" read_vars = {} # set of variables really used variable_flow = {} # map {Var: list-of-Vars-it-depends-on} + set_of_blocks = set(blocks) + start_blocks = find_start_blocks(graphs) def canremove(op, block): if op.opname not in CanRemove: @@ -451,7 +460,7 @@ if block.exits: for link in block.exits: - if link.target not in blocks: + if link.target not in set_of_blocks: for arg, targetarg in zip(link.args, link.target.inputargs): read_vars[arg] = True read_vars[targetarg] = True @@ -465,7 +474,7 @@ read_vars[arg] = True # an input block's inputargs should not be modified, even if some # of the function's input arguments are not actually used - if block.isstartblock: + if block in start_blocks: for arg in block.inputargs: read_vars[arg] = True diff --git a/pypy/translator/transform.py b/pypy/translator/transform.py --- a/pypy/translator/transform.py +++ b/pypy/translator/transform.py @@ -115,7 +115,7 @@ # to kill dead (never-followed) links, # which can possibly remove more variables. from pypy.translator.simplify import transform_dead_op_vars_in_blocks - transform_dead_op_vars_in_blocks(block_subset) + transform_dead_op_vars_in_blocks(block_subset, self.translator.graphs) def transform_dead_code(self, block_subset): """Remove dead code: these are the blocks that are not annotated at all diff --git a/pypy/translator/unsimplify.py b/pypy/translator/unsimplify.py --- a/pypy/translator/unsimplify.py +++ b/pypy/translator/unsimplify.py @@ -42,9 +42,7 @@ vars = [copyvar(annotator, v) for v in graph.startblock.inputargs] newblock = Block(vars) newblock.closeblock(Link(vars, graph.startblock)) - graph.startblock.isstartblock = False graph.startblock = newblock - graph.startblock.isstartblock = True def starts_with_empty_block(graph): return (not graph.startblock.operations @@ -151,9 +149,7 @@ newop = SpaceOperation('direct_call', [c_initial_func], v_none) extrablock.operations = [newop] extrablock.closeblock(Link(args, entry_point.startblock)) - entry_point.startblock.isstartblock = False entry_point.startblock = extrablock - entry_point.startblock.isstartblock = True checkgraph(entry_point) def call_final_function(translator, final_func, annhelper=None): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit