I removed constants denoting _QUICK bytecodes as valid bytecode can not contain them. To catch possible bugs with passing invalid opcode I also replaced extra, opcodeCount and stackChange arrays by functions with switch statements that throws IllegalArgumentException on bad opcode. It also has an advantage of reducing class file size due to lack of support in JVM for efficient array initialization.

This commit is contained in:
igor%mir2.org 2002-12-22 02:42:40 +00:00
Родитель 49148f941b
Коммит 89e660e85e
2 изменённых файлов: 678 добавлений и 817 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -412,11 +412,11 @@ public class ClassFileWriter {
if (DEBUGCODE)
System.out.println("Add " + Integer.toHexString(theOpCode & 0xFF));
if (DEBUG) {
if (ByteCode.opcodeCount[theOpCode & 0xFF] != 0)
throw new RuntimeException("Expected operands");
if (ByteCode.opcodeCount(theOpCode) != 0)
throw new RuntimeException("Unexpected operands");
}
addToCodeBuffer(theOpCode);
itsStackTop += ByteCode.stackChange[theOpCode & 0xFF];
itsStackTop += ByteCode.stackChange(theOpCode);
if (DEBUGSTACK) {
System.out.println("After " + Integer.toHexString(theOpCode & 0xFF) + " stack = " + itsStackTop);
}
@ -436,7 +436,7 @@ public class ClassFileWriter {
public void add(byte theOpCode, int theOperand) {
if (DEBUGCODE)
System.out.println("Add " + Integer.toHexString(theOpCode & 0xFF) + ", " + Integer.toHexString(theOperand) );
itsStackTop += ByteCode.stackChange[theOpCode & 0xFF];
itsStackTop += ByteCode.stackChange(theOpCode);
if (DEBUGSTACK) {
System.out.println("After " + Integer.toHexString(theOpCode & 0xFF) + " stack = " + itsStackTop);
}
@ -652,7 +652,7 @@ public class ClassFileWriter {
System.out.println("Add " + Integer.toHexString(theOpCode & 0xFF)
+ ", " + Integer.toHexString(theOperand1)
+ ", " + Integer.toHexString(theOperand2));
itsStackTop += ByteCode.stackChange[theOpCode & 0xFF];
itsStackTop += ByteCode.stackChange(theOpCode);
if (DEBUGSTACK) {
System.out.println("After " + Integer.toHexString(theOpCode & 0xFF) + " stack = " + itsStackTop);
}
@ -708,7 +708,7 @@ public class ClassFileWriter {
if (DEBUGCODE)
System.out.println("Add " + Integer.toHexString(theOpCode & 0xFF)
+ ", " + className);
itsStackTop += ByteCode.stackChange[theOpCode & 0xFF];
itsStackTop += ByteCode.stackChange(theOpCode);
if (DEBUGSTACK) {
System.out.println("After " + Integer.toHexString(theOpCode & 0xFF) + " stack = " + itsStackTop);
}
@ -741,7 +741,7 @@ public class ClassFileWriter {
if (DEBUGCODE)
System.out.println("Add " + Integer.toHexString(theOpCode & 0xFF)
+ ", " + className + ", " + fieldName + ", " + fieldType);
itsStackTop += ByteCode.stackChange[theOpCode & 0xFF];
itsStackTop += ByteCode.stackChange(theOpCode);
if (DEBUG) {
if (itsStackTop < 0)
throw new RuntimeException("After " + Integer.toHexString(theOpCode & 0xFF) + " Stack underflow");
@ -781,7 +781,7 @@ public class ClassFileWriter {
+ ", " + className + ", " + methodName + ", " + parametersType + ", " + returnType);
int parameterInfo = sizeOfParameters(parametersType);
itsStackTop -= (parameterInfo & 0xFFFF);
itsStackTop += ByteCode.stackChange[theOpCode & 0xFF]; // adjusts for 'this'
itsStackTop += ByteCode.stackChange(theOpCode); // adjusts for 'this'
if (DEBUG) {
if (itsStackTop < 0)
throw new RuntimeException("After " + Integer.toHexString(theOpCode & 0xFF) + " Stack underflow");