8311946: add support for libgraal specific jtreg tests
Reviewed-by: kvn, thartmann
This commit is contained in:
parent
167d1c1835
commit
a63f865feb
@ -67,6 +67,33 @@ bool JVMCI::can_initialize_JVMCI() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JVMCI::get_shared_library_path(char* pathbuf, size_t pathlen, bool fail_is_fatal) {
|
||||||
|
if (JVMCILibPath != nullptr) {
|
||||||
|
if (!os::dll_locate_lib(pathbuf, pathlen, JVMCILibPath, JVMCI_SHARED_LIBRARY_NAME)) {
|
||||||
|
if (!fail_is_fatal) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
fatal("Unable to create path to JVMCI shared library based on value of JVMCILibPath (%s)", JVMCILibPath);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!os::dll_locate_lib(pathbuf, pathlen, Arguments::get_dll_dir(), JVMCI_SHARED_LIBRARY_NAME)) {
|
||||||
|
if (!fail_is_fatal) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
fatal("Unable to create path to JVMCI shared library");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JVMCI::shared_library_exists() {
|
||||||
|
if (_shared_library_handle != nullptr) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
char path[JVM_MAXPATHLEN];
|
||||||
|
return get_shared_library_path(path, sizeof(path), false);
|
||||||
|
}
|
||||||
|
|
||||||
void* JVMCI::get_shared_library(char*& path, bool load) {
|
void* JVMCI::get_shared_library(char*& path, bool load) {
|
||||||
void* sl_handle = _shared_library_handle;
|
void* sl_handle = _shared_library_handle;
|
||||||
if (sl_handle != nullptr || !load) {
|
if (sl_handle != nullptr || !load) {
|
||||||
@ -78,15 +105,7 @@ void* JVMCI::get_shared_library(char*& path, bool load) {
|
|||||||
if (_shared_library_handle == nullptr) {
|
if (_shared_library_handle == nullptr) {
|
||||||
char path[JVM_MAXPATHLEN];
|
char path[JVM_MAXPATHLEN];
|
||||||
char ebuf[1024];
|
char ebuf[1024];
|
||||||
if (JVMCILibPath != nullptr) {
|
get_shared_library_path(path, sizeof(path), true);
|
||||||
if (!os::dll_locate_lib(path, sizeof(path), JVMCILibPath, JVMCI_SHARED_LIBRARY_NAME)) {
|
|
||||||
fatal("Unable to create path to JVMCI shared library based on value of JVMCILibPath (%s)", JVMCILibPath);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!os::dll_locate_lib(path, sizeof(path), Arguments::get_dll_dir(), JVMCI_SHARED_LIBRARY_NAME)) {
|
|
||||||
fatal("Unable to create path to JVMCI shared library");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void* handle = os::dll_load(path, ebuf, sizeof ebuf);
|
void* handle = os::dll_load(path, ebuf, sizeof ebuf);
|
||||||
if (handle == nullptr) {
|
if (handle == nullptr) {
|
||||||
|
@ -101,6 +101,12 @@ class JVMCI : public AllStatic {
|
|||||||
// Gets the Thread* value for the current thread or null if it's not available.
|
// Gets the Thread* value for the current thread or null if it's not available.
|
||||||
static Thread* current_thread_or_null();
|
static Thread* current_thread_or_null();
|
||||||
|
|
||||||
|
// Writes into `pathbuf` the path to the existing JVMCI shared library file.
|
||||||
|
// If the file cannot be found and `fail_is_fatal` is true, then
|
||||||
|
// a fatal error occurs.
|
||||||
|
// Returns whether the path to an existing file was written into `pathbuf`.
|
||||||
|
static bool get_shared_library_path(char* pathbuf, size_t pathlen, bool fail_is_fatal);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum CodeInstallResult {
|
enum CodeInstallResult {
|
||||||
@ -122,6 +128,11 @@ class JVMCI : public AllStatic {
|
|||||||
return JVMCIThreadsPerNativeLibraryRuntime == 1 && JVMCICompilerIdleDelay == 0;
|
return JVMCIThreadsPerNativeLibraryRuntime == 1 && JVMCICompilerIdleDelay == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determines if the JVMCI shared library exists. This does not
|
||||||
|
// take into account whether loading the library would succeed
|
||||||
|
// if it's not already loaded.
|
||||||
|
static bool shared_library_exists();
|
||||||
|
|
||||||
// Gets the handle to the loaded JVMCI shared library, loading it
|
// Gets the handle to the loaded JVMCI shared library, loading it
|
||||||
// first if not yet loaded and `load` is true. The path from
|
// first if not yet loaded and `load` is true. The path from
|
||||||
// which the library is loaded is returned in `path`.
|
// which the library is loaded is returned in `path`.
|
||||||
|
@ -366,6 +366,13 @@ WB_ENTRY(jboolean, WB_IsGCSupported(JNIEnv* env, jobject o, jint name))
|
|||||||
return GCConfig::is_gc_supported((CollectedHeap::Name)name);
|
return GCConfig::is_gc_supported((CollectedHeap::Name)name);
|
||||||
WB_END
|
WB_END
|
||||||
|
|
||||||
|
WB_ENTRY(jboolean, WB_HasLibgraal(JNIEnv* env, jobject o))
|
||||||
|
#if INCLUDE_JVMCI
|
||||||
|
return JVMCI::shared_library_exists();
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
WB_END
|
||||||
|
|
||||||
WB_ENTRY(jboolean, WB_IsGCSupportedByJVMCICompiler(JNIEnv* env, jobject o, jint name))
|
WB_ENTRY(jboolean, WB_IsGCSupportedByJVMCICompiler(JNIEnv* env, jobject o, jint name))
|
||||||
#if INCLUDE_JVMCI
|
#if INCLUDE_JVMCI
|
||||||
if (EnableJVMCI) {
|
if (EnableJVMCI) {
|
||||||
@ -2803,6 +2810,7 @@ static JNINativeMethod methods[] = {
|
|||||||
{CC"isCDSIncluded", CC"()Z", (void*)&WB_IsCDSIncluded },
|
{CC"isCDSIncluded", CC"()Z", (void*)&WB_IsCDSIncluded },
|
||||||
{CC"isJFRIncluded", CC"()Z", (void*)&WB_IsJFRIncluded },
|
{CC"isJFRIncluded", CC"()Z", (void*)&WB_IsJFRIncluded },
|
||||||
{CC"isDTraceIncluded", CC"()Z", (void*)&WB_IsDTraceIncluded },
|
{CC"isDTraceIncluded", CC"()Z", (void*)&WB_IsDTraceIncluded },
|
||||||
|
{CC"hasLibgraal", CC"()Z", (void*)&WB_HasLibgraal },
|
||||||
{CC"isC2OrJVMCIIncluded", CC"()Z", (void*)&WB_isC2OrJVMCIIncluded },
|
{CC"isC2OrJVMCIIncluded", CC"()Z", (void*)&WB_isC2OrJVMCIIncluded },
|
||||||
{CC"isJVMCISupportedByGC", CC"()Z", (void*)&WB_IsJVMCISupportedByGC},
|
{CC"isJVMCISupportedByGC", CC"()Z", (void*)&WB_IsJVMCISupportedByGC},
|
||||||
{CC"canWriteJavaHeapArchive", CC"()Z", (void*)&WB_CanWriteJavaHeapArchive },
|
{CC"canWriteJavaHeapArchive", CC"()Z", (void*)&WB_CanWriteJavaHeapArchive },
|
||||||
|
@ -78,6 +78,8 @@ requires.properties= \
|
|||||||
vm.continuations \
|
vm.continuations \
|
||||||
vm.jvmti \
|
vm.jvmti \
|
||||||
vm.graal.enabled \
|
vm.graal.enabled \
|
||||||
|
jdk.hasLibgraal \
|
||||||
|
vm.libgraal.enabled \
|
||||||
vm.compiler1.enabled \
|
vm.compiler1.enabled \
|
||||||
vm.compiler2.enabled \
|
vm.compiler2.enabled \
|
||||||
vm.musl \
|
vm.musl \
|
||||||
|
@ -123,6 +123,10 @@ public class VMProps implements Callable<Map<String, String>> {
|
|||||||
map.put("vm.continuations", this::vmContinuations);
|
map.put("vm.continuations", this::vmContinuations);
|
||||||
// vm.graal.enabled is true if Graal is used as JIT
|
// vm.graal.enabled is true if Graal is used as JIT
|
||||||
map.put("vm.graal.enabled", this::isGraalEnabled);
|
map.put("vm.graal.enabled", this::isGraalEnabled);
|
||||||
|
// jdk.hasLibgraal is true if the libgraal shared library file is present
|
||||||
|
map.put("jdk.hasLibgraal", this::hasLibgraal);
|
||||||
|
// vm.libgraal.enabled is true if libgraal is used as JIT
|
||||||
|
map.put("vm.libgraal.enabled", this::isLibgraalEnabled);
|
||||||
map.put("vm.compiler1.enabled", this::isCompiler1Enabled);
|
map.put("vm.compiler1.enabled", this::isCompiler1Enabled);
|
||||||
map.put("vm.compiler2.enabled", this::isCompiler2Enabled);
|
map.put("vm.compiler2.enabled", this::isCompiler2Enabled);
|
||||||
map.put("docker.support", this::dockerSupport);
|
map.put("docker.support", this::dockerSupport);
|
||||||
@ -486,6 +490,24 @@ public class VMProps implements Callable<Map<String, String>> {
|
|||||||
return "" + Compiler.isGraalEnabled();
|
return "" + Compiler.isGraalEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the libgraal shared library file is present.
|
||||||
|
*
|
||||||
|
* @return true if the libgraal shared library file is present.
|
||||||
|
*/
|
||||||
|
protected String hasLibgraal() {
|
||||||
|
return "" + WB.hasLibgraal();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if libgraal is used as JIT compiler.
|
||||||
|
*
|
||||||
|
* @return true if libgraal is used as JIT compiler.
|
||||||
|
*/
|
||||||
|
protected String isLibgraalEnabled() {
|
||||||
|
return "" + Compiler.isLibgraalEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if Compiler1 is present.
|
* Check if Compiler1 is present.
|
||||||
*
|
*
|
||||||
@ -709,6 +731,7 @@ public class VMProps implements Callable<Map<String, String>> {
|
|||||||
}
|
}
|
||||||
List<String> lines = new ArrayList<>();
|
List<String> lines = new ArrayList<>();
|
||||||
map.forEach((k, v) -> lines.add(k + ":" + v));
|
map.forEach((k, v) -> lines.add(k + ":" + v));
|
||||||
|
Collections.sort(lines);
|
||||||
try {
|
try {
|
||||||
Files.write(Paths.get(dumpFileName), lines,
|
Files.write(Paths.get(dumpFileName), lines,
|
||||||
StandardOpenOption.APPEND, StandardOpenOption.CREATE);
|
StandardOpenOption.APPEND, StandardOpenOption.CREATE);
|
||||||
|
@ -303,6 +303,9 @@ public class WhiteBox {
|
|||||||
public native void NMTArenaMalloc(long arena, long size);
|
public native void NMTArenaMalloc(long arena, long size);
|
||||||
|
|
||||||
// Compiler
|
// Compiler
|
||||||
|
|
||||||
|
// Determines if the libgraal shared library file is present.
|
||||||
|
public native boolean hasLibgraal();
|
||||||
public native boolean isC2OrJVMCIIncluded();
|
public native boolean isC2OrJVMCIIncluded();
|
||||||
public native boolean isJVMCISupportedByGC();
|
public native boolean isJVMCISupportedByGC();
|
||||||
|
|
||||||
|
@ -88,6 +88,25 @@ public class Compiler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if libgraal is used as JIT compiler.
|
||||||
|
*
|
||||||
|
* libraal is enabled if isGraalEnabled is true and:
|
||||||
|
* - UseJVMCINativeLibrary flag is true
|
||||||
|
*
|
||||||
|
* @return true if libgraal is used as JIT compiler.
|
||||||
|
*/
|
||||||
|
public static boolean isLibgraalEnabled() {
|
||||||
|
if (!isGraalEnabled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Boolean useJvmciNativeLibrary = WB.getBooleanVMFlag("UseJVMCINativeLibrary");
|
||||||
|
if (useJvmciNativeLibrary == null || !useJvmciNativeLibrary) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if C2 is used as JIT compiler.
|
* Check if C2 is used as JIT compiler.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user