GraphDependencies and completion

Andreas Lundblad andreas.lundblad at oracle.com
Fri Oct 16 19:03:28 UTC 2015


On Fri, Oct 16, 2015 at 09:55:54AM -0700, Vicente-Arturo Romero-Zaldivar wrote:
> Hi,
> 
> On 10/16/2015 03:24 AM, Andreas Lundblad wrote:
> >Widening the audience of this discussion. Jan and Maurizio, forgive the overlap with previous email.
> >
> >I've looked into the Dependencies class and tried to figure out how it can be adjusted to cover the requirements of sjavac (with the help of Jan and Maurizio). A summary follows.
> >
> >Currently the Dependencies mechanism works as follows: When a symbol is about to be completed, it's pushed onto a stack and when completion finishes the stack is popped.
> 
> Where is this stack living? According to this description this
> algorithm is trying to find a topological sort of the dependency
> graph but it seems like its logic is not explicit but interleaved
> with the completion process. Probably this is the only way to do it.
> Can you provide some links to the current code implementing this?

The stack lives in Dependencies.java (in the GraphDependencies class to be specific).

In a sense symbols are completed in a topological sorted order I guess, but note that completion of A may trigger completion of B which in turn may trigger completion of A again. This would mean that A depends on B and B depends on A. That is, the resulting dependency relation is not a topological sorted sequence, but an arbitrary graph.

You are right that the algorithm is interleaved with the completion process. Previously I analyzed the trees explicitly after the compilation, but it was more code and more cases to cover. Dependencies.java was already there for another purpose, so I switched to that which simplified the code a lot. As discovered later it introduced this regression.

-- Andreas


More information about the compiler-dev mailing list