8339642: Reduce overheads in InvokerBytecodeGenerator

Reviewed-by: liach
This commit is contained in:
Claes Redestad 2024-09-06 12:37:48 +00:00
parent cb00333d6a
commit d2b36f0907
2 changed files with 43 additions and 45 deletions

View file

@ -1555,6 +1555,7 @@ class LambdaForm {
* Return -1 if the name is not used.
*/
int lastUseIndex(Name n) {
Object[] arguments = this.arguments;
if (arguments == null) return -1;
for (int i = arguments.length; --i >= 0; ) {
if (arguments[i] == n) return i;
@ -1562,21 +1563,6 @@ class LambdaForm {
return -1;
}
/** Return the number of occurrences of n in the argument array.
* Return 0 if the name is not used.
*/
int useCount(Name n) {
int count = 0;
if (arguments != null) {
for (Object argument : arguments) {
if (argument == n) {
count++;
}
}
}
return count;
}
public boolean equals(Name that) {
if (this == that) return true;
if (isParam())
@ -1618,8 +1604,16 @@ class LambdaForm {
int useCount(Name n) {
int count = (result == n.index) ? 1 : 0;
int i = Math.max(n.index + 1, arity);
Name[] names = this.names;
while (i < names.length) {
count += names[i++].useCount(n);
Object[] arguments = names[i++].arguments;
if (arguments != null) {
for (Object argument : arguments) {
if (argument == n) {
count++;
}
}
}
}
return count;
}