Program: 149777
Project: 149777
Buggy source:
/** 
 * Identify candidate blocks by using a very simplistic algorithm. <ul> <li> Find all blocks that end in a test that is statically known to be likely to create a common case trace. For example, blocks that end in IG_METHOD_TEST, IG_CLASS_TEST and IG_PATCH_POINT. Note that these tests also have the property that it is correct (but less desirable) to execute the off branch when the test would have selected the on branch. <li> If such a block has a control flow predecessor that is marked as infrequent, and if the block is relatively small, then it is almost certainly profitable to duplicate the block and transfer the infrequent predecessor to go to the cloned block.  This has the effect of freeing the common-case path from the pollution of the infrequently executed block. Therefore we identify the block as a splitting candidate. </ul>
 */
private void simpleCandidateSearch(IR ir){
  for (BasicBlockEnumeration e=ir.getBasicBlocks(); e.hasMoreElements(); ) {
    BasicBlock cand=e.next();
    if (cand.isExceptionHandlerBasicBlock())     continue;
    Instruction candTest=getCandidateTest(cand);
    if (candTest == null)     continue;
    BasicBlock coldPrev=findColdPrev(cand);
    if (coldPrev == null)     continue;
    if (tooBig(cand))     continue;
    BasicBlock coldSucc=findColdSucc(cand,candTest);
    if (DEBUG) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite("String_Node_Str" + candTest + "String_Node_Str");
      VM.sysWrite("String_Node_Str" + coldPrev + "String_Node_Str");
      VM.sysWrite("String_Node_Str" + coldSucc + "String_Node_Str");
      cand.printExtended();
    }
    pushCandidate(cand,coldPrev,coldSucc,candTest);
  }
}

Fixed version (ground truth):
/** 
 * Identify candidate blocks by using a very simplistic algorithm. <ul> <li> Find all blocks that end in a test that is statically known to be likely to create a common case trace. For example, blocks that end in IG_METHOD_TEST, IG_CLASS_TEST and IG_PATCH_POINT. Note that these tests also have the property that it is correct (but less desirable) to execute the off branch when the test would have selected the on branch. <li> If such a block has a control flow predecessor that is marked as infrequent, and if the block is relatively small, then it is almost certainly profitable to duplicate the block and transfer the infrequent predecessor to go to the cloned block.  This has the effect of freeing the common-case path from the pollution of the infrequently executed block. Therefore we identify the block as a splitting candidate. </ul>
 */
private void simpleCandidateSearch(IR ir){
  for (BasicBlockEnumeration e=ir.getBasicBlocks(); e.hasMoreElements(); ) {
    BasicBlock cand=e.next();
    if (cand.isExceptionHandlerBasicBlock())     continue;
    Instruction candTest=getCandidateTest(cand);
    if (candTest == null)     continue;
    BasicBlock coldPrev=findColdPrev(cand);
    if (coldPrev == null)     continue;
    if (tooBig(cand))     continue;
    BasicBlock coldSucc=findColdSucc(cand,candTest);
    if (containsOSRPoint(coldSucc))     continue;
    if (DEBUG) {
      VM.sysWrite("String_Node_Str");
      VM.sysWrite("String_Node_Str" + candTest + "String_Node_Str");
      VM.sysWrite("String_Node_Str" + coldPrev + "String_Node_Str");
      VM.sysWrite("String_Node_Str" + coldSucc + "String_Node_Str");
      cand.printExtended();
    }
    pushCandidate(cand,coldPrev,coldSucc,candTest);
  }
}