Skip to content

Commit b224dfa

Browse files
committed
[GR-69713] Adopt JVMCI separation from AnnotatedElement.
PullRequest: graal/22598
2 parents e808b93 + 08eec1e commit b224dfa

File tree

86 files changed

+654
-883
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+654
-883
lines changed

common.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@
4949
"graalvm-ee-25-ea": {"name": "graalvm-jdk", "version": "25.0.0", "ea": "36", "platformspecific": true },
5050

5151
"oraclejdk-latest": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25.0.1+8", "platformspecific": true, "extrabundles": ["static-libs"]},
52-
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b09", "platformspecific": true },
53-
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b09-debug", "platformspecific": true },
54-
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b09-sulong", "platformspecific": true },
55-
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b09", "platformspecific": true },
56-
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b09-debug", "platformspecific": true },
57-
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b09-sulong", "platformspecific": true }
52+
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b10", "platformspecific": true },
53+
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b10-debug", "platformspecific": true },
54+
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b10-sulong", "platformspecific": true },
55+
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b10", "platformspecific": true },
56+
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b10-debug", "platformspecific": true },
57+
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b10-sulong", "platformspecific": true }
5858
},
5959

6060
"eclipse": {

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/annotation/test/TestAnnotationsOnMethods.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ public void getParameterAnnotationValuesTest() throws Exception {
126126
private static void checkParameterAnnotationValues(Method m) {
127127
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
128128
Annotation[][] parameterAnnotations = m.getParameterAnnotations();
129-
List<List<AnnotationValue>> parameterAnnotationValues = AnnotationValueSupport.getParameterAnnotationValues(method);
130-
if (parameterAnnotationValues != null) {
131-
int parsedAnnotations = parameterAnnotationValues.size();
129+
var parsed = AnnotationValueSupport.getParameterAnnotationValues(method);
130+
if (parsed != null) {
131+
int parsedAnnotations = parsed.values().size();
132132
if (parsedAnnotations != parameterAnnotations.length) {
133133
// Remove slots injected for implicit leading parameters
134134
parameterAnnotations = Arrays.copyOfRange(parameterAnnotations, parameterAnnotations.length - parsedAnnotations, parameterAnnotations.length);
135135
}
136-
assertParameterAnnotationsEquals(parameterAnnotations, parameterAnnotationValues);
136+
assertParameterAnnotationsEquals(parameterAnnotations, parsed.values());
137137
} else {
138138
for (Annotation[] annotations : parameterAnnotations) {
139139
Assert.assertEquals(0, annotations.length);

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/api/directives/test/ControlFlowAnchorDirectiveTest.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@
2929
import java.lang.annotation.Retention;
3030
import java.lang.annotation.RetentionPolicy;
3131
import java.lang.annotation.Target;
32-
import java.util.Arrays;
3332
import java.util.Collections;
3433
import java.util.List;
3534

35+
import org.junit.Assert;
36+
import org.junit.Test;
37+
38+
import jdk.graal.compiler.annotation.AnnotationValue;
39+
import jdk.graal.compiler.annotation.AnnotationValueSupport;
3640
import jdk.graal.compiler.api.directives.GraalDirectives;
3741
import jdk.graal.compiler.core.test.GraalCompilerTest;
3842
import jdk.graal.compiler.graph.Node;
@@ -44,9 +48,6 @@
4448
import jdk.graal.compiler.nodes.StructuredGraph.AllowAssumptions;
4549
import jdk.graal.compiler.nodes.debug.ControlFlowAnchorNode;
4650
import jdk.graal.compiler.phases.OptimisticOptimizations;
47-
import org.junit.Assert;
48-
import org.junit.Test;
49-
5051
import jdk.vm.ci.meta.ResolvedJavaMethod;
5152

5253
public class ControlFlowAnchorDirectiveTest extends GraalCompilerTest {
@@ -226,14 +227,16 @@ public void testClone() {
226227
g.copy(g.getDebug());
227228
}
228229

229-
private static List<NodeCount> getNodeCountAnnotations(StructuredGraph graph) {
230+
@SuppressWarnings("unchecked")
231+
private static List<AnnotationValue> getNodeCountAnnotations(StructuredGraph graph) {
230232
ResolvedJavaMethod method = graph.method();
231-
AnchorSnippet snippet = method.getAnnotation(AnchorSnippet.class);
233+
AnnotationValue snippet = AnnotationValueSupport.getAnnotationValue(method, AnchorSnippet.class);
232234
if (snippet != null) {
233-
return Arrays.asList(snippet.value());
235+
return (List<AnnotationValue>) snippet.get("value", List.class);
234236
}
235237

236-
NodeCount single = method.getAnnotation(NodeCount.class);
238+
AnnotationValue single = AnnotationValueSupport.getAnnotationValue(method, NodeCount.class);
239+
237240
if (single != null) {
238241
return Collections.singletonList(single);
239242
}
@@ -246,6 +249,7 @@ protected OptimisticOptimizations getOptimisticOptimizations() {
246249
return OptimisticOptimizations.ALL.remove(OptimisticOptimizations.Optimization.RemoveNeverExecutedCode);
247250
}
248251

252+
@SuppressWarnings("unchecked")
249253
@Override
250254
protected void checkLowTierGraph(StructuredGraph graph) {
251255
List<ControlFlowAnchorNode> anchors = graph.getNodes().filter(ControlFlowAnchorNode.class).snapshot();
@@ -259,9 +263,10 @@ protected void checkLowTierGraph(StructuredGraph graph) {
259263
}
260264
}
261265

262-
for (NodeCount nodeCount : getNodeCountAnnotations(graph)) {
263-
NodeIterable<? extends Node> nodes = graph.getNodes().filter(nodeCount.nodeClass());
264-
Assert.assertEquals(nodeCount.nodeClass().getSimpleName(), nodeCount.expectedCount(), nodes.count());
266+
for (AnnotationValue nodeCount : getNodeCountAnnotations(graph)) {
267+
Class<? extends Node> nodeClass = (Class<? extends Node>) getSnippetReflection().originalClass(nodeCount.getType("nodeClass"));
268+
NodeIterable<? extends Node> nodes = graph.getNodes().filter(nodeClass);
269+
Assert.assertEquals(nodeClass.getSimpleName(), nodeCount.getInt("expectedCount"), nodes.count());
265270
}
266271
}
267272
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/api/directives/test/OpaqueDirectiveTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
import java.lang.annotation.RetentionPolicy;
3030
import java.lang.annotation.Target;
3131

32+
import org.junit.Assert;
33+
import org.junit.Test;
34+
35+
import jdk.graal.compiler.annotation.AnnotationValue;
36+
import jdk.graal.compiler.annotation.AnnotationValueSupport;
3237
import jdk.graal.compiler.api.directives.GraalDirectives;
3338
import jdk.graal.compiler.core.test.GraalCompilerTest;
3439
import jdk.graal.compiler.nodes.ConstantNode;
@@ -37,8 +42,6 @@
3742
import jdk.graal.compiler.nodes.calc.AddNode;
3843
import jdk.graal.compiler.nodes.calc.ConditionalNode;
3944
import jdk.graal.compiler.phases.OptimisticOptimizations;
40-
import org.junit.Assert;
41-
import org.junit.Test;
4245

4346
/**
4447
* Tests for {@link GraalDirectives#opaque}.
@@ -136,9 +139,9 @@ protected OptimisticOptimizations getOptimisticOptimizations() {
136139

137140
@Override
138141
protected void checkLowTierGraph(StructuredGraph graph) {
139-
OpaqueSnippet snippet = graph.method().getAnnotation(OpaqueSnippet.class);
142+
AnnotationValue snippet = AnnotationValueSupport.getAnnotationValue(graph.method(), OpaqueSnippet.class);
140143
for (ReturnNode returnNode : graph.getNodes(ReturnNode.TYPE)) {
141-
Assert.assertEquals(snippet.expectedReturnNode(), returnNode.result().getClass());
144+
Assert.assertEquals(snippet.getType("expectedReturnNode"), getMetaAccess().lookupJavaType(returnNode.result().getClass()));
142145
}
143146
}
144147
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/CheckGraalInvariants.java

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.io.IOException;
2929
import java.io.PrintWriter;
3030
import java.io.StringWriter;
31-
import java.lang.annotation.Annotation;
3231
import java.lang.reflect.Field;
3332
import java.lang.reflect.Method;
3433
import java.lang.reflect.Modifier;
@@ -60,6 +59,8 @@
6059
import org.junit.Assume;
6160
import org.junit.Test;
6261

62+
import jdk.graal.compiler.annotation.AnnotationValue;
63+
import jdk.graal.compiler.annotation.AnnotationValueSupport;
6364
import jdk.graal.compiler.api.replacements.Snippet;
6465
import jdk.graal.compiler.api.replacements.Snippet.ConstantParameter;
6566
import jdk.graal.compiler.api.replacements.Snippet.NonNullParameter;
@@ -463,10 +464,10 @@ public static void runTest(InvariantsTool tool) {
463464
if (matches(filters, methodName)) {
464465
executor.execute(() -> {
465466
try (DebugContext debug = new Builder(options).build()) {
466-
boolean isSubstitution = method.getAnnotation(Snippet.class) != null;
467+
boolean isSubstitution = AnnotationValueSupport.getAnnotationValue(method, Snippet.class) != null;
467468
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).setIsSubstitution(isSubstitution).build();
468469
try (DebugCloseable _ = debug.disableIntercept(); DebugContext.Scope _ = debug.scope("CheckingGraph", graph, method)) {
469-
checkMethod(method);
470+
checkMethod(method, metaAccess);
470471
graphBuilderSuite.apply(graph, context);
471472
// update phi stamps
472473
graph.getNodes().filter(PhiNode.class).forEach(PhiNode::inferStamp);
@@ -675,17 +676,21 @@ private static void checkClass(Class<?> c, MetaAccessProvider metaAccess, List<V
675676
}
676677
}
677678

678-
private static void checkMethod(ResolvedJavaMethod method) {
679-
if (method.getAnnotation(Snippet.class) == null) {
680-
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
681-
for (int i = 0; i < parameterAnnotations.length; i++) {
682-
for (Annotation a : parameterAnnotations[i]) {
683-
Class<? extends Annotation> annotationType = a.annotationType();
684-
if (annotationType == ConstantParameter.class || annotationType == VarargsParameter.class || annotationType == NonNullParameter.class) {
685-
VerificationError verificationError = new VerificationError("Parameter %d of %s is annotated with %s but the method is not annotated with %s", i, method,
686-
annotationType.getSimpleName(),
687-
Snippet.class.getSimpleName());
688-
throw verificationError;
679+
private static void checkMethod(ResolvedJavaMethod method, MetaAccessProvider metaAccess) {
680+
if (AnnotationValueSupport.getAnnotationValue(method, Snippet.class) == null) {
681+
var parsed = AnnotationValueSupport.getParameterAnnotationValues(method);
682+
if (parsed != null) {
683+
for (int i = 0; i < parsed.values().size(); i++) {
684+
List<AnnotationValue> annotations = parsed.values().get(i);
685+
for (AnnotationValue a : annotations) {
686+
ResolvedJavaType annotationType = a.getAnnotationType();
687+
if (annotationType.equals(metaAccess.lookupJavaType(ConstantParameter.class)) ||
688+
annotationType.equals(metaAccess.lookupJavaType(VarargsParameter.class)) ||
689+
annotationType.equals(metaAccess.lookupJavaType(NonNullParameter.class))) {
690+
throw new VerificationError("Parameter %d of %s is annotated with %s but the method is not annotated with %s", i, method,
691+
annotationType.toJavaName(false),
692+
Snippet.class.getSimpleName());
693+
}
689694
}
690695
}
691696
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/EarlyGVNTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import org.junit.Before;
4040
import org.junit.Test;
4141

42+
import jdk.graal.compiler.annotation.AnnotationValue;
43+
import jdk.graal.compiler.annotation.AnnotationValueSupport;
4244
import jdk.graal.compiler.api.directives.GraalDirectives;
4345
import jdk.graal.compiler.core.common.GraalOptions;
4446
import jdk.graal.compiler.graph.Node;
@@ -80,9 +82,9 @@ public void checkOptions() {
8082

8183
@Override
8284
protected void checkHighTierGraph(StructuredGraph graph) {
83-
MustFold fold = graph.method().getAnnotation(MustFold.class);
85+
AnnotationValue fold = AnnotationValueSupport.getAnnotationValue(graph.method(), MustFold.class);
8486
if (fold != null) {
85-
if (fold.noLoopLeft()) {
87+
if (fold.getBoolean("noLoopLeft")) {
8688
assertFalse(graph.hasLoops());
8789
} else {
8890
assertTrue(graph.hasLoops());

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/GraalCompilerTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
import org.junit.Test;
6969
import org.junit.internal.AssumptionViolatedException;
7070

71+
import jdk.graal.compiler.annotation.AnnotationValue;
72+
import jdk.graal.compiler.annotation.AnnotationValueSupport;
7173
import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
7274
import jdk.graal.compiler.api.test.Graal;
7375
import jdk.graal.compiler.api.test.ModuleSupport;
@@ -1593,7 +1595,7 @@ protected StructuredGraph parse(StructuredGraph.Builder builder, PhaseSuite<High
15931595
if (id != null) {
15941596
builder.compilationId(id);
15951597
}
1596-
assert javaMethod.getAnnotation(Test.class) == null : "shouldn't parse method with @Test annotation: " + javaMethod;
1598+
assert AnnotationValueSupport.getAnnotationValue(javaMethod, Test.class) == null : "shouldn't parse method with @Test annotation: " + javaMethod;
15971599
StructuredGraph graph = builder.build();
15981600
DebugContext debug = graph.getDebug();
15991601
try (DebugContext.Scope _ = debug.scope("Parsing", javaMethod, graph)) {
@@ -1782,11 +1784,11 @@ protected GraphBuilderConfiguration editGraphBuilderConfiguration(GraphBuilderCo
17821784

17831785
@Override
17841786
public InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) {
1785-
BytecodeParserNeverInline neverInline = method.getAnnotation(BytecodeParserNeverInline.class);
1787+
AnnotationValue neverInline = AnnotationValueSupport.getAnnotationValue(method, BytecodeParserNeverInline.class);
17861788
if (neverInline != null) {
1787-
return neverInline.invokeWithException() ? DO_NOT_INLINE_WITH_EXCEPTION : DO_NOT_INLINE_NO_EXCEPTION;
1789+
return neverInline.getBoolean("invokeWithException") ? DO_NOT_INLINE_WITH_EXCEPTION : DO_NOT_INLINE_NO_EXCEPTION;
17881790
}
1789-
if (method.getAnnotation(BytecodeParserForceInline.class) != null) {
1791+
if (AnnotationValueSupport.getAnnotationValue(method, BytecodeParserForceInline.class) != null) {
17901792
return InlineInfo.createStandardInlineInfo(method);
17911793
}
17921794
return bytecodeParserShouldInlineInvoke(b, method, args);

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/VerifyFoldableMethods.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.concurrent.ConcurrentHashMap;
3030
import java.util.stream.Collectors;
3131

32+
import jdk.graal.compiler.annotation.AnnotationValueSupport;
3233
import jdk.graal.compiler.api.replacements.Fold;
3334
import jdk.graal.compiler.nodes.PluginReplacementNode;
3435
import jdk.graal.compiler.nodes.StructuredGraph;
@@ -84,13 +85,13 @@ private boolean isGenerated(ResolvedJavaMethod method, CoreProviders context) {
8485
@Override
8586
protected void verify(StructuredGraph graph, CoreProviders context) {
8687
ResolvedJavaMethod method = graph.method();
87-
if (method.getAnnotation(Fold.class) != null) {
88+
if (AnnotationValueSupport.getAnnotationValue(method, Fold.class) != null) {
8889
foldableCallers.putIfAbsent(method, method);
8990
} else {
9091
if (!isGenerated(method, context)) {
9192
for (MethodCallTargetNode t : graph.getNodes(MethodCallTargetNode.TYPE)) {
9293
ResolvedJavaMethod callee = t.targetMethod();
93-
if (callee.getAnnotation(Fold.class) != null) {
94+
if (AnnotationValueSupport.getAnnotationValue(callee, Fold.class) != null) {
9495
foldableCallers.put(callee, method);
9596
}
9697
}

0 commit comments

Comments
 (0)