8217474: Remove WhiteBox.getConcurrentGCPhases()
authorkbarrett
Tue, 05 Feb 2019 16:46:49 -0500
changeset 53647 82c95d4b61f0
parent 53646 043ae846819f
child 53648 6d37b8ec36fa
8217474: Remove WhiteBox.getConcurrentGCPhases() Summary: Remove function and supporting infrastructure. Reviewed-by: shade, tschatzl
src/hotspot/share/gc/g1/g1CollectedHeap.cpp
src/hotspot/share/gc/g1/g1CollectedHeap.hpp
src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp
src/hotspot/share/gc/g1/g1ConcurrentMarkThread.hpp
src/hotspot/share/gc/shared/collectedHeap.cpp
src/hotspot/share/gc/shared/collectedHeap.hpp
src/hotspot/share/prims/whitebox.cpp
test/hotspot/jtreg/gc/concurrent_phase_control/CheckSupported.java
test/hotspot/jtreg/gc/concurrent_phase_control/CheckUnsupported.java
test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlG1Basics.java
test/lib/sun/hotspot/WhiteBox.java
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Tue Feb 05 15:12:13 2019 -0500
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Tue Feb 05 16:46:49 2019 -0500
@@ -2323,10 +2323,6 @@
   return true;
 }
 
-const char* const* G1CollectedHeap::concurrent_phases() const {
-  return _cm_thread->concurrent_phases();
-}
-
 bool G1CollectedHeap::request_concurrent_phase(const char* phase) {
   return _cm_thread->request_concurrent_phase(phase);
 }
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Tue Feb 05 15:12:13 2019 -0500
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Tue Feb 05 16:46:49 2019 -0500
@@ -1369,7 +1369,6 @@
 
   // WhiteBox testing support.
   virtual bool supports_concurrent_phase_control() const;
-  virtual const char* const* concurrent_phases() const;
   virtual bool request_concurrent_phase(const char* phase);
 
   virtual WorkGang* get_safepoint_workers() { return _workers; }
--- a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp	Tue Feb 05 15:12:13 2019 -0500
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp	Tue Feb 05 16:46:49 2019 -0500
@@ -224,10 +224,6 @@
   { }
 };
 
