Program: 149773
Project: 149773
Buggy source:
private static void getVariableValue(byte[] stack,Offset offset,byte[] types,BaselineCompiledMethod compiledMethod,boolean kind,ExecutionState state){
  int size=types.length;
  Offset vOffset=offset;
  for (int i=0; i < size; i++) {
    if (VM.TraceOnStackReplacement) {
      Word content=Magic.getWordAtOffset(stack,vOffset.minus(BYTES_IN_ADDRESS));
      VM.sysWrite("String_Node_Str",vOffset.minus(BYTES_IN_ADDRESS),"String_Node_Str");
      VM.sysWriteln(content);
    }
switch (types[i]) {
case VoidTypeCode:
      vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
    break;
case BooleanTypeCode:
case ByteTypeCode:
case ShortTypeCode:
case CharTypeCode:
case IntTypeCode:
case FloatTypeCode:
{
    int value=Magic.getIntAtOffset(stack,vOffset.minus(BYTES_IN_INT));
    vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
    byte tcode=(types[i] == FloatTypeCode) ? FLOAT : INT;
    state.add(new VariableElement(kind,i,tcode,value));
    break;
  }
case LongTypeCode:
case DoubleTypeCode:
{
  Offset memoff=(kind == LOCAL) ? vOffset.minus(BYTES_IN_DOUBLE) : VM.BuildFor64Addr ? vOffset : vOffset.minus(BYTES_IN_STACKSLOT);
  long value=Magic.getLongAtOffset(stack,memoff);
  byte tcode=(types[i] == LongTypeCode) ? LONG : DOUBLE;
  state.add(new VariableElement(kind,i,tcode,value));
  if (kind == LOCAL) {
    vOffset=vOffset.minus(2 * BYTES_IN_STACKSLOT);
    i++;
  }
 else {
    vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
  }
  break;
}
case ReturnAddressTypeCode:
{
VM.disableGC();
Address rowIP=Magic.objectAsAddress(stack).loadAddress(vOffset);
Offset ipOffset=compiledMethod.getInstructionOffset(rowIP);
VM.enableGC();
vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
if (VM.TraceOnStackReplacement) {
  Offset ipIndex=ipOffset.toWord().rsha(LG_INSTRUCTION_WIDTH).toOffset();
  VM.sysWrite("String_Node_Str",ipIndex,"String_Node_Str");
}
int bcIndex=compiledMethod.findBytecodeIndexForInstruction(ipOffset.plus(INSTRUCTION_WIDTH));
if (VM.TraceOnStackReplacement) {
  VM.sysWrite("String_Node_Str" + bcIndex + "String_Node_Str");
}
state.add(new VariableElement(kind,i,RET_ADDR,bcIndex));
break;
}
case ClassTypeCode:
case ArrayTypeCode:
{
VM.disableGC();
Object ref=Magic.getObjectAtOffset(stack,vOffset.minus(BYTES_IN_ADDRESS));
VM.enableGC();
vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
state.add(new VariableElement(kind,i,REF,ref));
break;
}
case WordTypeCode:
{
Word value=Magic.getWordAtOffset(stack,vOffset.minus(BYTES_IN_ADDRESS));
vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
state.add(new VariableElement(kind,i,WORD,value));
break;
}
default :
if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED);
break;
}
}
}

Fixed version (ground truth):
private static void getVariableValue(byte[] stack,Offset offset,byte[] types,BaselineCompiledMethod compiledMethod,boolean kind,ExecutionState state){
  int size=types.length;
  Offset vOffset=offset;
  for (int i=0; i < size; i++) {
    if (VM.TraceOnStackReplacement) {
      Word content=Magic.getWordAtOffset(stack,vOffset.minus(BYTES_IN_ADDRESS));
      VM.sysWrite("String_Node_Str",vOffset.minus(BYTES_IN_ADDRESS),"String_Node_Str");
      VM.sysWriteln(content);
      if ((types[i] == LongTypeCode) || (types[i] == DoubleTypeCode)) {
        content=Magic.getWordAtOffset(stack,vOffset.minus(2 * BYTES_IN_ADDRESS));
        VM.sysWrite("String_Node_Str",vOffset.minus(2 * BYTES_IN_ADDRESS),"String_Node_Str");
        VM.sysWriteln(content);
      }
    }
switch (types[i]) {
case VoidTypeCode:
      vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
    break;
case BooleanTypeCode:
case ByteTypeCode:
case ShortTypeCode:
case CharTypeCode:
case IntTypeCode:
case FloatTypeCode:
{
    int value=Magic.getIntAtOffset(stack,vOffset.minus(BYTES_IN_INT));
    vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
    byte tcode=(types[i] == FloatTypeCode) ? FLOAT : INT;
    state.add(new VariableElement(kind,i,tcode,value));
    break;
  }
case LongTypeCode:
case DoubleTypeCode:
{
  Offset memoff=(kind == LOCAL) ? vOffset.minus(BYTES_IN_DOUBLE) : VM.BuildFor64Addr ? vOffset : vOffset.minus(BYTES_IN_STACKSLOT);
  long value=Magic.getLongAtOffset(stack,memoff);
  byte tcode=(types[i] == LongTypeCode) ? LONG : DOUBLE;
  state.add(new VariableElement(kind,i,tcode,value));
  if (kind == LOCAL) {
    vOffset=vOffset.minus(2 * BYTES_IN_STACKSLOT);
    i++;
  }
 else {
    vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
  }
  break;
}
case ReturnAddressTypeCode:
{
VM.disableGC();
Address rowIP=Magic.objectAsAddress(stack).loadAddress(vOffset);
Offset ipOffset=compiledMethod.getInstructionOffset(rowIP);
VM.enableGC();
vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
if (VM.TraceOnStackReplacement) {
  Offset ipIndex=ipOffset.toWord().rsha(LG_INSTRUCTION_WIDTH).toOffset();
  VM.sysWrite("String_Node_Str",ipIndex,"String_Node_Str");
}
int bcIndex=compiledMethod.findBytecodeIndexForInstruction(ipOffset.plus(INSTRUCTION_WIDTH));
if (VM.TraceOnStackReplacement) {
  VM.sysWrite("String_Node_Str" + bcIndex + "String_Node_Str");
}
state.add(new VariableElement(kind,i,RET_ADDR,bcIndex));
break;
}
case ClassTypeCode:
case ArrayTypeCode:
{
VM.disableGC();
Object ref=Magic.getObjectAtOffset(stack,vOffset.minus(BYTES_IN_ADDRESS));
VM.enableGC();
vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
state.add(new VariableElement(kind,i,REF,ref));
break;
}
case WordTypeCode:
{
Word value=Magic.getWordAtOffset(stack,vOffset.minus(BYTES_IN_ADDRESS));
vOffset=vOffset.minus(BYTES_IN_STACKSLOT);
state.add(new VariableElement(kind,i,WORD,value));
break;
}
default :
if (VM.VerifyAssertions) VM._assert(VM.NOT_REACHED);
break;
}
}
}