Example #1
0
 def finish_rtype(self):
     rtyper = self.rtyper
     translator = rtyper.annotator.translator
     original_graph_count = len(translator.graphs)
     perform_normalizations(rtyper)
     for r in self.delayedreprs:
         r.set_setup_delayed(False)
     rtyper.call_all_setups()
     for p, repr, obj in self.delayedconsts:
         p._become(repr.convert_const(obj))
     rtyper.call_all_setups()
     for p, graph in self.delayedfuncs:
         self.newgraphs.add(graph)
         real_p = rtyper.getcallable(graph)
         REAL = lltype.typeOf(real_p).TO
         FUNCTYPE = lltype.typeOf(p).TO
         if isinstance(FUNCTYPE, lltype.ForwardReference):
             FUNCTYPE.become(REAL)
         assert FUNCTYPE == REAL
         p._become(real_p)
     rtyper.specialize_more_blocks()
     self.delayedreprs.clear()
     del self.delayedconsts[:]
     del self.delayedfuncs[:]
     for graph in translator.graphs[original_graph_count:]:
         self.newgraphs.add(graph)
Example #2
0
 def finish_rtype(self):
     rtyper = self.rtyper
     translator = rtyper.annotator.translator
     original_graph_count = len(translator.graphs)
     perform_normalizations(rtyper.annotator)
     for r in self.delayedreprs:
         r.set_setup_delayed(False)
     rtyper.call_all_setups()
     for p, repr, obj in self.delayedconsts:
         p._become(repr.convert_const(obj))
     rtyper.call_all_setups()
     for p, graph in self.delayedfuncs:
         self.newgraphs.add(graph)
         real_p = rtyper.getcallable(graph)
         REAL = lltype.typeOf(real_p).TO
         FUNCTYPE = lltype.typeOf(p).TO
         if isinstance(FUNCTYPE, lltype.ForwardReference):
             FUNCTYPE.become(REAL)
         assert FUNCTYPE == REAL
         p._become(real_p)
     rtyper.specialize_more_blocks()
     self.delayedreprs.clear()
     del self.delayedconsts[:]
     del self.delayedfuncs[:]
     for graph in translator.graphs[original_graph_count:]:
         self.newgraphs.add(graph)
Example #3
0
 def perform_normalizations(self, rtyper):
     """Prepare the annotator's internal data structures for rtyping
     with the specified type system.
     """
     # default implementation
     from rpython.rtyper.normalizecalls import perform_normalizations
     perform_normalizations(rtyper)
Example #4
0
 def simplify(self, block_subset=None, extra_passes=None):
     # Generic simplifications
     transform.transform_graph(self, block_subset=block_subset,
                               extra_passes=extra_passes)
     if block_subset is None:
         graphs = self.translator.graphs
     else:
         graphs = {}
         for block in block_subset:
             graph = self.annotated.get(block)
             if graph:
                 graphs[graph] = True
     for graph in graphs:
         simplify.eliminate_empty_blocks(graph)
     if block_subset is None:
         perform_normalizations(self)
Example #5
0
    def specialize(self, dont_simplify_again=False):
        """Main entry point: specialize all annotated blocks of the program."""
        # specialize depends on annotator simplifications
        assert dont_simplify_again in (False, True)  # safety check
        if not dont_simplify_again:
            self.annotator.simplify()

        # first make sure that all functions called in a group have exactly
        # the same signature, by hacking their flow graphs if needed
        perform_normalizations(self.annotator)
        self.exceptiondata.finish(self)

        # new blocks can be created as a result of specialize_block(), so
        # we need to be careful about the loop here.
        self.already_seen = {}
        self.specialize_more_blocks()
        if self.exceptiondata is not None:
            self.exceptiondata.make_helpers(self)
            self.specialize_more_blocks()  # for the helpers just made
Example #6
0
    def specialize(self, dont_simplify_again=False):
        """Main entry point: specialize all annotated blocks of the program."""
        # specialize depends on annotator simplifications
        assert dont_simplify_again in (False, True)  # safety check
        if not dont_simplify_again:
            self.annotator.simplify()

        # first make sure that all functions called in a group have exactly
        # the same signature, by hacking their flow graphs if needed
        perform_normalizations(self.annotator)
        self.exceptiondata.finish(self)

        # new blocks can be created as a result of specialize_block(), so
        # we need to be careful about the loop here.
        self.already_seen = {}
        self.specialize_more_blocks()
        if self.exceptiondata is not None:
            self.exceptiondata.make_helpers(self)
            self.specialize_more_blocks()   # for the helpers just made