Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
"graalvm-ee-25-ea": {"name": "graalvm-jdk", "version": "25.0.0", "ea": "36", "platformspecific": true },

"oraclejdk-latest": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25.0.1+8", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b08", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b08-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b08-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b08", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b08-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b08-sulong", "platformspecific": true }
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b09", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b09-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25.0.1+8-jvmci-25.1-b09-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b09", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b09-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25.0.1+8-jvmci-25.1-b09-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
1 change: 1 addition & 0 deletions compiler/mx.compiler/mx_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def _ctw_jvmci_export_args(arg_prefix='--'):
'add-exports=java.base/jdk.internal.module=ALL-UNNAMED',
'add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED',
'add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED',
'add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta.annotation=ALL-UNNAMED',
'add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED',
'add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED',
'add-exports=jdk.graal.compiler/jdk.graal.compiler.hotspot=ALL-UNNAMED',
Expand Down
1 change: 1 addition & 0 deletions compiler/mx.compiler/mx_graal_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ def extraVmArgs(self):
'--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED',
'--add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED',
'--add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED',
'--add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta.annotation=ALL-UNNAMED',
'--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED',
'--add-exports=jdk.graal.compiler/jdk.graal.compiler.graph=ALL-UNNAMED',
'--add-exports=org.graalvm.truffle/com.oracle.truffle.api.benchmark=ALL-UNNAMED',
Expand Down
3 changes: 3 additions & 0 deletions compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@
"GRAAL_PROCESSOR",
],
"javaCompliance" : "21+",
"spotbugs": "false",
"workingSets" : "Graal,HotSpot",
},

Expand All @@ -328,6 +329,7 @@
"requiresConcealed" : {
"jdk.internal.vm.ci" : [
"jdk.vm.ci.meta",
"jdk.vm.ci.meta.annotation",
"jdk.vm.ci.code"
],
},
Expand Down Expand Up @@ -398,6 +400,7 @@
"checkstyle" : "jdk.graal.compiler",
"javaCompliance" : "21+",
"jacoco" : "exclude",
"spotbugs": "false",
"graalCompilerSourceEdition": "ignore",
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected HostMethodInfo computeValue(ResolvedJavaMethod method) {
boolean isBytecodeInterpreterSwitch = annotations.containsKey(hostTypes.BytecodeInterpreterSwitch);
boolean isBytecodeInterpreterSwitchBoundary = annotations.containsKey(hostTypes.BytecodeInterpreterSwitchBoundary);
boolean isInliningCutoff = annotations.containsKey(hostTypes.InliningCutoff);
boolean isInliningRoot = annotations.containsKey(hostTypes.InliningRoot);
boolean isInliningRoot = hostTypes.InliningRoot != null && annotations.containsKey(hostTypes.InliningRoot);
return new HostMethodInfo(isTruffleBoundary, isBytecodeInterpreterSwitch, isBytecodeInterpreterSwitchBoundary, isInliningCutoff, isInliningRoot);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void checkProxyMethods() throws IllegalAccessException, InvocationTargetE
assertTrue("protected method should throw UnsupportedOperationException", e.getTargetException() instanceof UnsupportedOperationException);
continue;
}
Assert.fail("expected the protected method to throw");
Assert.fail("expected the protected method to throw: " + method);
}

Object returnValue = createValue(method.getReturnType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.BiFunction;

import jdk.graal.compiler.util.CollectionsUtil;
import jdk.vm.ci.meta.ResolvedJavaType;
Expand Down Expand Up @@ -375,4 +376,28 @@ public int hashCode() {
}
return type.hashCode() ^ elements.hashCode();
}

/**
* Result of last call to {@link #toAnnotation}.
*/
private volatile Annotation annotationCache;

