Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
8288425: Footprint regression due MH creation when initializing Strin…
Browse files Browse the repository at this point in the history
…gConcatFactory

Reviewed-by: jlaskey
Backport-of: 6d59561
  • Loading branch information
cl4es committed Jun 28, 2022
1 parent adbd200 commit 9048cef
Showing 1 changed file with 11 additions and 4 deletions.
Expand Up @@ -722,8 +722,15 @@ private static int classIndex(Class<?> cl) {
private static final int[] PREPEND_FILTER_SECOND_PAIR_ARGS = new int[] { 0, 1, 4, 5 };

// Base MH for complex prepender combinators.
private static final MethodHandle PREPEND_BASE = MethodHandles.dropArguments(
MethodHandles.identity(long.class), 1, byte[].class);
private static @Stable MethodHandle PREPEND_BASE;
private static MethodHandle prependBase() {
MethodHandle base = PREPEND_BASE;
if (base == null) {
base = PREPEND_BASE = MethodHandles.dropArguments(
MethodHandles.identity(long.class), 1, byte[].class);
}
return base;
}

private static final @Stable MethodHandle[][] DOUBLE_PREPENDERS = new MethodHandle[TYPE_COUNT][TYPE_COUNT];

Expand All @@ -733,7 +740,7 @@ private static MethodHandle prepender(String prefix, Class<?> cl, String prefix2
MethodHandle prepend = DOUBLE_PREPENDERS[idx1][idx2];
if (prepend == null) {
prepend = DOUBLE_PREPENDERS[idx1][idx2] =
MethodHandles.dropArguments(PREPEND_BASE, 2, cl, cl2);
MethodHandles.dropArguments(prependBase(), 2, cl, cl2);
}
prepend = MethodHandles.filterArgumentsWithCombiner(prepend, 0, prepender(prefix, cl),
PREPEND_FILTER_FIRST_ARGS);
Expand All @@ -750,7 +757,7 @@ private static MethodHandle prepender(int pos, String[] constants, Class<?>[] pt
return prepender(constants[pos], ptypes[pos], constants[pos + 1], ptypes[pos + 1]);
}
// build a tree from an unbound prepender, allowing us to bind the constants in a batch as a final step
MethodHandle prepend = PREPEND_BASE;
MethodHandle prepend = prependBase();
if (count == 3) {
prepend = MethodHandles.dropArguments(prepend, 2,
ptypes[pos], ptypes[pos + 1], ptypes[pos + 2]);
Expand Down

1 comment on commit 9048cef

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.