-const char* const* G1ConcurrentMarkThread::concurrent_phases() const {
-  return concurrent_phase_names;
-}
-
 bool G1ConcurrentMarkThread::request_concurrent_phase(const char* phase_name) {
   int phase = lookup_concurrent_phase(phase_name);
   if (phase < 0) return false;
--- a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.hpp	Tue Feb 05 15:12:13 2019 -0500
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.hpp	Tue Feb 05 16:46:49 2019 -0500
@@ -90,7 +90,6 @@
   bool during_cycle()      { return !idle(); }
 
   // WhiteBox testing support.
-  const char* const* concurrent_phases() const;
   bool request_concurrent_phase(const char* phase);
 
   ConcurrentGCPhaseManager::Stack* phase_manager_stack() {
--- a/src/hotspot/share/gc/shared/collectedHeap.cpp	Tue Feb 05 15:12:13 2019 -0500
+++ b/src/hotspot/share/gc/shared/collectedHeap.cpp	Tue Feb 05 16:46:49 2019 -0500
@@ -161,11 +161,6 @@
   return false;
 }
 
-const char* const* CollectedHeap::concurrent_phases() const {
-  static const char* const result[] = { NULL };
-  return result;
-}
-
 bool CollectedHeap::request_concurrent_phase(const char* phase) {
   return false;
 }
--- a/src/hotspot/share/gc/shared/collectedHeap.hpp	Tue Feb 05 15:12:13 2019 -0500
+++ b/src/hotspot/share/gc/shared/collectedHeap.hpp	Tue Feb 05 16:46:49 2019 -0500
@@ -534,12 +534,6 @@
   // The default implementation returns false.
   virtual bool supports_concurrent_phase_control() const;
 
-  // Return a NULL terminated array of concurrent phase names provided
-  // by this collector.  Supports Whitebox testing.  These are the
-  // names recognized by request_concurrent_phase(). The default
-  // implementation returns an array of one NULL element.
-  virtual const char* const* concurrent_phases() const;
-
   // Request the collector enter the indicated concurrent phase, and
   // wait until it does so.  Supports WhiteBox testing.  Only one
   // request may be active at a time.  Phases are designated by name;
--- a/src/hotspot/share/prims/whitebox.cpp	Tue Feb 05 15:12:13 2019 -0500
+++ b/src/hotspot/share/prims/whitebox.cpp	Tue Feb 05 16:46:49 2019 -0500
@@ -394,32 +394,6 @@
   return Universe::heap()->supports_concurrent_phase_control();
 WB_END
 
-WB_ENTRY(jobjectArray, WB_GetConcurrentGCPhases(JNIEnv* env, jobject o))
-  const char* const* phases = Universe::heap()->concurrent_phases();
-  jint nphases = 0;
-  for ( ; phases[nphases] != NULL; ++nphases) ;
-
-  ResourceMark rm(thread);
-  ThreadToNativeFromVM ttn(thread);
-  jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string());
-  CHECK_JNI_EXCEPTION_(env, NULL);
-
-  jobjectArray result = env->NewObjectArray(nphases, clazz, NULL);
-  CHECK_JNI_EXCEPTION_(env, NULL);
-
-  // If push fails, return with pending exception.
-  if (env->PushLocalFrame(nphases) < 0) return NULL;
-  for (jint i = 0; i < nphases; ++i) {
-    jstring phase = env->NewStringUTF(phases[i]);
-    CHECK_JNI_EXCEPTION_(env, NULL);
-    env->SetObjectArrayElement(result, i, phase);
-    CHECK_JNI_EXCEPTION_(env, NULL);
-  }
-  env->PopLocalFrame(NULL);
-
-  return result;
-WB_END
-
 WB_ENTRY(jboolean, WB_RequestConcurrentGCPhase(JNIEnv* env, jobject o, jstring name))
   Handle h_name(THREAD, JNIHandles::resolve(name));
   ResourceMark rm;
@@ -2351,8 +2325,6 @@
   {CC"isGCSelected",              CC"(I)Z",           (void*)&WB_IsGCSelected},
   {CC"isGCSelectedErgonomically", CC"()Z",            (void*)&WB_IsGCSelectedErgonomically},
   {CC"supportsConcurrentGCPhaseControl", CC"()Z",     (void*)&WB_SupportsConcurrentGCPhaseControl},
