mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8341512: Optimize StackMapGenerator::processInvokeInstructions
Reviewed-by: liach
This commit is contained in:
parent
f8db3a831b
commit
1c3e56c3e4
10 changed files with 13 additions and 19 deletions
|
@ -92,7 +92,7 @@ public sealed interface EnclosingMethodAttribute
|
|||
* immediately enclosed by a method or constructor}
|
||||
*/
|
||||
default Optional<MethodTypeDesc> enclosingMethodTypeSymbol() {
|
||||
return enclosingMethod().map(Util::methodTypeSymbol);
|
||||
return enclosingMethodType().map(Util::methodTypeSymbol);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,6 +45,6 @@ public sealed interface InterfaceMethodRefEntry
|
|||
* {@return a symbolic descriptor for the interface method's type}
|
||||
*/
|
||||
default MethodTypeDesc typeSymbol() {
|
||||
return Util.methodTypeSymbol(nameAndType());
|
||||
return Util.methodTypeSymbol(type());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public sealed interface InvokeDynamicEntry
|
|||
* {@return a symbolic descriptor for the call site's invocation type}
|
||||
*/
|
||||
default MethodTypeDesc typeSymbol() {
|
||||
return Util.methodTypeSymbol(nameAndType());
|
||||
return Util.methodTypeSymbol(type());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,6 +44,6 @@ public sealed interface MethodRefEntry extends MemberRefEntry
|
|||
* {@return a symbolic descriptor for the method's type}
|
||||
*/
|
||||
default MethodTypeDesc typeSymbol() {
|
||||
return Util.methodTypeSymbol(nameAndType());
|
||||
return Util.methodTypeSymbol(type());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public sealed interface InvokeInstruction extends Instruction
|
|||
* {@return a symbolic descriptor for the method type}
|
||||
*/
|
||||
default MethodTypeDesc typeSymbol() {
|
||||
return Util.methodTypeSymbol(method().nameAndType());
|
||||
return Util.methodTypeSymbol(method().type());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1061,7 +1061,7 @@ public abstract sealed class AbstractInstruction
|
|||
@Override
|
||||
public int count() {
|
||||
return op == Opcode.INVOKEINTERFACE
|
||||
? Util.parameterSlots(Util.methodTypeSymbol(methodEntry.nameAndType())) + 1
|
||||
? Util.parameterSlots(Util.methodTypeSymbol(methodEntry.type())) + 1
|
||||
: 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -809,7 +809,7 @@ public final class DirectCodeBuilder
|
|||
@Override
|
||||
public CodeBuilder invoke(Opcode opcode, MemberRefEntry ref) {
|
||||
if (opcode == INVOKEINTERFACE) {
|
||||
int slots = Util.parameterSlots(Util.methodTypeSymbol(ref.nameAndType())) + 1;
|
||||
int slots = Util.parameterSlots(Util.methodTypeSymbol(ref.type())) + 1;
|
||||
writeInvokeInterface(opcode, (InterfaceMethodRefEntry) ref, slots);
|
||||
} else {
|
||||
writeInvokeNormal(opcode, ref);
|
||||
|
|
|
@ -326,7 +326,7 @@ public final class StackCounter {
|
|||
case INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC, INVOKEINTERFACE, INVOKEDYNAMIC -> {
|
||||
var cpe = cp.entryByIndex(bcs.getIndexU2());
|
||||
var nameAndType = opcode == INVOKEDYNAMIC ? ((DynamicConstantPoolEntry)cpe).nameAndType() : ((MemberRefEntry)cpe).nameAndType();
|
||||
var mtd = Util.methodTypeSymbol(nameAndType);
|
||||
var mtd = Util.methodTypeSymbol(nameAndType.type());
|
||||
var delta = Util.slotSize(mtd.returnType()) - Util.parameterSlots(mtd);
|
||||
if (opcode != INVOKESTATIC && opcode != INVOKEDYNAMIC) {
|
||||
delta--;
|
||||
|
|
|
@ -781,12 +781,12 @@ public final class StackMapGenerator {
|
|||
var nameAndType = opcode == INVOKEDYNAMIC
|
||||
? cp.entryByIndex(index, InvokeDynamicEntry.class).nameAndType()
|
||||
: cp.entryByIndex(index, MemberRefEntry.class).nameAndType();
|
||||
String invokeMethodName = nameAndType.name().stringValue();
|
||||
var mDesc = Util.methodTypeSymbol(nameAndType);
|
||||
var mDesc = Util.methodTypeSymbol(nameAndType.type());
|
||||
int bci = bcs.bci();
|
||||
var currentFrame = this.currentFrame;
|
||||
currentFrame.decStack(Util.parameterSlots(mDesc));
|
||||
if (opcode != INVOKESTATIC && opcode != INVOKEDYNAMIC) {
|
||||
if (OBJECT_INITIALIZER_NAME.equals(invokeMethodName)) {
|
||||
if (nameAndType.name().equalsString(OBJECT_INITIALIZER_NAME)) {
|
||||
Type type = currentFrame.popStack();
|
||||
if (type == Type.UNITIALIZED_THIS_TYPE) {
|
||||
if (inTryBlock) {
|
||||
|
@ -795,9 +795,7 @@ public final class StackMapGenerator {
|
|||
currentFrame.initializeObject(type, thisType);
|
||||
thisUninit = true;
|
||||
} else if (type.tag == ITEM_UNINITIALIZED) {
|
||||
int new_offset = type.bci;
|
||||
int new_class_index = bcs.getU2(new_offset + 1);
|
||||
Type new_class_type = cpIndexToType(new_class_index, cp);
|
||||
Type new_class_type = cpIndexToType(bcs.getU2(type.bci + 1), cp);
|
||||
if (inTryBlock) {
|
||||
processExceptionHandlerTargets(bci, thisUninit);
|
||||
}
|
||||
|
@ -806,7 +804,7 @@ public final class StackMapGenerator {
|
|||
throw generatorError("Bad operand type when invoking <init>");
|
||||
}
|
||||
} else {
|
||||
currentFrame.popStack();
|
||||
currentFrame.decStack(1);
|
||||
}
|
||||
}
|
||||
currentFrame.pushStack(mDesc.returnType());
|
||||
|
|
|
@ -231,10 +231,6 @@ public class Util {
|
|||
return ((AbstractPoolEntry.Utf8EntryImpl) utf8).methodTypeSymbol();
|
||||
}
|
||||
|
||||
public static MethodTypeDesc methodTypeSymbol(NameAndTypeEntry nat) {
|
||||
return methodTypeSymbol(nat.type());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T extends Attribute<T>> void writeAttribute(BufWriterImpl writer, Attribute<?> attr) {
|
||||
if (attr instanceof CustomAttribute<?> ca) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue