From 3a3040f1c9452ccb7a294cb166f31197f2354a21 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Thu, 27 Apr 2017 13:07:23 -0700 Subject: [PATCH] 8177845: Need a mechanism to load Graal Reviewed-by: kvn, mchung --- jdk/make/launcher/Launcher-jdk.aot.gmk | 16 +++++++ .../share/classes/jdk/internal/misc/VM.java | 42 +++++++++++++------ .../unix/classes/module-info.java.extra | 9 ---- jdk/test/tools/jimage/VerifyJimage.java | 10 +++-- 4 files changed, 52 insertions(+), 25 deletions(-) diff --git a/jdk/make/launcher/Launcher-jdk.aot.gmk b/jdk/make/launcher/Launcher-jdk.aot.gmk index a827a66bc35..9aea620ac9e 100644 --- a/jdk/make/launcher/Launcher-jdk.aot.gmk +++ b/jdk/make/launcher/Launcher-jdk.aot.gmk @@ -25,9 +25,25 @@ include LauncherCommon.gmk +# The JVMCI exports are needed since JVMCI is normally dynamically exported +# (see jdk.vm.ci.services.internal.ReflectionAccessJDK::openJVMCITo). + $(eval $(call SetupBuildLauncher, jaotc, \ MAIN_CLASS := jdk.tools.jaotc.Main, \ JAVA_ARGS := -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.sparc=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ + --add-exports=jdk.internal.vm.ci/jdk.vm.ci.sparc=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \ -XX:+UseAOT \ -Djvmci.UseProfilingInformation=false \ -Dgraal.UseExceptionProbability=false \ diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java b/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java index 695795e4338..95961c74584 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java @@ -26,7 +26,10 @@ package jdk.internal.misc; import static java.lang.Thread.State.*; +import java.util.Map; +import java.util.HashMap; import java.util.Properties; +import java.util.Collections; public class VM { @@ -132,25 +135,33 @@ public class VM { * Returns the system property of the specified key saved at * system initialization time. This method should only be used * for the system properties that are not changed during runtime. - * It accesses a private copy of the system properties so - * that user's locking of the system properties object will not - * cause the library to deadlock. * * Note that the saved system properties do not include - * the ones set by sun.misc.Version.init(). - * + * the ones set by java.lang.VersionProps.init(). */ public static String getSavedProperty(String key) { - if (savedProps.isEmpty()) - throw new IllegalStateException("Should be non-empty if initialized"); + if (savedProps == null) + throw new IllegalStateException("Not yet initialized"); - return savedProps.getProperty(key); + return savedProps.get(key); } - // TODO: the Property Management needs to be refactored and - // the appropriate prop keys need to be accessible to the - // calling classes to avoid duplication of keys. - private static final Properties savedProps = new Properties(); + /** + * Gets an unmodifiable view of the system properties saved at system + * initialization time. This method should only be used + * for the system properties that are not changed during runtime. + * + * Note that the saved system properties do not include + * the ones set by java.lang.VersionProps.init(). + */ + public static Map getSavedProperties() { + if (savedProps == null) + throw new IllegalStateException("Not yet initialized"); + + return savedProps; + } + + private static Map savedProps; // Save a private copy of the system properties and remove // the system properties that are not intended for public access. @@ -160,7 +171,12 @@ public class VM { if (initLevel() != 0) throw new IllegalStateException("Wrong init level"); - savedProps.putAll(props); + @SuppressWarnings({"rawtypes", "unchecked"}) + Map sp = + Map.ofEntries(props.entrySet().toArray(new Map.Entry[0])); + // only main thread is running at this time, so savedProps and + // its content will be correctly published to threads started later + savedProps = sp; // Set the maximum amount of direct memory. This value is controlled // by the vm option -XX:MaxDirectMemorySize=. diff --git a/jdk/src/java.base/unix/classes/module-info.java.extra b/jdk/src/java.base/unix/classes/module-info.java.extra index 833b0964309..2dc36bf4b53 100644 --- a/jdk/src/java.base/unix/classes/module-info.java.extra +++ b/jdk/src/java.base/unix/classes/module-info.java.extra @@ -23,14 +23,5 @@ * questions. */ -// jdk.internal.vm.compiler uses Unsafe and VM classes from jdk.internal.misc -exports jdk.internal.misc to jdk.internal.vm.compiler; -opens jdk.internal.misc to jdk.internal.vm.compiler; - -// jdk.internal.vm.compiler uses com.sun.crypto.provider to generate crypto intrinsics -opens com.sun.crypto.provider to jdk.internal.vm.compiler; - -exports jdk.internal.module to jdk.internal.vm.compiler; - // AOT uses jdk.internal.misc.Unsafe exports jdk.internal.misc to jdk.aot; diff --git a/jdk/test/tools/jimage/VerifyJimage.java b/jdk/test/tools/jimage/VerifyJimage.java index e4fcd9ca667..9ed9880d0a5 100644 --- a/jdk/test/tools/jimage/VerifyJimage.java +++ b/jdk/test/tools/jimage/VerifyJimage.java @@ -195,15 +195,19 @@ public class VerifyJimage { .replaceAll("\\.class$", "").replace('/', '.'); } - private static Set DEPLOY_MODULES = - Set.of("javafx.deploy", "jdk.deploy", "jdk.plugin", "jdk.javaws"); + private static Set EXCLUDED_MODULES = + Set.of("javafx.deploy", "jdk.deploy", "jdk.plugin", "jdk.javaws", + // All JVMCI packages other than jdk.vm.ci.services are dynamically + // exported to jdk.internal.vm.compiler and jdk.aot + "jdk.internal.vm.compiler", "jdk.aot" + ); private boolean accept(String entry) { int index = entry.indexOf('/', 1); String mn = index > 1 ? entry.substring(1, index) : ""; // filter deployment modules - if (mn.isEmpty() || DEPLOY_MODULES.contains(mn)) { + if (mn.isEmpty() || EXCLUDED_MODULES.contains(mn)) { return false; } return entry.endsWith(".class") && !entry.endsWith(MODULE_INFO);