/**
* Converts this to an {@link Annotation} of type {@code annotationType}, utilizing the provided
* converter function. The result is cached to improve performance by reducing redundant
* conversions.
*
* @param <T> the type of the annotation to be created
* @param annotationType the desired annotation type
* @param converter a function that does the conversion
*/
@SuppressWarnings("unchecked")
public <T extends Annotation> T toAnnotation(Class<T> annotationType, BiFunction<AnnotationValue, Class<T>, T> converter) {
Annotation res = annotationCache;
if (res == null || res.annotationType() != annotationType) {
res = converter.apply(this, annotationType);
annotationCache = res;
}
return (T) res;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
import java.lang.reflect.Method;
import java.lang.reflect.RecordComponent;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;

import jdk.graal.compiler.core.common.LibGraalSupport;
import jdk.graal.compiler.debug.GraalError;
import jdk.graal.compiler.util.CollectionsUtil;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
import jdk.vm.ci.meta.UnresolvedJavaType;
Expand Down Expand Up @@ -77,12 +77,26 @@ public static AnnotationValue getDeclaredAnnotationValue(ResolvedJavaType annota
* present on this element
*/
public static Map<ResolvedJavaType, AnnotationValue> getDeclaredAnnotationValues(Annotated annotated) {
AnnotationsInfo info = annotated.getDeclaredAnnotationInfo();
return annotated.getDeclaredAnnotationInfo(ANNOTATIONS_INFO_PARSER).values;
}

/**
* Result type returned by {@link AnnotationValueSupport#ANNOTATIONS_INFO_PARSER}.
*
* @param values the parsed annotations
* @param container used to resolve type names in the annotations
*/
public record ParsedDeclaredAnnotationValues(Map<ResolvedJavaType, AnnotationValue> values, ResolvedJavaType container) {
public static ParsedDeclaredAnnotationValues NONE = new ParsedDeclaredAnnotationValues(CollectionsUtil.mapOf(), null);
}

public static final Function<AnnotationsInfo, ParsedDeclaredAnnotationValues> ANNOTATIONS_INFO_PARSER = info -> {
if (info == null) {
return Collections.emptyMap();
return ParsedDeclaredAnnotationValues.NONE;
}
return AnnotationValueParser.parseAnnotations(info.bytes(), info.constPool(), info.container());
}
ResolvedJavaType container = info.container();
return new ParsedDeclaredAnnotationValues(AnnotationValueParser.parseAnnotations(info.bytes(), info.constPool(), container), container);
};

/**
* Gets the type annotations for {@code annotated} that back the implementation of
Expand Down Expand Up @@ -122,9 +136,9 @@ public static List<List<AnnotationValue>> getParameterAnnotationValues(ResolvedJ
* null if no default is associated with {@code method}, or if {@code method} does not represent
* a declared member of an annotation type.
*
* @see Method#getDefaultValue()
* @return the default value for the annotation member represented by this object. The type of
* the returned value is specified by {@link AnnotationValue#get}
* @see Method#getDefaultValue()
*/
public static Object getAnnotationDefaultValue(ResolvedJavaMethod method) {
AnnotationsInfo info = method.getAnnotationDefaultInfo();
Expand All @@ -150,47 +164,14 @@ public static AnnotationValue getAnnotationValue(Annotated annotated, Class<? ex
return getAnnotationValue0(annotated, annotationType, inherited);
}

/**
* Cache for {@link #getAnnotationValue}. Building libgraal-ee shows that this cache grows to
* about 3K entries so the LRU cache is sized just above that (4096). This cache must not grow
* too large as there are Native Image tests that build numerous images in the one JVM process.
*/
@LibGraalSupport.HostedOnly //
private static final Map<Annotated, Map<ResolvedJavaType, AnnotationValue>> declaredAnnotations;
static {
final int cacheMaxSize = 4096;
if (LibGraalSupport.INSTANCE == null) {
declaredAnnotations = Collections.synchronizedMap(new java.util.LinkedHashMap<>(cacheMaxSize, 0.75f, true) {
@Override
protected boolean removeEldestEntry(Map.Entry<Annotated, Map<ResolvedJavaType, AnnotationValue>> eldest) {
return size() > cacheMaxSize;
}
});
} else {
declaredAnnotations = null;
}
}

@LibGraalSupport.HostedOnly
private static AnnotationValue getAnnotationValue0(Annotated annotated, Class<? extends Annotation> annotationType, boolean inherited) {
AnnotationsInfo info = annotated.getDeclaredAnnotationInfo();
if (info == null && !inherited) {
ParsedDeclaredAnnotationValues parsed = annotated.getDeclaredAnnotationInfo(ANNOTATIONS_INFO_PARSER);
if (parsed.values == null && !inherited) {
return null;
}
Map<ResolvedJavaType, AnnotationValue> map = declaredAnnotations.get(annotated);
if (map == null) {
/*
* Do not use Map#computeIfAbsent as Collections.SynchronizedMap#computeIfAbsent blocks
* readers during the creation of the cached value.
*/
map = AnnotationValueParser.parseAnnotations(info.bytes(), info.constPool(), info.container());
var existing = declaredAnnotations.putIfAbsent(annotated, map);
if (existing != null) {
map = existing;
}
}

AnnotationValue res = lookup(annotationType, map, info);
AnnotationValue res = lookup(annotationType, parsed.values, parsed.container);
if (res != null) {
return res;
}
Expand All @@ -201,19 +182,22 @@ private static AnnotationValue getAnnotationValue0(Annotated annotated, Class<?
return null;
}

@LibGraalSupport.HostedOnly //
private static final Map<Class<? extends Annotation>, ResolvedJavaType> resolvedAnnotationTypeCache = LibGraalSupport.INSTANCE != null ? null
: new ConcurrentHashMap<>();

/**
* Looks up the annotation value of type {@code annotationType} in {@code map}.
*
* @param annotationType the type of annotation to look up
* @param map the map of annotation values to search
* @param container used to resolve the annotation type
* @return the annotation value if found, or null if not found
*/
@LibGraalSupport.HostedOnly
private static AnnotationValue lookup(Class<? extends Annotation> annotationType, Map<ResolvedJavaType, AnnotationValue> map, AnnotationsInfo info) {
private static AnnotationValue lookup(Class<? extends Annotation> annotationType, Map<ResolvedJavaType, AnnotationValue> map, ResolvedJavaType container) {
String internalName = "L" + annotationType.getName().replace(".", "/") + ";";
for (var e : map.entrySet()) {
ResolvedJavaType type = e.getKey();
if (type.getName().equals(internalName)) {
// The name matches so now double-check the resolved type matches
ResolvedJavaType resolved = resolvedAnnotationTypeCache.computeIfAbsent(annotationType, a -> UnresolvedJavaType.create(internalName).resolve(info.container()));
if (resolved.equals(type)) {
if (UnresolvedJavaType.create(internalName).resolve(container).equals(type)) {
return e.getValue();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public final class JVMCIVersionCheck {
// Checkstyle: stop stable iteration order check
private static final Map<String, Map<String, Version>> JVMCI_MIN_VERSIONS = Map.of(
"25", Map.of(
"Oracle Corporation", createLabsJDKVersion("25.0.1+8", "25.1", 8),
DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("25.0.1+8", "25.1", 8)));
"Oracle Corporation", createLabsJDKVersion("25.0.1+8", "25.1", 9),
DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("25.0.1+8", "25.1", 9)));
// Checkstyle: resume stable iteration order check

private static final int NA = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Objects;
import java.util.function.Function;

import jdk.vm.ci.meta.Constant;
import jdk.vm.ci.meta.ConstantPool;
Expand All @@ -38,6 +39,7 @@
import jdk.vm.ci.meta.ResolvedJavaType;
import jdk.vm.ci.meta.Signature;
import jdk.vm.ci.meta.SpeculationLog;
import jdk.vm.ci.meta.annotation.AnnotationsInfo;

/**
* A minimal implementation of {@link ResolvedJavaMethod} for use by libgraal.
Expand Down Expand Up @@ -225,6 +227,16 @@ public Annotation[] getDeclaredAnnotations() {
throw new UnsupportedOperationException();
}

@Override
public <T> T getDeclaredAnnotationInfo(Function<AnnotationsInfo, T> parser) {
throw new UnsupportedOperationException();
}

@Override
public AnnotationsInfo getTypeAnnotationInfo() {
throw new UnsupportedOperationException();
}

@Override
public int getModifiers() {
return modifiers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;

import jdk.graal.compiler.core.common.LibGraalSupport;
import jdk.graal.compiler.debug.GraalError;
Expand All @@ -41,6 +42,7 @@
import jdk.vm.ci.meta.ResolvedJavaRecordComponent;
import jdk.vm.ci.meta.ResolvedJavaType;
import jdk.vm.ci.meta.UnresolvedJavaType;
import jdk.vm.ci.meta.annotation.AnnotationsInfo;

/**
* A minimal implementation of {@link ResolvedJavaType} for use by libgraal.
Expand Down Expand Up @@ -381,6 +383,16 @@ public Annotation[] getDeclaredAnnotations() {
throw new UnsupportedOperationException();
}

@Override
public <T> T getDeclaredAnnotationInfo(Function<AnnotationsInfo, T> parser) {
throw new UnsupportedOperationException();
}

@Override
public AnnotationsInfo getTypeAnnotationInfo() {
throw new UnsupportedOperationException();
}

@Override
public boolean isArray() {
return javaClass.isArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package jdk.graal.compiler.hotspot.replaycomp;

import static java.util.FormattableFlags.ALTERNATE;
import static jdk.graal.compiler.annotation.AnnotationValueSupport.ANNOTATIONS_INFO_PARSER;
import static jdk.graal.compiler.bytecode.Bytecodes.INVOKEDYNAMIC;
import static jdk.graal.compiler.bytecode.Bytecodes.INVOKEINTERFACE;
import static jdk.graal.compiler.bytecode.Bytecodes.INVOKESPECIAL;
Expand All @@ -45,6 +46,7 @@
import org.graalvm.collections.Equivalence;
import org.graalvm.collections.UnmodifiableEconomicMap;

import jdk.graal.compiler.annotation.AnnotationValueSupport;
import jdk.graal.compiler.bytecode.BytecodeStream;
import jdk.graal.compiler.core.common.CompilerProfiler;
import jdk.graal.compiler.debug.DebugContext;
Expand Down Expand Up @@ -796,6 +798,15 @@ public static CompilerInterfaceDeclarations build() {
return null;
})
.setStrategy(HotSpotResolvedJavaMethodProxy.getGenericParameterTypesMethod, MethodStrategy.Passthrough)
.setStrategy(HotSpotResolvedJavaMethodProxy.getDeclaredAnnotationInfoMethod, MethodStrategy.Passthrough)
.setFallbackInvocationHandler(HotSpotResolvedJavaMethodProxy.getDeclaredAnnotationInfoMethod, (proxy, method, args, metaAccess) -> {
// The HostInliningPhase can query Truffle-related annotations during replay on jargraal.
Object function = args[0];
if (function == ANNOTATIONS_INFO_PARSER) {
return AnnotationValueSupport.ParsedDeclaredAnnotationValues.NONE;
}
return null;
})
.setDefaultValueStrategy(HotSpotResolvedJavaMethodProxy.hasCodeAtLevelMethod, false)
.setDefaultValue(HotSpotResolvedJavaMethodProxy.isInVirtualMethodTableMethod, false)
.setDefaultValue(HotSpotResolvedJavaMethodProxy.intrinsicIdMethod, 0)
Expand Down
Loading