8339640: Reduce construction overheads in StringConcatFactory$InlineHiddenClassStrategy
Reviewed-by: liach
This commit is contained in:
parent
260908e16e
commit
cb00333d6a
@ -1242,7 +1242,7 @@ public final class StringConcatFactory {
|
|||||||
lookup = STR_LOOKUP;
|
lookup = STR_LOOKUP;
|
||||||
final MethodType concatArgs = erasedArgs(args);
|
final MethodType concatArgs = erasedArgs(args);
|
||||||
|
|
||||||
// 1 argment use built-in method
|
// 1 argument use built-in method
|
||||||
if (args.parameterCount() == 1) {
|
if (args.parameterCount() == 1) {
|
||||||
Object concat1 = JLA.stringConcat1(constants);
|
Object concat1 = JLA.stringConcat1(constants);
|
||||||
var handle = lookup.findVirtual(concat1.getClass(), METHOD_NAME, concatArgs);
|
var handle = lookup.findVirtual(concat1.getClass(), METHOD_NAME, concatArgs);
|
||||||
@ -1254,7 +1254,7 @@ public final class StringConcatFactory {
|
|||||||
MethodHandlePair handlePair = weakConstructorHandle.get();
|
MethodHandlePair handlePair = weakConstructorHandle.get();
|
||||||
if (handlePair != null) {
|
if (handlePair != null) {
|
||||||
try {
|
try {
|
||||||
var instance = handlePair.constructor.invoke(constants);
|
var instance = handlePair.constructor.invokeBasic((Object)constants);
|
||||||
return handlePair.concatenator.bindTo(instance);
|
return handlePair.concatenator.bindTo(instance);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new StringConcatException("Exception while utilizing the hidden class", e);
|
throw new StringConcatException("Exception while utilizing the hidden class", e);
|
||||||
@ -1331,10 +1331,10 @@ public final class StringConcatFactory {
|
|||||||
var hiddenClass = lookup.makeHiddenClassDefiner(CLASS_NAME, classBytes, Set.of(), DUMPER)
|
var hiddenClass = lookup.makeHiddenClassDefiner(CLASS_NAME, classBytes, Set.of(), DUMPER)
|
||||||
.defineClass(true, null);
|
.defineClass(true, null);
|
||||||
var constructor = lookup.findConstructor(hiddenClass, CONSTRUCTOR_METHOD_TYPE);
|
var constructor = lookup.findConstructor(hiddenClass, CONSTRUCTOR_METHOD_TYPE);
|
||||||
var concat = lookup.findVirtual(hiddenClass, METHOD_NAME, concatArgs);
|
var concatenator = lookup.findVirtual(hiddenClass, METHOD_NAME, concatArgs);
|
||||||
CACHE.put(concatArgs, new SoftReference<>(new MethodHandlePair(constructor, concat)));
|
CACHE.put(concatArgs, new SoftReference<>(new MethodHandlePair(constructor, concatenator)));
|
||||||
var instance = hiddenClass.cast(constructor.invoke(constants));
|
var instance = constructor.invokeBasic((Object)constants);
|
||||||
return concat.bindTo(instance);
|
return concatenator.bindTo(instance);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new StringConcatException("Exception while spinning the class", e);
|
throw new StringConcatException("Exception while spinning the class", e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user