RFR: 8303431: [JVMCI] libgraal annotation API [v9]
Doug Simon
dnsimon at openjdk.org
Thu Apr 20 09:12:02 UTC 2023
On Tue, 18 Apr 2023 07:27:47 GMT, Doug Simon <dnsimon at openjdk.org> wrote:
>> This PR extends JVMCI with new API (`jdk.vm.ci.meta.Annotated`) for accessing annotations. The main differences from `java.lang.reflect.AnnotatedElement` are:
>> * All methods in the `Annotated` interface explicitly specify requested annotation type(s). That is, there is no equivalent of `AnnotatedElement.getAnnotations()`.
>> * Annotation data is returned in a map-like object (of type `jdk.vm.ci.meta.AnnotationData`) instead of in an `Annotation` object. This works better for libgraal as it avoids the need for annotation types to be loaded and included in libgraal.
>>
>> To demonstrate the new API, here's an example in terms `java.lang.reflect.AnnotatedElement` (which `ResolvedJavaType` implements):
>>
>> ResolvedJavaMethod method = ...;
>> ExplodeLoop a = method.getAnnotation(ExplodeLoop.class);
>> return switch (a.kind()) {
>> case FULL_UNROLL -> LoopExplosionKind.FULL_UNROLL;
>> case FULL_UNROLL_UNTIL_RETURN -> LoopExplosionKind.FULL_UNROLL_UNTIL_RETURN;
>> ...
>> }
>>
>>
>> The same code using the new API:
>>
>>
>> ResolvedJavaMethod method = ...;
>> ResolvedJavaType explodeLoopType = ...;
>> AnnotationData a = method.getAnnotationDataFor(explodeLoopType);
>> return switch (a.getEnum("kind").getName()) {
>> case "FULL_UNROLL" -> LoopExplosionKind.FULL_UNROLL;
>> case "FULL_UNROLL_UNTIL_RETURN" -> LoopExplosionKind.FULL_UNROLL_UNTIL_RETURN;
>> ...
>> }
>>
>>
>> The implementation relies on new methods in `jdk.internal.vm.VMSupport` for parsing annotations and serializing/deserializing to/from a byte array. This allows the annotation data to be passed from the HotSpot heap to the libgraal heap.
>
> Doug Simon has updated the pull request incrementally with two additional commits since the last revision:
>
> - added breadcrumb in AnnotationParser about considering JVMCI should new annotation element types be added
> - fixed javadoc comment
I can reproduce this locally as well but really don't know where to start in terms of debugging this. Can you please provide hints as to what may cause this failure C1 compiled code?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/12810#issuecomment-1515986311
More information about the core-libs-dev
mailing list