Program: 186563
Project: 186563
Buggy source:
private void optimizeMethods(AnalysisManager analyses,ExecFrequencyProvider ecp,CandidateSelector selector,Set<MethodInfo> methods){
  Map<MethodInfo,MethodData> methodData=new HashMap<MethodInfo,MethodData>(methods.size());
  selector.clear();
  for (  MethodInfo method : methods) {
    if (method.isNative())     continue;
    method.getCode().compile();
    StacksizeAnalysis stacksize=analyses.getStacksizeAnalysis(method);
    int locals=method.getCode().getMaxLocals();
    for (    CodeOptimizer optimizer : optimizers) {
      Collection<Candidate> found;
      found=optimizer.findCandidates(method,analyses,stacksize,locals);
      selector.addCandidates(method,found);
      countCandidates+=found.size();
    }
    methodData.put(method,new MethodData(locals));
  }
  selector.sortCandidates(ecp);
  Set<MethodInfo> optimizedMethods=new HashSet<MethodInfo>();
  Set<MethodInfo> candidateChanges=new HashSet<MethodInfo>();
  Collection<Candidate> candidates=selector.selectNextCandidates(ecp);
  while (candidates != null) {
    optimizedMethods.clear();
    candidateChanges.clear();
    analyses.clearChangeSets();
    for (    Candidate c : candidates) {
      MethodInfo method=c.getMethod();
      StacksizeAnalysis stacksize=analyses.getStacksizeAnalysis(method);
      logger.info("String_Node_Str" + c.toString());
      if (!c.optimize(analyses,stacksize))       continue;
      countOptimized++;
      method.getCode().compile();
      stacksize.analyze(c.getStart(),c.getEnd());
      int locals=c.getMaxLocalsInRegion();
      List<Candidate> newCandidates=new ArrayList<Candidate>();
      for (      CodeOptimizer optimizer : optimizers) {
        Collection<Candidate> found;
        found=optimizer.findCandidates(method,analyses,stacksize,locals,c.getStart(),c.getEnd());
        newCandidates.addAll(found);
      }
      selector.onSuccessfulOptimize(c,newCandidates);
      countCandidates+=newCandidates.size();
      optimizedMethods.add(method);
    }
    candidateChanges.addAll(optimizedMethods);
    if (methods.size() > 1) {
      for (      MethodInfo method : optimizedMethods) {
        candidateChanges.addAll(appInfo.getCallGraph().getDirectInvokers(method));
      }
      candidateChanges.addAll(analyses.getMethodCacheAnalysis().getClassificationChangeSet());
    }
    Set<MethodInfo> changeSet=selector.updateChangeSet(ecp,optimizedMethods,candidateChanges);
    for (    MethodInfo method : candidateChanges) {
      if (!methodData.containsKey(method))       continue;
      selector.updateCandidates(method,ecp,analyses.getStacksizeAnalysis(method));
    }
    if (methods.size() == 1) {
      selector.sortCandidates(ecp,methods);
    }
 else {
      if (logger.isTraceEnabled()) {
        logger.trace("String_Node_Str" + changeSet.size());
      }
      selector.sortCandidates(ecp,changeSet);
    }
    candidates=selector.selectNextCandidates(ecp);
  }
}

Fixed version (ground truth):
private void optimizeMethods(AnalysisManager analyses,ExecFrequencyProvider ecp,CandidateSelector selector,Set<MethodInfo> methods){
  Map<MethodInfo,MethodData> methodData=new HashMap<MethodInfo,MethodData>(methods.size());
  selector.clear();
  if (maxSteps > 0 && countOptimized >= maxSteps) {
    return;
  }
  for (  MethodInfo method : methods) {
    if (method.isNative())     continue;
    method.getCode().compile();
    StacksizeAnalysis stacksize=analyses.getStacksizeAnalysis(method);
    int locals=method.getCode().getMaxLocals();
    for (    CodeOptimizer optimizer : optimizers) {
      Collection<Candidate> found;
      found=optimizer.findCandidates(method,analyses,stacksize,locals);
      selector.addCandidates(method,found);
      countCandidates+=found.size();
    }
    methodData.put(method,new MethodData(locals));
  }
  selector.sortCandidates(ecp);
  Set<MethodInfo> optimizedMethods=new HashSet<MethodInfo>();
  Set<MethodInfo> candidateChanges=new HashSet<MethodInfo>();
  Collection<Candidate> candidates=selector.selectNextCandidates(ecp);
  while (candidates != null) {
    optimizedMethods.clear();
    candidateChanges.clear();
    analyses.clearChangeSets();
    for (    Candidate c : candidates) {
      MethodInfo method=c.getMethod();
      StacksizeAnalysis stacksize=analyses.getStacksizeAnalysis(method);
      logger.info("String_Node_Str" + c.toString());
      if (!c.optimize(analyses,stacksize))       continue;
      countOptimized++;
      if (maxSteps > 0 && countOptimized >= maxSteps) {
        return;
      }
      method.getCode().compile();
      stacksize.analyze(c.getStart(),c.getEnd());
      int locals=c.getMaxLocalsInRegion();
      List<Candidate> newCandidates=new ArrayList<Candidate>();
      for (      CodeOptimizer optimizer : optimizers) {
        Collection<Candidate> found;
        found=optimizer.findCandidates(method,analyses,stacksize,locals,c.getStart(),c.getEnd());
        newCandidates.addAll(found);
      }
      selector.onSuccessfulOptimize(c,newCandidates);
      countCandidates+=newCandidates.size();
      optimizedMethods.add(method);
    }
    candidateChanges.addAll(optimizedMethods);
    if (methods.size() > 1) {
      for (      MethodInfo method : optimizedMethods) {
        candidateChanges.addAll(appInfo.getCallGraph().getDirectInvokers(method));
      }
      candidateChanges.addAll(analyses.getMethodCacheAnalysis().getClassificationChangeSet());
    }
    Set<MethodInfo> changeSet=selector.updateChangeSet(ecp,optimizedMethods,candidateChanges);
    for (    MethodInfo method : candidateChanges) {
      if (!methodData.containsKey(method))       continue;
      selector.updateCandidates(method,ecp,analyses.getStacksizeAnalysis(method));
    }
    if (methods.size() == 1) {
      selector.sortCandidates(ecp,methods);
    }
 else {
      if (logger.isTraceEnabled()) {
        logger.trace("String_Node_Str" + changeSet.size());
      }
      selector.sortCandidates(ecp,changeSet);
    }
    candidates=selector.selectNextCandidates(ecp);
  }
}