Graphity for TypeScript 3.0.0
    Preparing search index...

    Variable ControlFlowConst

    ControlFlow: { dominanceFrontiers(dominators: Dominators): Graph } = ...

    Relations of control flow that follow from Dominators, returned as graphs: the dominance frontiers and, from them, control dependence.

    A block is control dependent on another if that block decides whether it runs. Control dependence is the transposed graph of the dominance frontiers of the post-dominators. The post-dominators are the dominators of the transposed graph with the exits as entries. Here, for a method load with a for loop and an if in it, whose control flow cfg ends in the block exit:

    const postDominators = Dominators.of(BiAdjacentGraph.of(cfg).transposed(), exit);
    const controlDependence = BiAdjacentGraph.of(
    ControlFlow.dominanceFrontiers(postDominators),
    ).transposed();
    // header -> [header, body, next]: the loop condition decides whether they run
    // body -> [then]: the if decides whether then runs

    For the placement of phi-nodes, IteratedDominanceFrontier answers without building the dominance frontiers.

    Type Declaration

    • dominanceFrontiers: function
      • Returns the dominance frontiers as a graph: an edge n -> m for every node m in the dominance frontier of n.

        The dominance frontier of n holds the nodes where its dominance ends: m is in it if n dominates an in-node of m but does not strictly dominate m. A node can be in its own dominance frontier, as the header of a natural loop is, so the result can have self-loops. Nodes that the entries do not reach have empty dominance frontiers and are in none.

        Uses the algorithm of Cooper, Harvey and Kennedy. The result is computed anew on every call, not cached: keep it to use it more than once. It can grow quadratically with the node count, for example on deeply nested do-while loops.

        Time: O(nodeCount + edgeCount + frontierCount), where frontierCount is the number of edges of the result. Memory: 4 x (nodeCount + frontierCount) bytes for the result; while it runs, as much again and 8 x nodeCount bytes more.

        Parameters

        • dominators: Dominators

          the dominators of the control-flow graph

        Returns Graph

        the dominance frontiers, with the node IDs of the graph of dominators

        Error if the result would have more edges than a graph can have