diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index b7e12fc1c92..2c389d37fec 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -747,6 +747,14 @@ WB_ENTRY(void, WB_NMTArenaMalloc(JNIEnv* env, jobject o, jlong arena, jlong size a->Amalloc(size_t(size)); WB_END +WB_ENTRY(jboolean, WB_isC2Included(JNIEnv* env)) +#ifdef COMPILER2 + return true; +#else + return false; +#endif +WB_END + static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { assert(method != nullptr, "method should not be null"); ThreadToNativeFromVM ttn(thread); @@ -2843,6 +2851,7 @@ static JNINativeMethod methods[] = { {CC"NMTNewArena", CC"(J)J", (void*)&WB_NMTNewArena }, {CC"NMTFreeArena", CC"(J)V", (void*)&WB_NMTFreeArena }, {CC"NMTArenaMalloc", CC"(JJ)V", (void*)&WB_NMTArenaMalloc }, + {CC"isC2Included", CC"()Z", (void*)&WB_isC2Included }, {CC"deoptimizeFrames", CC"(Z)I", (void*)&WB_DeoptimizeFrames }, {CC"isFrameDeoptimized", CC"(I)Z", (void*)&WB_IsFrameDeoptimized}, {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, diff --git a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java index 36e38e6e2fb..68391893a32 100644 --- a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java +++ b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java @@ -86,7 +86,7 @@ public class TestGCLogMessages { } public boolean isAvailable() { - return Compiler.isC2Enabled(); + return Compiler.isC2Included(); } } diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java index 311502a16e2..c4b2da9beb0 100644 --- a/test/lib/jdk/test/whitebox/WhiteBox.java +++ b/test/lib/jdk/test/whitebox/WhiteBox.java @@ -336,6 +336,8 @@ public class WhiteBox { // Compiler + public native boolean isC2Included(); + public native int matchesMethod(Executable method, String pattern); public native int matchesInline(Executable method, String pattern); public native boolean shouldPrintAssembly(Executable method, int comp_level); diff --git a/test/lib/jdk/test/whitebox/code/Compiler.java b/test/lib/jdk/test/whitebox/code/Compiler.java index 333ca42782c..2450fa81ee6 100644 --- a/test/lib/jdk/test/whitebox/code/Compiler.java +++ b/test/lib/jdk/test/whitebox/code/Compiler.java @@ -34,6 +34,15 @@ public class Compiler { private static final WhiteBox WB = WhiteBox.getWhiteBox(); + /** + * Check if C2 was included in the VM build + * + * @return true if C2 was included in the VM build. + */ + public static boolean isC2Included() { + return WB.isC2Included(); + } + /** * Check if C2 is used as JIT compiler. *