[dmd-internals] Fixing forward ref bugs for good

Brad Roberts braddr at puremagic.com
Tue Sep 13 16:58:32 PDT 2011


On Tue, 13 Sep 2011, Walter Bright wrote:

> Don, just so you know, I've been thinking for a while about transitioning from
> doing the semantic pass in order to doing it completely "on demand". In other
> words, try to semantic a declaration. In the process, any declarations it
> depends on are semantic'd if not already, recursively.

Does the compiler have a graph of dependencies at all?  Easy to walk 
without requiring pausing to do work at each node?  One of the things 
we talked about _ages_ ago that I've had kicking around in the back of my 
head ever sense was breaking the problem into two pieces.

Piece 1: A process that finds nodes in the graph that have no 
unfulfilled dependencies and adds those to a queue to be analyzed.

Piece 2: a thread pool of workers that pull those work items and analyzes 
them.

As elements finish #2, #1 produces more work due to satisfied 
dependencies.  Repeat until no more work can be done.

if the graph is fully analyzed, success, if not fail due to true 
circularness.

For the time being, the worker probably needs to not really be using 
threads due to the over abundant use of global state.  But it could still 
be trivially iterated if those two pieces are actually reasonable to 
build.

If the global state issues can be resolved (and I'm only aware of a few 
myself, but I'm sure there's more out there), parallel semantic analysis 
would be a nice speed boost.



More information about the dmd-internals mailing list