Java Code Examples for com.sun.tools.javac.comp.Infer.GraphSolver.InferenceGraph.Node#mergeWith()

The following examples show how to use com.sun.tools.javac.comp.Infer.GraphSolver.InferenceGraph.Node#mergeWith() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Infer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes(Map<Type, Set<Type>> stuckDeps) {
    //add nodes
    nodes = new ArrayList<Node>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        Set<Type> optDepsByNode = stuckDeps.get(i);
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(DependencyKind.BOUND, n_j);
            }
            if (optDepsByNode != null && optDepsByNode.contains(j)) {
                //update i's stuck dependencies
                n_i.addDependency(DependencyKind.STUCK, n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<Node>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 2
Source File: Infer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes(Map<Type, Set<Type>> stuckDeps) {
    //add nodes
    nodes = new ArrayList<Node>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        Set<Type> optDepsByNode = stuckDeps.get(i);
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(DependencyKind.BOUND, n_j);
            }
            if (optDepsByNode != null && optDepsByNode.contains(j)) {
                //update i's stuck dependencies
                n_i.addDependency(DependencyKind.STUCK, n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<Node>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 3
Source File: Infer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes(Map<Type, Set<Type>> stuckDeps) {
    //add nodes
    nodes = new ArrayList<Node>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        Set<Type> optDepsByNode = stuckDeps.get(i);
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(DependencyKind.BOUND, n_j);
            }
            if (optDepsByNode != null && optDepsByNode.contains(j)) {
                //update i's stuck dependencies
                n_i.addDependency(DependencyKind.STUCK, n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<Node>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 4
Source File: Infer.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes() {
    //add nodes
    nodes = new ArrayList<>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            // don't compare a variable to itself
            if (i != j) {
                UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
                if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                    //update i's bound dependencies
                    n_i.addDependency(n_j);
                }
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 5
Source File: Infer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes(Map<Type, Set<Type>> stuckDeps) {
    //add nodes
    nodes = new ArrayList<Node>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        Set<Type> optDepsByNode = stuckDeps.get(i);
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(DependencyKind.BOUND, n_j);
            }
            if (optDepsByNode != null && optDepsByNode.contains(j)) {
                //update i's stuck dependencies
                n_i.addDependency(DependencyKind.STUCK, n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<Node>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 6
Source File: Infer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes() {
    //add nodes
    nodes = new ArrayList<>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 7
Source File: Infer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes(Map<Type, Set<Type>> stuckDeps) {
    //add nodes
    nodes = new ArrayList<Node>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        Set<Type> optDepsByNode = stuckDeps.get(i);
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(DependencyKind.BOUND, n_j);
            }
            if (optDepsByNode != null && optDepsByNode.contains(j)) {
                //update i's stuck dependencies
                n_i.addDependency(DependencyKind.STUCK, n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<Node>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 8
Source File: Infer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes(Map<Type, Set<Type>> stuckDeps) {
    //add nodes
    nodes = new ArrayList<Node>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        Set<Type> optDepsByNode = stuckDeps.get(i);
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asFree(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(DependencyKind.BOUND, n_j);
            }
            if (optDepsByNode != null && optDepsByNode.contains(j)) {
                //update i's stuck dependencies
                n_i.addDependency(DependencyKind.STUCK, n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<Node>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}
 
Example 9
Source File: Infer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the graph nodes. First a simple node is created for every inference
 * variables to be solved. Then Tarjan is used to found all connected components
 * in the graph. For each component containing more than one node, a super node is
 * created, effectively replacing the original cyclic nodes.
 */
void initNodes(Map<Type, Set<Type>> stuckDeps) {
    //add nodes
    nodes = new ArrayList<Node>();
    for (Type t : inferenceContext.restvars()) {
        nodes.add(new Node(t));
    }
    //add dependencies
    for (Node n_i : nodes) {
        Type i = n_i.data.first();
        Set<Type> optDepsByNode = stuckDeps.get(i);
        for (Node n_j : nodes) {
            Type j = n_j.data.first();
            UndetVar uv_i = (UndetVar)inferenceContext.asFree(i);
            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
                //update i's bound dependencies
                n_i.addDependency(DependencyKind.BOUND, n_j);
            }
            if (optDepsByNode != null && optDepsByNode.contains(j)) {
                //update i's stuck dependencies
                n_i.addDependency(DependencyKind.STUCK, n_j);
            }
        }
    }
    //merge cyclic nodes
    ArrayList<Node> acyclicNodes = new ArrayList<Node>();
    for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
        if (conSubGraph.length() > 1) {
            Node root = conSubGraph.head;
            root.mergeWith(conSubGraph.tail);
            for (Node n : conSubGraph) {
                notifyUpdate(n, root);
            }
        }
        acyclicNodes.add(conSubGraph.head);
    }
    nodes = acyclicNodes;
}