コード例 #1
0
 /**
  * Due to PI nodes and Moves, the initial label for a register may be another register. Fix up the
  * value graph for cases where the initial register label was not removed.
  */
 private void computeClosure() {
   for (Enumeration<GraphNode> e = enumerateVertices(); e.hasMoreElements(); ) {
     ValueGraphVertex v = (ValueGraphVertex) e.nextElement();
     if (v.getName() instanceof Register) {
       if (v.getLabel() instanceof Register) {
         if (v.getName() != v.getLabel()) {
           ValueGraphVertex v2 = getVertex(v.getLabel());
           if (VM.VerifyAssertions) {
             if (v2.getName() instanceof Register
                 && v2.getLabel() instanceof Register
                 && v2.getLabel() != v2.getName()) {
               VM._assert(VM.NOT_REACHED);
             }
           }
           v.copyVertex(v2);
         }
       }
     }
   }
 }
コード例 #2
0
 /**
  * Initialize the congruence classes, assuming that all nodes with the same label are congruent.
  */
 private void initialize() {
   // store a map from label -> congruenceClass
   HashMap<Object, GVCongruenceClass> labelMap = new HashMap<Object, GVCongruenceClass>(10);
   for (Enumeration<GraphNode> e = valueGraph.enumerateVertices(); e.hasMoreElements(); ) {
     ValueGraphVertex v = (ValueGraphVertex) e.nextElement();
     Object label = v.getLabel();
     GVCongruenceClass c = findOrCreateCongruenceClass(label, labelMap);
     // add this node to the congruence class
     c.addVertex(v);
     // set the value number for the node
     v.setValueNumber(c.getValueNumber());
   }
 }
コード例 #3
0
 /**
  * Does the current state of the algorithm optimistically assume that two nodes are congruent?
  * Note: this can return false even if the value numbers are currently the same.
  *
  * @param v1 first vertex
  * @param v2 second vertex
  * @return whether the notes are assumed to be congruent
  */
 private boolean checkCongruence(ValueGraphVertex v1, ValueGraphVertex v2) {
   if (v1 == v2) {
     return true;
   }
   // make sure the two nodes have the same label
   if (v1.getLabel() != v2.getLabel()) {
     return false;
   }
   // make sure that the operands match
   int arity = v1.getArity();
   for (int i = 0; i < arity; i++) {
     ValueGraphVertex target1 = v1.getTarget(i);
     ValueGraphVertex target2 = v2.getTarget(i);
     // if either target is null, then that particular control
     // flow path is never realized, so assume TOP
     if ((target1 == null) || (target2 == null)) {
       continue;
     }
     if (target1.getValueNumber() != target2.getValueNumber()) {
       return false;
     }
   }
   return true;
 }