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