-  {CC"getConcurrentGCPhases",     CC"()[Ljava/lang/String;",
-                                                      (void*)&WB_GetConcurrentGCPhases},
   {CC"requestConcurrentGCPhase0", CC"(Ljava/lang/String;)Z",
                                                       (void*)&WB_RequestConcurrentGCPhase},
   {CC"checkLibSpecifiesNoexecstack", CC"(Ljava/lang/String;)Z",
--- a/test/hotspot/jtreg/gc/concurrent_phase_control/CheckSupported.java	Tue Feb 05 15:12:13 2019 -0500
+++ b/test/hotspot/jtreg/gc/concurrent_phase_control/CheckSupported.java	Tue Feb 05 16:46:49 2019 -0500
@@ -30,66 +30,18 @@
  */
 
 import sun.hotspot.WhiteBox;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
 
 public class CheckSupported {
 
     private static final WhiteBox WB = WhiteBox.getWhiteBox();
 
-    private static Set<String> toSet(List<String> list, String which)
-        throws Exception
-    {
-        Set<String> result = new HashSet<String>(list);
-        if (result.size() < list.size()) {
-            throw new RuntimeException(which + " phases contains duplicates");
-        }
-        return result;
-    }
-
-    private static void checkPhases(String[] expectedPhases) throws Exception {
-        String[] actualPhases = WB.getConcurrentGCPhases();
-
-        List<String> expectedList = Arrays.asList(expectedPhases);
-        List<String> actualList = Arrays.asList(actualPhases);
-
-        Set<String> expected = toSet(expectedList, "Expected");
-        Set<String> actual = toSet(actualList, "Actual");
-
-        expected.removeAll(actualList);
-        actual.removeAll(expectedList);
-
-        boolean match = true;
-        if (!expected.isEmpty()) {
-            match = false;
-            System.out.println("Unexpected phases:");
-            for (String s: expected) {
-                System.out.println("  " + s);
-            }
-        }
-        if (!actual.isEmpty()) {
-            match = false;
-            System.out.println("Expected but missing phases:");
-            for (String s: actual) {
-                System.out.println("  " + s);
-            }
-        }
-        if (!match) {
-            throw new RuntimeException("Mismatch between expected and actual phases");
-        }
-    }
-
-    public static void check(String gcName, String[] phases) throws Exception {
+    public static void check(String gcName) throws Exception {
         // Verify supported.
         if (!WB.supportsConcurrentGCPhaseControl()) {
             throw new RuntimeException(
                 gcName + " unexpectedly missing phase control support");
         }
 
-        checkPhases(phases);
-
         // Verify IllegalArgumentException thrown by request attempt
         // with unknown phase.
         boolean illegalArgumentThrown = false;
--- a/test/hotspot/jtreg/gc/concurrent_phase_control/CheckUnsupported.java	Tue Feb 05 15:12:13 2019 -0500
+++ b/test/hotspot/jtreg/gc/concurrent_phase_control/CheckUnsupported.java	Tue Feb 05 16:46:49 2019 -0500
@@ -42,13 +42,6 @@
                 gcName + " unexpectedly supports phase control");
         }
 
-        // Verify phase sequence is empty.
-        String[] phases = WB.getConcurrentGCPhases();
-        if (phases.length > 0) {
-            throw new RuntimeException(
-                gcName + " unexpectedly has non-empty phases");
-        }
-
         // Verify IllegalStateException thrown by request attempt.
         boolean illegalStateThrown = false;
         try {
--- a/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlG1Basics.java	Tue Feb 05 15:12:13 2019 -0500
+++ b/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlG1Basics.java	Tue Feb 05 16:46:49 2019 -0500
@@ -27,8 +27,7 @@
  * @test TestConcurrentPhaseControlG1Basics
  * @bug 8169517
  * @requires vm.gc.G1
- * @summary Verify G1 supports concurrent phase control and has the
- * expected set of phases.
+ * @summary Verify G1 supports concurrent phase control.
  * @key gc
  * @modules java.base
  * @library /test/lib /
@@ -45,22 +44,7 @@
 
 public class TestConcurrentPhaseControlG1Basics {
 
-    private static final String[] phases = {
-        "ANY",
-        "IDLE",
-        "CONCURRENT_CYCLE",
-        "CLEAR_CLAIMED_MARKS",
-        "SCAN_ROOT_REGIONS",
-        "CONCURRENT_MARK",
-        "MARK_FROM_ROOTS",
-        "PRECLEAN",
-        "BEFORE_REMARK",
-        "REMARK",
-        "REBUILD_REMEMBERED_SETS",
-        "CLEANUP_FOR_NEXT_MARK",
-    };
-
     public static void main(String[] args) throws Exception {
-        CheckSupported.check("G1", phases);
+        CheckSupported.check("G1");
     }
 }
--- a/test/lib/sun/hotspot/WhiteBox.java	Tue Feb 05 15:12:13 2019 -0500
+++ b/test/lib/sun/hotspot/WhiteBox.java	Tue Feb 05 16:46:49 2019 -0500
@@ -402,11 +402,6 @@
   // always fail.
   public native boolean supportsConcurrentGCPhaseControl();
 
-  // Returns an array of concurrent phase names provided by this
-  // collector.  These are the names recognized by
-  // requestConcurrentGCPhase().
-  public native String[] getConcurrentGCPhases();
-
   // Attempt to put the collector into the indicated concurrent phase,
   // and attempt to remain in that state until a new request is made.
   //