8341510: Optimize StackMapGenerator::processFieldInstructions

Reviewed-by: liach
This commit is contained in:
Shaojin Wen 2024-10-05 01:21:25 +00:00
parent b42fbf43df
commit f8db3a831b
4 changed files with 7 additions and 13 deletions

View File

@ -50,7 +50,7 @@ public sealed interface ConstantDynamicEntry
* {@return a symbolic descriptor for the dynamic constant's type}
*/
default ClassDesc typeSymbol() {
return Util.fieldTypeSymbol(nameAndType());
return Util.fieldTypeSymbol(type());
}
@Override

View File

@ -44,6 +44,6 @@ public sealed interface FieldRefEntry extends MemberRefEntry
* {@return a symbolic descriptor for the field's type}
*/
default ClassDesc typeSymbol() {
return Util.fieldTypeSymbol(nameAndType());
return Util.fieldTypeSymbol(type());
}
}

View File

@ -756,22 +756,20 @@ public final class StackMapGenerator {
}
private void processFieldInstructions(RawBytecodeHelper bcs) {
var desc = Util.fieldTypeSymbol(cp.entryByIndex(bcs.getIndexU2(), MemberRefEntry.class).nameAndType());
var desc = Util.fieldTypeSymbol(cp.entryByIndex(bcs.getIndexU2(), MemberRefEntry.class).type());
var currentFrame = this.currentFrame;
switch (bcs.opcode()) {
case GETSTATIC ->
currentFrame.pushStack(desc);
case PUTSTATIC -> {
currentFrame.popStack();
if (Util.isDoubleSlot(desc)) currentFrame.popStack();
currentFrame.decStack(Util.isDoubleSlot(desc) ? 2 : 1);
}
case GETFIELD -> {
currentFrame.popStack();
currentFrame.decStack(1);
currentFrame.pushStack(desc);
}
case PUTFIELD -> {
currentFrame.popStack();
currentFrame.popStack();
if (Util.isDoubleSlot(desc)) currentFrame.popStack();
currentFrame.decStack(Util.isDoubleSlot(desc) ? 3 : 2);
}
default -> throw new AssertionError("Should not reach here");
}

View File

@ -231,10 +231,6 @@ public class Util {
return ((AbstractPoolEntry.Utf8EntryImpl) utf8).methodTypeSymbol();
}
public static ClassDesc fieldTypeSymbol(NameAndTypeEntry nat) {
return fieldTypeSymbol(nat.type());
}
public static MethodTypeDesc methodTypeSymbol(NameAndTypeEntry nat) {
return methodTypeSymbol(nat.type());
}