Skip to content

Commit b13c2fa

Browse files
author
Christian Wimmer
committed
[GR-45327] Remove JDK 11 support from native image code.
PullRequest: graal/14266
2 parents b99ab9c + 3c36689 commit b13c2fa

File tree

57 files changed

+204
-927
lines changed

Some content is hidden

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

57 files changed

+204
-927
lines changed

common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"jdks": {
1111
"oraclejdk11": {"name": "jpg-jdk", "version": "11.0.11", "build_id": "9", "release": true, "platformspecific": true, "extrabundles": ["static-libs"] },
1212

13-
"oraclejdk17": {"name": "jpg-jdk", "version": "17.0.1", "build_id": "12", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
13+
"oraclejdk17": {"name": "jpg-jdk", "version": "17.0.6", "build_id": "9", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
1414
"labsjdk-ce-17": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.0-b10", "platformspecific": true },
1515
"labsjdk-ce-17Debug": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.0-b10-debug", "platformspecific": true },
1616
"labsjdk-ce-17-llvm": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.0-b10-sulong", "platformspecific": true },

substratevm/mx.substratevm/suite.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@
270270
"sun.util.calendar",
271271
"sun.util.locale.provider",
272272
"sun.util.resources",
273+
"jdk.internal.access",
273274
"jdk.internal.event",
274275
"jdk.internal.loader",
275276
"jdk.internal.logger",
@@ -428,6 +429,11 @@
428429
"LLVM_PLATFORM_SPECIFIC_SHADOWED",
429430
"JAVACPP_PLATFORM_SPECIFIC_SHADOWED",
430431
],
432+
"requiresConcealed" : {
433+
"java.base" : [
434+
"jdk.internal.misc",
435+
],
436+
},
431437
"checkstyle": "com.oracle.svm.core",
432438
"javaCompliance" : "17+",
433439
"annotationProcessors": [
@@ -595,6 +601,7 @@
595601
"requiresConcealed" : {
596602
"java.base" : [
597603
"jdk.internal",
604+
"jdk.internal.access",
598605
"jdk.internal.event",
599606
"jdk.internal.loader",
600607
"jdk.internal.misc",

substratevm/src/com.oracle.graal.pointsto.standalone/src/com/oracle/graal/pointsto/standalone/PointsToAnalyzer.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import org.graalvm.compiler.options.OptionValues;
4646
import org.graalvm.compiler.phases.util.Providers;
4747
import org.graalvm.compiler.printer.GraalDebugHandlersFactory;
48-
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
4948
import org.graalvm.compiler.word.WordTypes;
5049
import org.graalvm.nativeimage.hosted.Feature;
5150

@@ -93,11 +92,9 @@ public final class PointsToAnalyzer {
9392
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "jdk.internal.misc");
9493
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.text.spi");
9594
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "jdk.internal.org.objectweb.asm");
96-
if (JavaVersionUtil.JAVA_SPEC >= 16) {
97-
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.reflect.annotation");
98-
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.security.jca");
99-
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "jdk.jdeps", "com.sun.tools.classfile");
100-
}
95+
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.reflect.annotation");
96+
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.security.jca");
97+
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "jdk.jdeps", "com.sun.tools.classfile");
10198
}
10299

103100
private final StandalonePointsToAnalysis bigbang;

substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMGenerator.java

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
import org.graalvm.compiler.core.common.type.RawPointerStamp;
6464
import org.graalvm.compiler.core.common.type.Stamp;
6565
import org.graalvm.compiler.core.common.type.StampFactory;
66-
import org.graalvm.compiler.debug.GraalError;
6766
import org.graalvm.compiler.graph.Node;
6867
import org.graalvm.compiler.lir.LIRFrameState;
6968
import org.graalvm.compiler.lir.LIRInstruction;
@@ -82,7 +81,6 @@
8281
import org.graalvm.compiler.nodes.cfg.HIRBlock;
8382
import org.graalvm.compiler.nodes.type.NarrowOopStamp;
8483
import org.graalvm.compiler.phases.util.Providers;
85-
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
8684
import org.graalvm.nativeimage.AnnotationAccess;
8785
import org.graalvm.nativeimage.c.constant.CEnum;
8886
import org.graalvm.nativeimage.c.function.CEntryPoint;
@@ -128,8 +126,8 @@
128126
import com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef;
129127
import com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef;
130128
import com.oracle.svm.shadowed.org.bytedeco.llvm.global.LLVM;
131-
import com.oracle.svm.util.ReflectionUtil;
132129

130+
import jdk.internal.misc.Unsafe;
133131
import jdk.vm.ci.code.CallingConvention;
134132
import jdk.vm.ci.code.CodeCacheProvider;
135133
import jdk.vm.ci.code.DebugInfo;
@@ -1812,7 +1810,7 @@ public enum DebugLevel {
18121810

18131811
@Override
18141812
public void emitCacheWriteback(Value address) {
1815-
int cacheLineSize = getDataCacheLineFlushSize();
1813+
int cacheLineSize = Unsafe.getUnsafe().dataCacheLineFlushSize();
18161814
if (cacheLineSize == 0) {
18171815
throw shouldNotReachHere("cache writeback with cache line size of 0"); // ExcludeFromJacocoGeneratedReport
18181816
}
@@ -1825,28 +1823,4 @@ public void emitCacheWriteback(Value address) {
18251823
public void emitCacheWritebackSync(boolean isPreSync) {
18261824
throw unimplemented("cache sync barrier (GR-30894)"); // ExcludeFromJacocoGeneratedReport
18271825
}
1828-
1829-
private static final int dataCacheLineFlushSize = initDataCacheLineFlushSize();
1830-
1831-
/**
1832-
* Gets the value of {@code jdk.internal.misc.UnsafeConstants.DATA_CACHE_LINE_FLUSH_SIZE} which
1833-
* was introduced after JDK 11 by JEP 352.
1834-
*
1835-
* This method uses reflection to be compatible with JDK 11 and earlier.
1836-
*/
1837-
private static int initDataCacheLineFlushSize() {
1838-
if (JavaVersionUtil.JAVA_SPEC <= 11) {
1839-
return 0;
1840-
}
1841-
try {
1842-
Class<?> c = Class.forName("jdk.internal.misc.UnsafeConstants");
1843-
return ReflectionUtil.readStaticField(c, "DATA_CACHE_LINE_FLUSH_SIZE");
1844-
} catch (ClassNotFoundException e) {
1845-
throw new GraalError(e, "Expected UnsafeConstants.DATA_CACHE_LINE_FLUSH_SIZE to exist and be readable");
1846-
}
1847-
}
1848-
1849-
private static int getDataCacheLineFlushSize() {
1850-
return dataCacheLineFlushSize;
1851-
}
18521826
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -841,16 +841,7 @@ public ReportingSupport(Path reportingPath) {
841841
public static int getPageSize() {
842842
int value = PageSize.getValue();
843843
if (value == 0) {
844-
try {
845-
/*
846-
* On JDK 17 and later, this is just a final field access that can never fail. But
847-
* on JDK 11, it is a native method call with some corner cases that can throw an
848-
* exception.
849-
*/
850-
return Unsafe.getUnsafe().pageSize();
851-
} catch (IllegalArgumentException e) {
852-
return 4096;
853-
}
844+
return Unsafe.getUnsafe().pageSize();
854845
}
855846
assert value > 0;
856847
return value;

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_PhantomReference.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,10 @@
2929
import com.oracle.svm.core.SubstrateUtil;
3030
import com.oracle.svm.core.annotate.Substitute;
3131
import com.oracle.svm.core.annotate.TargetClass;
32-
import com.oracle.svm.core.annotate.TargetElement;
33-
import com.oracle.svm.core.jdk.JDK17OrLater;
3432

3533
@TargetClass(PhantomReference.class)
3634
public final class Target_java_lang_ref_PhantomReference<T> {
3735
@Substitute
38-
@TargetElement(onlyWith = JDK17OrLater.class)
3936
boolean refersTo0(Object obj) {
4037
return ReferenceInternals.refersTo(SubstrateUtil.cast(this, PhantomReference.class), obj);
4138
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_java_lang_ref_Reference.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@
4444
import com.oracle.svm.core.annotate.RecomputeFieldValue;
4545
import com.oracle.svm.core.annotate.Substitute;
4646
import com.oracle.svm.core.annotate.TargetClass;
47-
import com.oracle.svm.core.annotate.TargetElement;
48-
import com.oracle.svm.core.jdk.JDK17OrLater;
49-
import com.oracle.svm.core.jdk.JDK17_0_2OrLater;
5047
import com.oracle.svm.core.util.VMError;
5148
import com.oracle.svm.util.ReflectionUtil;
5249

@@ -131,21 +128,17 @@ public void clear() {
131128
}
132129

133130
@Substitute
134-
@TargetElement(onlyWith = JDK17OrLater.class)
135131
private void clear0() {
136132
clear();
137133
}
138134

139135
@KeepOriginal
140-
@TargetElement(onlyWith = JDK17_0_2OrLater.class)
141136
native boolean refersToImpl(T obj);
142137

143138
@KeepOriginal
144-
@TargetElement(onlyWith = JDK17OrLater.class)
145139
public native boolean refersTo(T obj);
146140

147141
@Substitute
148-
@TargetElement(onlyWith = JDK17OrLater.class)
149142
boolean refersTo0(Object obj) {
150143
return ReferenceInternals.refersTo(SubstrateUtil.cast(this, Reference.class), obj);
151144
}
@@ -174,11 +167,9 @@ static void reachabilityFence(Object ref) {
174167
}
175168

176169
@KeepOriginal
177-
@TargetElement(onlyWith = JDK17OrLater.class) //
178170
native T getFromInactiveFinalReference();
179171

180172
@Substitute //
181-
@TargetElement(onlyWith = JDK17OrLater.class) //
182173
void clearInactiveFinalReference() {
183174
// assert this instanceof FinalReference;
184175
assert next != null; // I.e. FinalReference is inactive

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Target_jdk_internal_ref_Cleaner.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,6 @@ public final class Target_jdk_internal_ref_Cleaner {
5050
native void clean();
5151
}
5252

53-
/**
54-
* On JDK11+, the cleaner infrastructure is quite different from JDK8:
55-
* <ul>
56-
* <li>java.lang.ref.Cleaner: starts a new thread to process its reference queue.</li>
57-
* <li>jdk.internal.ref.CleanerFactory: provides a common cleaner with a shared cleaner thread. In
58-
* native-image, we do not necessarily spawn a separate thread for processing references, but may
59-
* drain the queue after garbage collection.</li>
60-
* <li>jdk.internal.ref.Cleaner: this only seems to be used by DirectByteBuffer but at least the
61-
* handling is the same as on JDK 8.
62-
* </ul>
63-
*/
6453
@TargetClass(className = "jdk.internal.ref.CleanerFactory")
6554
final class Target_jdk_internal_ref_CleanerFactory {
6655
@Alias

0 commit comments

Comments
 (0)