Esempio n. 1
0
File: all.py Progetto: enyst/plexnet
def inline_malloc_removal_phase(config, translator, graphs, inline_threshold,
                                inline_heuristic,
                                call_count_pred=None):

    type_system = translator.rtyper.type_system.name
    # inline functions in each other
    if inline_threshold:
        log.inlining("phase with threshold factor: %s" % inline_threshold)
        log.inlining("heuristic: %s.%s" % (inline_heuristic.__module__,
                                           inline_heuristic.__name__))

        inline.auto_inline_graphs(translator, graphs, inline_threshold,
                                  heuristic=inline_heuristic,
                                  call_count_pred=call_count_pred)

        if config.print_statistics:
            print "after inlining:"
            print_statistics(translator.graphs[0], translator)

    # vaporize mallocs
    if config.mallocs:
        log.malloc("starting malloc removal")
        remove_mallocs(translator, graphs, type_system)

        if config.print_statistics:
            print "after malloc removal:"
            print_statistics(translator.graphs[0], translator)    
Esempio n. 2
0
def inline_malloc_removal_phase(config,
                                translator,
                                graphs,
                                inline_threshold,
                                inline_heuristic,
                                call_count_pred=None):

    type_system = translator.rtyper.type_system.name
    # inline functions in each other
    if inline_threshold:
        log.inlining("phase with threshold factor: %s" % inline_threshold)
        log.inlining("heuristic: %s.%s" %
                     (inline_heuristic.__module__, inline_heuristic.__name__))

        inline.auto_inline_graphs(translator,
                                  graphs,
                                  inline_threshold,
                                  heuristic=inline_heuristic,
                                  call_count_pred=call_count_pred)

        if config.print_statistics:
            print "after inlining:"
            print_statistics(translator.graphs[0], translator)

    # vaporize mallocs
    if config.mallocs:
        log.malloc("starting malloc removal")
        remove_mallocs(translator, graphs, type_system)

        if config.print_statistics:
            print "after malloc removal:"
            print_statistics(translator.graphs[0], translator)
Esempio n. 3
0
def remove_mallocs(translator, graphs=None, type_system="lltypesystem"):
    if graphs is None:
        graphs = translator.graphs
    tot = 0
    for graph in graphs:
        count = remove_simple_mallocs(graph, type_system=type_system, verbose=translator.config.translation.verbose)
        if count:
            # remove typical leftovers from malloc removal
            removenoops.remove_same_as(graph)
            simplify.eliminate_empty_blocks(graph)
            simplify.transform_dead_op_vars(graph, translator)
            tot += count
    log.malloc("removed %d simple mallocs in total" % tot)
    return tot
Esempio n. 4
0
 def remove_simple_mallocs(self, graph):
     """Iteratively remove (inline) the mallocs that can be simplified away."""
     tot = 0
     while True:
         count = self.remove_mallocs_once(graph)
         if count:
             if self.verbose:
                 log.malloc('%d simple mallocs removed in %r' % (count, graph.name))
             else:
                 log.dot()
             tot += count
         else:
             break
     return tot
Esempio n. 5
0
 def remove_simple_mallocs(self, graph):
     """Iteratively remove (inline) the mallocs that can be simplified away."""
     tot = 0
     while True:
         count = self.remove_mallocs_once(graph)
         if count:
             if self.verbose:
                 log.malloc('%d simple mallocs removed in %r' %
                            (count, graph.name))
             else:
                 log.dot()
             tot += count
         else:
             break
     return tot
Esempio n. 6
0
def remove_mallocs(translator, graphs=None, type_system="lltypesystem"):
    if graphs is None:
        graphs = translator.graphs
    tot = 0
    for graph in graphs:
        count = remove_simple_mallocs(
            graph,
            type_system=type_system,
            verbose=translator.config.translation.verbose)
        if count:
            # remove typical leftovers from malloc removal
            removenoops.remove_same_as(graph)
            simplify.eliminate_empty_blocks(graph)
            simplify.transform_dead_op_vars(graph, translator)
            tot += count
    log.malloc("removed %d simple mallocs in total" % tot)
    return tot