Skip to content

Commit

Permalink
8340544: Optimize setLocalsFromArg
Browse files Browse the repository at this point in the history
Reviewed-by: redestad, liach
  • Loading branch information
wenshao committed Sep 22, 2024
1 parent 2461263 commit ab06a87
Showing 1 changed file with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1043,34 +1043,37 @@ private void setLocalRawInternal(int index, Type type) {
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);
}
case 'D' -> {
setLocalRawInternal(localsSize++, Type.DOUBLE_TYPE);
setLocalRawInternal(localsSize++, Type.DOUBLE2_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 '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;
Expand Down

0 comments on commit ab06a87

Please sign in to comment.