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} * {@return a symbolic descriptor for the dynamic constant's type}
*/ */
default ClassDesc typeSymbol() { default ClassDesc typeSymbol() {
return Util.fieldTypeSymbol(nameAndType()); return Util.fieldTypeSymbol(type());
} }
@Override @Override

View File

@ -44,6 +44,6 @@ public sealed interface FieldRefEntry extends MemberRefEntry
* {@return a symbolic descriptor for the field's type} * {@return a symbolic descriptor for the field's type}
*/ */
default ClassDesc typeSymbol() { 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) { 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()) { switch (bcs.opcode()) {
case GETSTATIC -> case GETSTATIC ->
currentFrame.pushStack(desc); currentFrame.pushStack(desc);
case PUTSTATIC -> { case PUTSTATIC -> {
currentFrame.popStack(); currentFrame.decStack(Util.isDoubleSlot(desc) ? 2 : 1);
if (Util.isDoubleSlot(desc)) currentFrame.popStack();
} }
case GETFIELD -> { case GETFIELD -> {
currentFrame.popStack(); currentFrame.decStack(1);
currentFrame.pushStack(desc); currentFrame.pushStack(desc);
} }
case PUTFIELD -> { case PUTFIELD -> {
currentFrame.popStack(); currentFrame.decStack(Util.isDoubleSlot(desc) ? 3 : 2);
currentFrame.popStack();
if (Util.isDoubleSlot(desc)) currentFrame.popStack();
} }
default -> throw new AssertionError("Should not reach here"); default -> throw new AssertionError("Should not reach here");
} }

View File

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