Program: 186705
Project: 186705
Buggy source:
/** 
 * @param method the changed method
 * @param deltaBytes the number of bytes to add to the current code size
 * @return the number of cache miss cycles due to the code size change
 */
public long getDeltaCacheMissCosts(MethodInfo method,int deltaBytes){
  if (deltaBytes == 0)   return 0;
  if (analysisType == AnalysisType.ALWAYS_HIT)   return 0;
  WCETProcessorModel pm=analyses.getJCopter().getWCETProcessorModel();
  int size=method.getCode().getNumberOfBytes();
  int oldWords=MiscUtils.bytesToWords(size);
  int newWords=MiscUtils.bytesToWords(size + deltaBytes);
  int deltaBlocks=cache.requiredNumberOfBlocks(newWords) - cache.requiredNumberOfBlocks(oldWords);
  int newBlocks=getRequiredBlocks(method) + deltaBlocks;
  long costs=0;
  if (analysisType == AnalysisType.ALWAYS_MISS || cache.allFit(newBlocks)) {
    long oldCycles=pm.getMethodCacheMissPenalty(oldWords,true);
    long newCycles=pm.getMethodCacheMissPenalty(newWords,true);
    costs=analyses.getExecCountAnalysis().getExecCount(method) * (newCycles - oldCycles);
    oldCycles=pm.getMethodCacheMissPenalty(oldWords,false);
    newCycles=pm.getMethodCacheMissPenalty(newWords,false);
    for (    InvokeSite invokeSite : method.getCode().getInvokeSites()) {
      costs+=analyses.getExecCountAnalysis().getExecCount(invokeSite) * (newCycles - oldCycles);
    }
  }
  if (analysisType == AnalysisType.ALWAYS_MISS) {
    return costs;
  }
  Set<ExecutionContext> changes=findClassificationChanges(method,deltaBytes);
  long deltaCosts=0;
  for (  ExecutionContext node : changes) {
    for (    InvokeSite invokeSite : node.getMethodInfo().getCode().getInvokeSites()) {
      int sizeWords=0;
      for (      MethodInfo invokee : callGraph.findImplementations(node.getCallString().push(invokeSite))) {
        sizeWords=Math.max(sizeWords,invokee.getCode().getNumberOfWords());
      }
      long count=analyses.getExecCountAnalysis().getExecCount(node,invokeSite.getInstructionHandle());
      deltaCosts+=count * pm.getMethodCacheMissPenalty(sizeWords,true);
      deltaCosts+=count * pm.getMethodCacheMissPenalty(oldWords,false);
    }
  }
  if (deltaBytes > 0) {
    costs+=deltaCosts;
  }
 else {
    costs-=deltaCosts;
  }
  if (analysisType == AnalysisType.ALL_FIT_REGIONS) {
  }
  return costs;
}

Fixed version (ground truth):
/** 
 * @param method the changed method
 * @param deltaBytes the number of bytes to add to the current code size
 * @return the number of cache miss cycles due to the code size change
 */
public long getDeltaCacheMissCosts(MethodInfo method,int deltaBytes){
  if (deltaBytes == 0)   return 0;
  if (analysisType == AnalysisType.ALWAYS_HIT)   return 0;
  WCETProcessorModel pm=analyses.getJCopter().getWCETProcessorModel();
  int size=method.getCode().getNumberOfBytes();
  int oldWords=MiscUtils.bytesToWords(size);
  int newWords=MiscUtils.bytesToWords(size + deltaBytes);
  int deltaBlocks=cache.requiredNumberOfBlocks(newWords) - cache.requiredNumberOfBlocks(oldWords);
  int newBlocks=getRequiredBlocks(method) + deltaBlocks;
  long costs=0;
  if (analysisType == AnalysisType.ALWAYS_MISS || !cache.allFit(newBlocks)) {
    long oldCycles=pm.getMethodCacheMissPenalty(oldWords,true);
    long newCycles=pm.getMethodCacheMissPenalty(newWords,true);
    costs=analyses.getExecCountAnalysis().getExecCount(method) * (newCycles - oldCycles);
    oldCycles=pm.getMethodCacheMissPenalty(oldWords,false);
    newCycles=pm.getMethodCacheMissPenalty(newWords,false);
    for (    InvokeSite invokeSite : method.getCode().getInvokeSites()) {
      costs+=analyses.getExecCountAnalysis().getExecCount(invokeSite) * (newCycles - oldCycles);
    }
  }
  if (analysisType == AnalysisType.ALWAYS_MISS) {
    return costs;
  }
  Set<ExecutionContext> changes=findClassificationChanges(method,deltaBytes);
  long deltaCosts=0;
  for (  ExecutionContext node : changes) {
    for (    InvokeSite invokeSite : node.getMethodInfo().getCode().getInvokeSites()) {
      int sizeWords=0;
      for (      MethodInfo invokee : callGraph.findImplementations(node.getCallString().push(invokeSite))) {
        sizeWords=Math.max(sizeWords,invokee.getCode().getNumberOfWords());
      }
      long count=analyses.getExecCountAnalysis().getExecCount(node,invokeSite.getInstructionHandle());
      deltaCosts+=count * pm.getMethodCacheMissPenalty(sizeWords,true);
      deltaCosts+=count * pm.getMethodCacheMissPenalty(oldWords,false);
    }
  }
  if (deltaBytes > 0) {
    costs+=deltaCosts;
  }
 else {
    costs-=deltaCosts;
  }
  if (analysisType == AnalysisType.ALL_FIT_REGIONS) {
  }
  return costs;
}