public void WlRemove() { WorkList<int> w = new WorkList<int>(); w.Add(3); w.Add(2); Assert.IsFalse(w.IsEmpty); w.Remove(3); Assert.IsFalse(w.IsEmpty); w.Remove(2); Assert.IsTrue(w.IsEmpty); int x; Assert.IsFalse(w.GetWorkItem(out x)); }
public void WlRemove() { WorkList <int> w = new WorkList <int>(); w.Add(3); w.Add(2); Assert.IsFalse(w.IsEmpty); w.Remove(3); Assert.IsFalse(w.IsEmpty); w.Remove(2); Assert.IsTrue(w.IsEmpty); int x; Assert.IsFalse(w.GetWorkItem(out x)); }
/// <summary> /// Build the weakly connected component for a cluster by following /// both predecessors and successors in the graph. However, we never /// follow the predecessors of nodes that are marked directly called, /// and we never follow successors that are marked directly called /// (tail calls). /// </summary> /// <param name="node"></param> /// <param name="cluster"></param> /// <param name="wl"></param> private void BuildWCC( RtlBlock node, Cluster cluster, WorkList <RtlBlock> wl) { wl.Remove(node); cluster.Blocks.Add(node); foreach (var s in sr.ICFG.Successors(node)) { if (wl.Contains(s)) { // Only add if successor is not CALLed. if (!procedures.Contains(s.Address)) { BuildWCC(s, cluster, wl); } } } if (!procedures.Contains(node.Address)) { // Only backtrack through predecessors if the node // is not CALLed. foreach (var p in sr.ICFG.Predecessors(node)) { if (wl.Contains(p)) { BuildWCC(p, cluster, wl); } } } }
public List <Interval> BuildIntervals(DirectedGraph <StructureNode> graph, StructureNode entry) { if (graph == null) { throw new ArgumentNullException("graph"); } if (entry == null) { throw new ArgumentNullException("entry"); } var intervalsInGraph = new List <Interval>(); // The sequence of intervals in this graph var headers = new WorkList <StructureNode>(); // The sequence of interval header nodes var beenInH = new HashSet <StructureNode>(); // The set of nodes that have been in the above sequence at some stage headers.Add(entry); beenInH.Add(entry); StructureNode header; while (headers.GetWorkItem(out header)) { Interval newInt = new Interval(intervalID++, header); // Process each succesive node in the interval until no more nodes can be added to the interval. for (int i = 0; i < newInt.Nodes.Count; i++) { StructureNode curNode = newInt.Nodes[i]; foreach (StructureNode succ in graph.Successors(curNode)) { // Only further consider the current child if it isn't already in the interval if (!newInt.Nodes.Contains(succ)) { // If the current child has all its parents // inside the interval, then add it to the interval. Remove it from the header // sequence if it is on it. if (IsSubSetOf(graph.Predecessors(succ), newInt)) { newInt.AddNode(succ); headers.Remove(succ); } // Otherwise, add it to the header sequence if it hasn't already been in it. else if (!beenInH.Contains(succ)) { headers.Add(succ); beenInH.Add(succ); } } } } // Add the new interval to the sequence of intervals intervalsInGraph.Add(newInt); } return(intervalsInGraph); }
public void BuildIntervals(DerivedGraph derGraph) { if (derGraph == null) throw new ArgumentNullException("derGraph"); if (derGraph.Entry == null) throw new ArgumentException("cfg graph must be non-null.", "derGraph"); var intSeq = derGraph.Intervals; // The sequence of intervals in this graph var headerSeq = new WorkList<StructureNode>(); // The sequence of interval header nodes var beenInH = new List<StructureNode>(); // The set of nodes that have been in the above sequence at some stage headerSeq.Add(derGraph.Entry); beenInH.Add(derGraph.Entry); StructureNode header; while (headerSeq.GetWorkItem(out header)) { var newInt = new Interval(intervalID++, header); // Process each succesive node in the interval until no more nodes can be added to the interval. for (int i = 0; i < newInt.Nodes.Count; i++) { var curNode = newInt.Nodes[i]; // Process each child of the current node for (int j = 0; j < curNode.OutEdges.Count; j++) { var succ = curNode.OutEdges[j]; // Only further consider the current child if it isn't already in the interval if (!newInt.Nodes.Contains(succ)) { // If the current child has all its parents // inside the interval, then add it to the interval. Remove it from the header // sequence if it is on it. if (IsSubSetOf(succ.InEdges, newInt)) { newInt.AddNode(succ); headerSeq.Remove(succ); } // Otherwise, add it to the header sequence if it hasn't already been in it. else if (!beenInH.Contains(succ)) { headerSeq.Add(succ); beenInH.Add(succ); } } } } // Add the new interval to the sequence of intervals intSeq.Add(newInt); } }
/// <summary> 回收 </summary> public void Recycle(T _unit) { WorkList.Remove(_unit); if (_unit != null) { IdleList.Add(_unit); OnBeforeRecycle(_unit); IPoolable recyclable; if ((recyclable = _unit as IPoolable) != null) { recyclable.OnRecycled(); } OnAfterRecycle(_unit); } }
public List<Interval> BuildIntervals(DirectedGraph<StructureNode> graph, StructureNode entry) { if (graph == null) throw new ArgumentNullException("graph"); if (entry == null) throw new ArgumentNullException("entry"); var intervalsInGraph = new List<Interval>(); // The sequence of intervals in this graph var headers = new WorkList<StructureNode>(); // The sequence of interval header nodes var beenInH = new HashSet<StructureNode>(); // The set of nodes that have been in the above sequence at some stage headers.Add(entry); beenInH.Add(entry); StructureNode header; while (headers.GetWorkItem(out header)) { Interval newInt = new Interval(intervalID++, header); // Process each succesive node in the interval until no more nodes can be added to the interval. for (int i = 0; i < newInt.Nodes.Count; i++) { StructureNode curNode = newInt.Nodes[i]; foreach (StructureNode succ in graph.Successors(curNode)) { // Only further consider the current child if it isn't already in the interval if (!newInt.Nodes.Contains(succ)) { // If the current child has all its parents // inside the interval, then add it to the interval. Remove it from the header // sequence if it is on it. if (IsSubSetOf(graph.Predecessors(succ), newInt)) { newInt.AddNode(succ); headers.Remove(succ); } // Otherwise, add it to the header sequence if it hasn't already been in it. else if (!beenInH.Contains(succ)) { headers.Add(succ); beenInH.Add(succ); } } } } // Add the new interval to the sequence of intervals intervalsInGraph.Add(newInt); } return intervalsInGraph; }
public void BuildIntervals(DerivedGraph derGraph) { if (derGraph == null) { throw new ArgumentNullException("derGraph"); } if (derGraph.Entry == null) { throw new ArgumentException("cfg graph must be non-null.", "derGraph"); } var intSeq = derGraph.Intervals; // The sequence of intervals in this graph var headerSeq = new WorkList <StructureNode>(); // The sequence of interval header nodes var beenInH = new List <StructureNode>(); // The set of nodes that have been in the above sequence at some stage headerSeq.Add(derGraph.Entry); beenInH.Add(derGraph.Entry); StructureNode header; while (headerSeq.GetWorkItem(out header)) { var newInt = new Interval(intervalID++, header); // Process each succesive node in the interval until no more nodes can be added to the interval. for (int i = 0; i < newInt.Nodes.Count; i++) { var curNode = newInt.Nodes[i]; // Process each child of the current node for (int j = 0; j < curNode.OutEdges.Count; j++) { var succ = curNode.OutEdges[j]; // Only further consider the current child if it isn't already in the interval if (!newInt.Nodes.Contains(succ)) { // If the current child has all its parents // inside the interval, then add it to the interval. Remove it from the header // sequence if it is on it. if (IsSubSetOf(succ.InEdges, newInt)) { newInt.AddNode(succ); headerSeq.Remove(succ); } // Otherwise, add it to the header sequence if it hasn't already been in it. else if (!beenInH.Contains(succ)) { headerSeq.Add(succ); beenInH.Add(succ); } } } } // Add the new interval to the sequence of intervals intSeq.Add(newInt); } }