Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8348347

Cleanup JavaThread subclass support in SA

XMLWordPrintable

    • b11

      There are a number of cleanups that can be done for the JavaThread subclass support in SA:

      1. CodeCacheSweeperThread is gone from hotspot. Remove from SA.

      Update: Actually it has already been for the most part removed. isisCodeCacheSweeperThread() is the only remnant and it is covered bye (3) below.

      2. isCompilerThread() is only used in one place, and it should be using isHiddenFromExternalView() instead. Make this switch and remove isCompilerThread().

      3. The following are not used and can be removed:

        public boolean isCodeCacheSweeperThread() { return false; }
        public boolean isHiddenFromExternalView() { return false; }
        public boolean isJvmtiAgentThread() { return false; }
        public boolean isWatcherThread() { return false; }
        public boolean isServiceThread() { return false; }
        public boolean isMonitorDeflationThread() { return false; }
        public boolean isAttachListenerThread() { return false; }
        public boolean isDeoptimizeObjectsALotThread() { return false; }

      4. The last cleanup suggestion is a bit more complex. We have the following subclasses of JavaThread:

      JvmtiAgentThread
      AttachListenerThread
      NotificationThread
      CompilerThread
      ServiceThread
      MonitorDeflationThread
      StringDedupThread
      DeoptimizeObjectsALotThread

      It looks like we could get rid of all these JavaThread subclasses in SA in favor of a couple additional generic subclasses. The first would be called something like SystemJavaThread. This would be for JavaThreads that return false for isJavaThread(), which would be every current subclass of JavaThread (the list above).

      Then we also need a subclass of SystemJavaThread called HiddenSystemJavaThread. This would be for all the SystemJavaThreads that override isHiddenFromExternalView() to return false. I believe that would be just these 3:

      JvmtiAgentThread
      AttachListenerThread
      NotificationThread

      We could then modify the addMapping() code to look like:

              virtualConstructor.addMapping("JavaThread", JavaThread.class);

              virtualConstructor.addMapping("JvmtiAgentThread", SystemJavaThread.class);
              virtualConstructor.addMapping("NotificationThread", SystemJavaThread.class);
              virtualConstructor.addMapping("AttachListenerThread", SystemJavaThread.class);

              virtualConstructor.addMapping("CompilerThread", HiddenSystemJavaThread.class);
              virtualConstructor.addMapping("ServiceThread", HiddenSystemJavaThread.class);
              virtualConstructor.addMapping("MonitorDeflationThread", HiddenSystemJavaThread.class);
              virtualConstructor.addMapping("StringDedupThread", HiddenSystemJavaThread.class);
              virtualConstructor.addMapping("DeoptimizeObjectsALotThread", HiddenSystemJavaThread.class);

      After doing this, we would not need to implement any of these other JavaThread subclasses in SA. We only need to implement JavaThread, SystemJavaThread, and HiddenSystemJavaThread.

      One downside to this is that if SA ever needs to know more about a JavaThread subclass than if is "pure" and if it is visible, then we are back to making an explicit SA implementation of that subclass. For example, see JDK-8348317. In order to get isHiddenFromExternalView() to work the way it should for JVMCI CompilerThreads, we need a CompilerThread subclass that overrides isHiddenFromExternalView() and does the extra logic to decide if the thread should be hidden or not. We may want to keep CompilerThread around for that reason.

            cjplummer Chris Plummer
            cjplummer Chris Plummer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: