8340544: Optimize setLocalsFromArg
Reviewed-by: redestad, liach
This commit is contained in:
parent
2461263aac
commit
ab06a878f8
@ -1043,34 +1043,37 @@ public final class StackMapGenerator {
|
||||
void setLocalsFromArg(String name, MethodTypeDesc methodDesc, boolean isStatic, Type thisKlass) {
|
||||
int localsSize = 0;
|
||||
// Pre-emptively create a locals array that encompass all parameter slots
|
||||
checkLocal(methodDesc.parameterCount() + (isStatic ? -1 : 0));
|
||||
checkLocal(Util.parameterSlots(methodDesc) + (isStatic ? -1 : 0));
|
||||
Type type;
|
||||
Type[] locals = this.locals;
|
||||
if (!isStatic) {
|
||||
localsSize++;
|
||||
if (OBJECT_INITIALIZER_NAME.equals(name) && !CD_Object.equals(thisKlass.sym)) {
|
||||
setLocal(0, Type.UNITIALIZED_THIS_TYPE);
|
||||
type = Type.UNITIALIZED_THIS_TYPE;
|
||||
flags |= FLAG_THIS_UNINIT;
|
||||
} else {
|
||||
setLocalRawInternal(0, thisKlass);
|
||||
type = thisKlass;
|
||||
}
|
||||
locals[localsSize++] = type;
|
||||
}
|
||||
for (int i = 0; i < methodDesc.parameterCount(); i++) {
|
||||
var desc = methodDesc.parameterType(i);
|
||||
if (!desc.isPrimitive()) {
|
||||
setLocalRawInternal(localsSize++, Type.referenceType(desc));
|
||||
} else switch (desc.descriptorString().charAt(0)) {
|
||||
case 'J' -> {
|
||||
setLocalRawInternal(localsSize++, Type.LONG_TYPE);
|
||||
setLocalRawInternal(localsSize++, Type.LONG2_TYPE);
|
||||
if (desc == CD_long) {
|
||||
locals[localsSize ] = Type.LONG_TYPE;
|
||||
locals[localsSize + 1] = Type.LONG2_TYPE;
|
||||
localsSize += 2;
|
||||
} else if (desc == CD_double) {
|
||||
locals[localsSize ] = Type.DOUBLE_TYPE;
|
||||
locals[localsSize + 1] = Type.DOUBLE2_TYPE;
|
||||
localsSize += 2;
|
||||
} else {
|
||||
if (desc instanceof ReferenceClassDescImpl) {
|
||||
type = Type.referenceType(desc);
|
||||
} else if (desc == CD_float) {
|
||||
type = Type.FLOAT_TYPE;
|
||||
} else {
|
||||
type = Type.INTEGER_TYPE;
|
||||
}
|
||||
case 'D' -> {
|
||||
setLocalRawInternal(localsSize++, Type.DOUBLE_TYPE);
|
||||
setLocalRawInternal(localsSize++, Type.DOUBLE2_TYPE);
|
||||
}
|
||||
case 'I', 'Z', 'B', 'C', 'S' ->
|
||||
setLocalRawInternal(localsSize++, Type.INTEGER_TYPE);
|
||||
case 'F' ->
|
||||
setLocalRawInternal(localsSize++, Type.FLOAT_TYPE);
|
||||
default -> throw new AssertionError("Should not reach here");
|
||||
locals[localsSize++] = type;
|
||||
}
|
||||
}
|
||||
this.localsSize = localsSize;
|
||||
|
Loading…
Reference in New Issue
Block a user