Graphity for TypeScript 3.0.0
    Preparing search index...

    The iterated dominance frontiers of a control-flow graph, which tell where SSA (static single assignment) form places phi-nodes.

    In SSA form, every assignment to a variable creates a new version of it, and a phi-node merges the versions where paths of control flow meet. The phi-nodes of a variable go into the iterated dominance frontier of the blocks that assign it: the dominance frontier of these blocks, then the dominance frontier of the result, and so on until nothing new is added. A compiler asks this once per variable, so IteratedDominanceFrontier.of prepares the queries once per control-flow graph, and IteratedDominanceFrontier.frontierOf answers them. Here, for the loop variable i of a method load, whose control flow cfg has the blocks entry and next:

    const dominators = Dominators.of(BiAdjacentGraph.of(cfg), entry);
    const phis = IteratedDominanceFrontier.of(dominators);
    // i is assigned in entry (i = 0) and in next (i++)
    const phiBlocks = phis.frontierOf([entry, next]);
    // phiBlocks: [1] - header

    Uses the algorithm of Sreedhar and Gao. A query walks the subtrees of the dominator tree below the nodes it is given and the nodes it adds, so its cost depends on the part of the graph it explores, not on the whole graph. It never builds the dominance frontiers themselves, which can grow quadratically with the node count; ControlFlow.dominanceFrontiers returns them as a graph.

    Instances are immutable.

    Memory: 16 x nodeCount bytes, plus the Dominators it was built from, which stay reachable as long as it is held.

    Index
    • Returns the iterated dominance frontier of nodes, in ascending order.

      The result can contain given nodes, such as the header of a natural loop, which is in its own dominance frontier. Nodes that the entries do not reach are ignored, and so are duplicates.

      Time: O(number of nodes + e + (s + k) log(s + k)), where e is the number of nodes and edges the query explores, at most nodeCount + edgeCount; s is the number of distinct given nodes that the entries reach, and k the size of the result. Memory: 4 x k bytes for the result; while it runs, up to about 60 bytes per node the query explores, and nothing sized by the whole graph.

      Parameters

      • nodes: IntList

        node IDs in 0..nodeCount-1, such as the blocks that assign a variable

      Returns SortedIntView

      the iterated dominance frontier

      RangeError if a node is out of range

      Error if the query explores more than about 8 x 10^8 nodes