Program: 149941
Project: 149941
Buggy source:
/** 
 * Meet two operands based on their positions in the operand lattice. For the purposes of doing dataflow analysis, OPT_Operands can be  thought of as forming a lattice. This function takes two operands and returns their meet (glb). We use <code>null</code> to stand for bottom (the meet of  the two operands is an illegal value).  For exmaple, meet(5.0, "hi") would evalaute to bottom. Meet returns op1 iff conservativelyApproximates(op1, op2): this is exploited in BC2IR to avoid doing redundant work.   <p> Unfortunately there is a fair amount of code duplication between   {@link #conservativelyApproximates} and {@link #meet}, but factoring out the common control logic is a non-trivial task. 
 * @param op1  the first operand to meet
 * @param op2  the second operand to meet
 * @param reg  the <code>OPT_Register</code> to use to create a new <code>OPT_RegisterOperand</code> if meeting op1 and op2 requires doing so.
 * @return the OPT_Operand that is the meet of op1 and op2.This function will return <code>null</code> when the meet evaluates to bottom.  It will return op1 when conservativelyApproximates(op1, op2) evaluates to <code>true</code>.
 * @author Dave Grove
 */
public static OPT_Operand meet(OPT_Operand op1,OPT_Operand op2,OPT_Register reg){
  if (op1 == op2) {
    if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
      if (op1 == null) {
        VM.sysWrite("String_Node_Str");
      }
 else {
        VM.sysWrite("String_Node_Str");
      }
    }
    return op1;
  }
  if (op1 == null) {
    if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
      VM.sysWrite("String_Node_Str");
    }
    return op1;
  }
  if (op2 == null) {
    if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
      VM.sysWrite("String_Node_Str");
    }
    return op2;
  }
  if (op1 instanceof OPT_NullConstantOperand) {
    if (op2 instanceof OPT_NullConstantOperand) {
      if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
        VM.sysWrite("String_Node_Str");
      }
      return op1;
    }
 else {
      VM_TypeReference type2=op2.getType();
      if (type2.isReferenceType()) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        return new OPT_RegisterOperand(reg,type2);
      }
 else {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        return null;
      }
    }
  }
  if (op1.isConstant()) {
    if (op1.similar(op2)) {
      if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
        VM.sysWrite("String_Node_Str");
      }
      return op1;
    }
 else {
      VM_TypeReference superType=OPT_ClassLoaderProxy.findCommonSuperclass(op1.getType(),op2.getType());
      if (superType == null) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        return null;
      }
 else {
        return new OPT_RegisterOperand(reg,superType);
      }
    }
  }
  if (op1.isRegister()) {
    OPT_RegisterOperand rop1=op1.asRegister();
    VM_TypeReference type1=rop1.type;
    if (op2.isRegister()) {
      OPT_RegisterOperand rop2=op2.asRegister();
      VM_TypeReference type2=rop2.type;
      if (type1 == type2) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        if (rop1.hasLessConservativeFlags(rop2)) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          OPT_RegisterOperand res=new OPT_RegisterOperand(reg,type1,rop1.getFlags());
          if (rop1.scratchObject instanceof OPT_Operand && rop2.scratchObject instanceof OPT_Operand && (((OPT_Operand)rop1.scratchObject).similar(((OPT_Operand)rop2.scratchObject)))) {
            res.scratchObject=rop1.scratchObject;
          }
          res.meetInheritableFlags(rop2);
          return res;
        }
 else         if (OPT_BC2IR.hasLessConservativeGuard(rop1,rop2)) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return new OPT_RegisterOperand(reg,type1,rop1.getFlags());
        }
 else {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return op1;
        }
      }
 else       if (compatiblePrimitives(type1,type2) || OPT_ClassLoaderProxy.includesType(type1,type2) == OPT_Constants.YES) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        if (rop1.isPreciseType() || rop1.hasLessConservativeFlags(rop2)) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          OPT_RegisterOperand res=new OPT_RegisterOperand(reg,type1,rop1.getFlags());
          res.meetInheritableFlags(rop2);
          res.clearPreciseType();
          if (rop1.scratchObject instanceof OPT_Operand && rop2.scratchObject instanceof OPT_Operand && (((OPT_Operand)rop1.scratchObject).similar(((OPT_Operand)rop2.scratchObject)))) {
            res.scratchObject=rop1.scratchObject;
          }
          return res;
        }
 else         if (OPT_BC2IR.hasLessConservativeGuard(rop1,rop2)) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return new OPT_RegisterOperand(reg,type1,rop1.getFlags());
        }
 else {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return op1;
        }
      }
 else {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str" + type1 + "String_Node_Str"+ type2+ "String_Node_Str");
        }
        VM_TypeReference resType=OPT_ClassLoaderProxy.findCommonSuperclass(type1,type2);
        if (resType == null) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return null;
        }
 else {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          OPT_RegisterOperand res=new OPT_RegisterOperand(reg,resType,rop1.getFlags());
          res.meetInheritableFlags(rop2);
          res.clearPreciseType();
          res.clearDeclaredType();
          if (rop1.scratchObject instanceof OPT_Operand && rop2.scratchObject instanceof OPT_Operand && (((OPT_Operand)rop1.scratchObject).similar(((OPT_Operand)rop2.scratchObject)))) {
            res.scratchObject=rop1.scratchObject;
          }
          return res;
        }
      }
    }
 else {
      if (op2 instanceof OPT_BC2IR.ReturnAddressOperand || op2 == OPT_BC2IR.DUMMY) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        return null;
      }
      VM_TypeReference type2=op2.getType();
      if (type1 == type2 || compatiblePrimitives(type1,type2) || (OPT_ClassLoaderProxy.includesType(type1,type2) == OPT_Constants.YES)) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        OPT_RegisterOperand res=rop1;
        if (res.isPreciseType() && type1 != type2) {
          res=res.copyU2U();
          res.clearPreciseType();
        }
        if ((rop1.scratchObject instanceof OPT_Operand) && ((type2 == VM_TypeReference.NULL_TYPE) || (type2.isIntLikeType() && op2.asIntConstant().value == 0) || (type2.isWordType() && op2.asAddressConstant().value.isZero())|| (type2.isLongType() && op2.asLongConstant().value == 0L))) {
          res=res.copyU2U();
          res.scratchObject=null;
        }
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          if (res == rop1) {
            VM.sysWrite("String_Node_Str");
          }
 else {
            VM.sysWrite("String_Node_Str");
          }
        }
        return res;
      }
 else {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str" + type1 + "String_Node_Str"+ type2+ "String_Node_Str");
        }
        VM_TypeReference resType=OPT_ClassLoaderProxy.findCommonSuperclass(type1,type2);
        if (resType == null) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return null;
        }
 else {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return new OPT_RegisterOperand(reg,resType);
        }
      }
    }
  }
  if (op1.similar(op2)) {
    if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
      VM.sysWrite("String_Node_Str");
    }
    return op1;
  }
 else {
    if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
      VM.sysWrite("String_Node_Str");
    }
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Meet two operands based on their positions in the operand lattice. For the purposes of doing dataflow analysis, OPT_Operands can be  thought of as forming a lattice. This function takes two operands and returns their meet (glb). We use <code>null</code> to stand for bottom (the meet of  the two operands is an illegal value).  For exmaple, meet(5.0, "hi") would evalaute to bottom. Meet returns op1 iff conservativelyApproximates(op1, op2): this is exploited in BC2IR to avoid doing redundant work.   <p> Unfortunately there is a fair amount of code duplication between   {@link #conservativelyApproximates} and {@link #meet}, but factoring out the common control logic is a non-trivial task. 
 * @param op1  the first operand to meet
 * @param op2  the second operand to meet
 * @param reg  the <code>OPT_Register</code> to use to create a new <code>OPT_RegisterOperand</code> if meeting op1 and op2 requires doing so.
 * @return the OPT_Operand that is the meet of op1 and op2.This function will return <code>null</code> when the meet evaluates to bottom.  It will return op1 when conservativelyApproximates(op1, op2) evaluates to <code>true</code>.
 * @author Dave Grove
 */
public static OPT_Operand meet(OPT_Operand op1,OPT_Operand op2,OPT_Register reg){
  if (op1 == op2) {
    if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
      if (op1 == null) {
        VM.sysWrite("String_Node_Str");
      }
 else {
        VM.sysWrite("String_Node_Str");
      }
    }
    return op1;
  }
  if (op1 == null) {
    if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
      VM.sysWrite("String_Node_Str");
    }
    return op1;
  }
  if (op2 == null) {
    if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
      VM.sysWrite("String_Node_Str");
    }
    return op2;
  }
  if (op1 instanceof OPT_NullConstantOperand) {
    if (op2 instanceof OPT_NullConstantOperand) {
      if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
        VM.sysWrite("String_Node_Str");
      }
      return op1;
    }
 else {
      if (op2 instanceof OPT_BC2IR.ReturnAddressOperand || op2 == OPT_BC2IR.DUMMY) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        return null;
      }
      VM_TypeReference type2=op2.getType();
      if (type2.isReferenceType()) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        return new OPT_RegisterOperand(reg,type2);
      }
 else {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        return null;
      }
    }
  }
  if (op1.isConstant()) {
    if (op1.similar(op2)) {
      if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
        VM.sysWrite("String_Node_Str");
      }
      return op1;
    }
 else {
      VM_TypeReference superType=OPT_ClassLoaderProxy.findCommonSuperclass(op1.getType(),op2.getType());
      if (superType == null) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        return null;
      }
 else {
        return new OPT_RegisterOperand(reg,superType);
      }
    }
  }
  if (op1.isRegister()) {
    OPT_RegisterOperand rop1=op1.asRegister();
    VM_TypeReference type1=rop1.type;
    if (op2.isRegister()) {
      OPT_RegisterOperand rop2=op2.asRegister();
      VM_TypeReference type2=rop2.type;
      if (type1 == type2) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        if (rop1.hasLessConservativeFlags(rop2)) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          OPT_RegisterOperand res=new OPT_RegisterOperand(reg,type1,rop1.getFlags());
          if (rop1.scratchObject instanceof OPT_Operand && rop2.scratchObject instanceof OPT_Operand && (((OPT_Operand)rop1.scratchObject).similar(((OPT_Operand)rop2.scratchObject)))) {
            res.scratchObject=rop1.scratchObject;
          }
          res.meetInheritableFlags(rop2);
          return res;
        }
 else         if (OPT_BC2IR.hasLessConservativeGuard(rop1,rop2)) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return new OPT_RegisterOperand(reg,type1,rop1.getFlags());
        }
 else {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return op1;
        }
      }
 else       if (compatiblePrimitives(type1,type2) || OPT_ClassLoaderProxy.includesType(type1,type2) == OPT_Constants.YES) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        if (rop1.isPreciseType() || rop1.hasLessConservativeFlags(rop2)) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          OPT_RegisterOperand res=new OPT_RegisterOperand(reg,type1,rop1.getFlags());
          res.meetInheritableFlags(rop2);
          res.clearPreciseType();
          if (rop1.scratchObject instanceof OPT_Operand && rop2.scratchObject instanceof OPT_Operand && (((OPT_Operand)rop1.scratchObject).similar(((OPT_Operand)rop2.scratchObject)))) {
            res.scratchObject=rop1.scratchObject;
          }
          return res;
        }
 else         if (OPT_BC2IR.hasLessConservativeGuard(rop1,rop2)) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return new OPT_RegisterOperand(reg,type1,rop1.getFlags());
        }
 else {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return op1;
        }
      }
 else {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str" + type1 + "String_Node_Str"+ type2+ "String_Node_Str");
        }
        VM_TypeReference resType=OPT_ClassLoaderProxy.findCommonSuperclass(type1,type2);
        if (resType == null) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return null;
        }
 else {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          OPT_RegisterOperand res=new OPT_RegisterOperand(reg,resType,rop1.getFlags());
          res.meetInheritableFlags(rop2);
          res.clearPreciseType();
          res.clearDeclaredType();
          if (rop1.scratchObject instanceof OPT_Operand && rop2.scratchObject instanceof OPT_Operand && (((OPT_Operand)rop1.scratchObject).similar(((OPT_Operand)rop2.scratchObject)))) {
            res.scratchObject=rop1.scratchObject;
          }
          return res;
        }
      }
    }
 else {
      if (op2 instanceof OPT_BC2IR.ReturnAddressOperand || op2 == OPT_BC2IR.DUMMY) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        return null;
      }
      VM_TypeReference type2=op2.getType();
      if (type1 == type2 || compatiblePrimitives(type1,type2) || (OPT_ClassLoaderProxy.includesType(type1,type2) == OPT_Constants.YES)) {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str");
        }
        OPT_RegisterOperand res=rop1;
        if (res.isPreciseType() && type1 != type2) {
          res=res.copyU2U();
          res.clearPreciseType();
        }
        if ((rop1.scratchObject instanceof OPT_Operand) && ((type2 == VM_TypeReference.NULL_TYPE) || (type2.isIntLikeType() && op2.asIntConstant().value == 0) || (type2.isWordType() && op2.asAddressConstant().value.isZero())|| (type2.isLongType() && op2.asLongConstant().value == 0L))) {
          res=res.copyU2U();
          res.scratchObject=null;
        }
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          if (res == rop1) {
            VM.sysWrite("String_Node_Str");
          }
 else {
            VM.sysWrite("String_Node_Str");
          }
        }
        return res;
      }
 else {
        if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
          VM.sysWrite("String_Node_Str" + type1 + "String_Node_Str"+ type2+ "String_Node_Str");
        }
        VM_TypeReference resType=OPT_ClassLoaderProxy.findCommonSuperclass(type1,type2);
        if (resType == null) {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return null;
        }
 else {
          if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
            VM.sysWrite("String_Node_Str");
          }
          return new OPT_RegisterOperand(reg,resType);
        }
      }
    }
  }
  if (op1.similar(op2)) {
    if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
      VM.sysWrite("String_Node_Str");
    }
    return op1;
  }
 else {
    if (OPT_IRGenOptions.DBG_OPERAND_LATTICE) {
      VM.sysWrite("String_Node_Str");
    }
    return null;
  }
}