Carriers update for matchers-experiment - #30
Merged
biboudis merged 7 commits intoJul 1, 2025
Merged
Conversation
| MethodHandle initializingConstructor = SharedSecrets.getJavaLangRuntimeAccess().initializingConstructor(bindingMT); | ||
|
|
||
| return (Object[])Carriers.boxedComponentValueArray(bindingMT).invoke(method.invoke(matchCandidate, matchCandidate, initializingConstructor)); | ||
| return (Object[])SharedSecrets.getJavaLangRuntimeAccess().boxedComponentValueArray(bindingMT).invoke(method.invoke(matchCandidate, matchCandidate, initializingConstructor)); |
Author
There was a problem hiding this comment.
I realized I changed this mechanically, but reflection does not need to go through the Carriers at all. Fixed in 47dd83d
| || (!invocationType.returnType().equals(componentType)) | ||
| || !invocationType.parameterType(0).equals(Object.class)) | ||
| throw new IllegalArgumentException("Illegal invocation type " + invocationType); | ||
| return new ConstantCallSite(MethodHandles.insertArguments(COMPONENT_GETTER, 0, i).asType(MethodType.methodType(componentType, Object.class))); |
There was a problem hiding this comment.
Since you're inserting the first argument I'd go for COMPONENT_GETTER.bindTo(i)
Author
There was a problem hiding this comment.
I don't think that's possible - the parameter is an int, and bindTo requires the first parameter to be a reference.
There was a problem hiding this comment.
Ah, that's a good observation 👍
| boxingType, | ||
| new int[methodType.parameterCount()] | ||
| ).asType(boxingType.changeReturnType(Object[].class)); | ||
| private static Object componentGetter(int component, Carrier carrier) throws Throwable { |
There was a problem hiding this comment.
🤔 Why does this need throws Throwable?
| .toArray(Class[]::new) | ||
| ); | ||
| MethodHandle initializingConstructor = SharedSecrets.getJavaLangRuntimeAccess().initializingConstructor(bindingMT); | ||
| MethodHandle pack = MethodHandles.identity(Object[].class).asCollector(Object[].class, this.getPatternBindings().length).asType(bindingMT); |
There was a problem hiding this comment.
It's actually possible to avoid having to create a new MH each invocation, and instead have a hoisted, re-usable, handle.
private static Object[] collect(Object... params) {
return params;
}
static final MethodHandle COLLECT_TO_ARRAY = MhUtil.findStatic(This.class, "collect", MethodType.methodType(Object[].class, Object[].class));
lahodaj
marked this pull request as ready for review
June 13, 2025 06:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change proposes to:
CarriersAPI surfaceCarriersto avoid potentially unnecessary internal complexity.componentbootstrap is now expected to be used viaindy.ConstantBootstraps.invoke, and to useindyinstead ofcondyto get the component values.