Browse Source

test and fix for 166084: istore incorrectly optimized

tags/Root_verification
aclement 17 years ago
parent
commit
f1520e89e3

+ 14
- 17
bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableInstruction.java View File

/** /**
* Abstract super class for instructions dealing with local variables. * Abstract super class for instructions dealing with local variables.
* *
* @version $Id: LocalVariableInstruction.java,v 1.4 2004/11/22 08:31:27 aclement Exp $
* @version $Id: LocalVariableInstruction.java,v 1.5 2006/11/29 13:43:01 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/ */
public abstract class LocalVariableInstruction extends Instruction public abstract class LocalVariableInstruction extends Instruction
{ {
if(wide) { if(wide) {
n = bytes.readUnsignedShort(); n = bytes.readUnsignedShort();
length = 4;
} else if(((opcode >= Constants.ILOAD) && } else if(((opcode >= Constants.ILOAD) &&
(opcode <= Constants.ALOAD)) || (opcode <= Constants.ALOAD)) ||
((opcode >= Constants.ISTORE) && ((opcode >= Constants.ISTORE) &&
(opcode <= Constants.ASTORE))) { (opcode <= Constants.ASTORE))) {
n = bytes.readUnsignedByte(); n = bytes.readUnsignedByte();
length = 2;
} else if(opcode <= Constants.ALOAD_3) { // compact load instruction such as ILOAD_2 } else if(opcode <= Constants.ALOAD_3) { // compact load instruction such as ILOAD_2
n = (opcode - Constants.ILOAD_0) % 4; n = (opcode - Constants.ILOAD_0) % 4;
length = 1;
} else { // Assert ISTORE_0 <= tag <= ASTORE_3 } else { // Assert ISTORE_0 <= tag <= ASTORE_3
n = (opcode - Constants.ISTORE_0) % 4; n = (opcode - Constants.ISTORE_0) % 4;
length = 1;
} }
workOutLength();
} }
private void workOutLength() {
if(n >= 0 && n <= 3) { // Use more compact instruction xLOAD_n
opcode = (short)(c_tag + n);
length = 1;
} else {
opcode = canon_tag;
if(wide()) length = 4;
else length = 2;
}
}


/** /**
* @return local variable index referred by this instruction. * @return local variable index referred by this instruction.
throw new ClassGenException("Illegal value: " + n); throw new ClassGenException("Illegal value: " + n);


this.n = n; this.n = n;

if(n >= 0 && n <= 3) { // Use more compact instruction xLOAD_n
opcode = (short)(c_tag + n);
length = 1;
} else {
opcode = canon_tag;
if(wide()) // Need WIDE prefix ?
length = 4;
else
length = 2;
}
workOutLength();
} }


/** @return canonical tag for instruction, e.g., ALOAD for ALOAD_0 /** @return canonical tag for instruction, e.g., ALOAD for ALOAD_0

Loading…
Cancel
Save