def build_specialized_graph(self, graph, key, nodelist): graph2 = copygraph(graph) virtualframe = VirtualFrame(graph2.startblock, 0, nodelist) graphbuilder = GraphBuilder(self, graph2) specblock = graphbuilder.start_from_virtualframe(virtualframe) specgraph = graph2 specgraph.name += '_mallocv' specgraph.startblock = specblock self.specialized_graphs[key] = ('call', specgraph) try: graphbuilder.propagate_specializations() except ForcedInline, e: if self.verbose: log.mallocv('%s inlined: %s' % (graph.name, e)) self.specialized_graphs[key] = ('inline', None)
def logresult(self, op, msg, exc=None): # only for nice log outputs if self.verbose: if exc is None: exc = '' else: exc = ': %s' % (exc,) chain = [] while True: chain.append(str(op.result)) if op.opname != 'direct_call': break fobj = op.args[0].value._obj op = self.inline_and_remove[fobj.graph] log.mallocv('%s %s%s' % ('->'.join(chain), msg, exc)) elif exc is None: log.dot()
def logresult(self, op, msg, exc=None): # only for nice log outputs if self.verbose: if exc is None: exc = '' else: exc = ': %s' % (exc, ) chain = [] while True: chain.append(str(op.result)) if op.opname != 'direct_call': break fobj = op.args[0].value._obj op = self.inline_and_remove[fobj.graph] log.mallocv('%s %s%s' % ('->'.join(chain), msg, exc)) elif exc is None: log.dot()
def report_result(self, progress): if progress: log.mallocv('removed %d mallocs so far' % self.count_virtualized) else: log.mallocv('done')
virtualframe = VirtualFrame(graph2.startblock, 0, nodelist) graphbuilder = GraphBuilder(self, graph2) specblock = graphbuilder.start_from_virtualframe(virtualframe) specgraph = graph2 specgraph.name += '_mallocv' specgraph.startblock = specblock self.specialized_graphs[key] = ('call', specgraph) try: graphbuilder.propagate_specializations() except ForcedInline, e: if self.verbose: log.mallocv('%s inlined: %s' % (graph.name, e)) self.specialized_graphs[key] = ('inline', None) except CannotVirtualize, e: if self.verbose: log.mallocv('%s failing: %s' % (graph.name, e)) self.specialized_graphs[key] = ('fail', None) else: self.graphbuilders[specgraph] = graphbuilder self.specgraphorigin[specgraph] = graph, nodelist self.graphs.append(specgraph) class GraphBuilder(object): def __init__(self, mallocv, graph): self.mallocv = mallocv self.graph = graph self.specialized_blocks = {} self.pending_specializations = []
virtualframe = VirtualFrame(graph2.startblock, 0, nodelist) graphbuilder = GraphBuilder(self, graph2) specblock = graphbuilder.start_from_virtualframe(virtualframe) specgraph = graph2 specgraph.name += "_mallocv" specgraph.startblock = specblock self.specialized_graphs[key] = ("call", specgraph) try: graphbuilder.propagate_specializations() except ForcedInline, e: if self.verbose: log.mallocv("%s inlined: %s" % (graph.name, e)) self.specialized_graphs[key] = ("inline", None) except CannotVirtualize, e: if self.verbose: log.mallocv("%s failing: %s" % (graph.name, e)) self.specialized_graphs[key] = ("fail", None) else: self.graphbuilders[specgraph] = graphbuilder self.specgraphorigin[specgraph] = graph, nodelist self.graphs.append(specgraph) class GraphBuilder(object): def __init__(self, mallocv, graph): self.mallocv = mallocv self.graph = graph self.specialized_blocks = {} self.pending_specializations = [] def initialize_from_old_builder(self, oldbuilder):
virtualframe = VirtualFrame(graph2.startblock, 0, nodelist) graphbuilder = GraphBuilder(self, graph2) specblock = graphbuilder.start_from_virtualframe(virtualframe) specgraph = graph2 specgraph.name += '_mallocv' specgraph.startblock = specblock self.specialized_graphs[key] = ('call', specgraph) try: graphbuilder.propagate_specializations() except ForcedInline, e: if self.verbose: log.mallocv('%s inlined: %s' % (graph.name, e)) self.specialized_graphs[key] = ('inline', None) except CannotVirtualize, e: if self.verbose: log.mallocv('%s failing: %s' % (graph.name, e)) self.specialized_graphs[key] = ('fail', None) else: self.graphbuilders[specgraph] = graphbuilder self.specgraphorigin[specgraph] = graph, nodelist self.graphs.append(specgraph) class GraphBuilder(object): def __init__(self, mallocv, graph): self.mallocv = mallocv self.graph = graph self.specialized_blocks = {} self.pending_specializations = [] def initialize_from_old_builder(self, oldbuilder):