8062735: CodeCacheSweeperThread missing from SA
authoranoll
Thu, 06 Nov 2014 07:27:25 +0100
changeset 27475 1f22a5d5be00
parent 27474 2b061fd571eb
child 27477 1b27e73be477
8062735: CodeCacheSweeperThread missing from SA Summary: Make SA aware of the code cache sweeper thread Reviewed-by: kvn, coleenp, sspitsyn
hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/CodeCacheSweeperThread.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/JavaThread.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Thread.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js
hotspot/src/share/vm/runtime/vmStructs.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/CodeCacheSweeperThread.java	Thu Nov 06 07:27:25 2014 +0100
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.runtime;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.types.*;
+
+public class CodeCacheSweeperThread extends JavaThread {
+  public CodeCacheSweeperThread(Address addr) {
+    super(addr);
+  }
+
+  public boolean isJavaThread() { return false; }
+  public boolean isHiddenFromExternalView() { return true; }
+  public boolean isCodeCacheSweeperThread() { return true; }
+
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/JavaThread.java	Thu Nov 06 01:31:31 2014 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/JavaThread.java	Thu Nov 06 07:27:25 2014 +0100
@@ -118,9 +118,10 @@
     return VM.getVM().getThreads().createJavaThreadWrapper(threadAddr);
   }
 
-  /** NOTE: for convenience, this differs in definition from the
-      underlying VM. Only "pure" JavaThreads return true;
-      CompilerThreads and JVMDIDebuggerThreads return false. FIXME:
+  /** NOTE: for convenience, this differs in definition from the underlying VM.
+      Only "pure" JavaThreads return true; CompilerThreads, the CodeCacheSweeperThread,
+      JVMDIDebuggerThreads return false.
+      FIXME:
       consider encapsulating platform-specific functionality in an
       object instead of using inheritance (which is the primary reason
       we can't traverse CompilerThreads, etc; didn't want to have, for
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Thread.java	Thu Nov 06 01:31:31 2014 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Thread.java	Thu Nov 06 07:27:25 2014 +0100
@@ -111,14 +111,15 @@
     return allocatedBytesField.getValue(addr);
   }
 
-  public boolean   isVMThread()                { return false; }
-  public boolean   isJavaThread()              { return false; }
-  public boolean   isCompilerThread()          { return false; }
-  public boolean   isHiddenFromExternalView()  { return false; }
-  public boolean   isJvmtiAgentThread()        { return false; }
-  public boolean   isWatcherThread()           { return false; }
+  public boolean   isVMThread()                  { return false; }
+  public boolean   isJavaThread()                { return false; }
+  public boolean   isCompilerThread()            { return false; }
+  public boolean   isCodeCacheSweeperThread()    { return false; }
+  public boolean   isHiddenFromExternalView()    { return false; }
+  public boolean   isJvmtiAgentThread()          { return false; }
+  public boolean   isWatcherThread()             { return false; }
   public boolean   isConcurrentMarkSweepThread() { return false; }
-  public boolean   isServiceThread()           { return false; }
+  public boolean   isServiceThread()             { return false; }
 
   /** Memory operations */
   public void oopsDo(AddressVisitor oopVisitor) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java	Thu Nov 06 01:31:31 2014 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java	Thu Nov 06 07:27:25 2014 +0100
@@ -120,6 +120,7 @@
         virtualConstructor.addMapping("JavaThread", JavaThread.class);
         if (!VM.getVM().isCore()) {
             virtualConstructor.addMapping("CompilerThread", CompilerThread.class);
+            virtualConstructor.addMapping("CodeCacheSweeperThread", CodeCacheSweeperThread.class);
         }
         // for now, use JavaThread itself. fix it later with appropriate class if needed
         virtualConstructor.addMapping("SurrogateLockerThread", JavaThread.class);
@@ -164,7 +165,7 @@
             return thread;
         } catch (Exception e) {
             throw new RuntimeException("Unable to deduce type of thread from address " + threadAddr +
-            " (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread, or SurrogateLockerThread)", e);
+            " (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread, SurrogateLockerThread, or CodeCacheSweeperThread)", e);
         }
     }
 
@@ -201,7 +202,7 @@
     public List getPendingThreads(ObjectMonitor monitor) {
         List pendingThreads = new ArrayList();
         for (JavaThread thread = first(); thread != null; thread = thread.next()) {
-            if (thread.isCompilerThread()) {
+            if (thread.isCompilerThread() || thread.isCodeCacheSweeperThread()) {
                 continue;
             }
             ObjectMonitor pending = thread.getCurrentPendingMonitor();
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js	Thu Nov 06 01:31:31 2014 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js	Thu Nov 06 07:27:25 2014 +0100
@@ -836,6 +836,7 @@
 // Java Threads
 vmType2Class["JavaThread"] = sapkg.runtime.JavaThread;
 vmType2Class["CompilerThread"] = sapkg.runtime.CompilerThread;
+vmType2Class["CodeCacheSweeperThread"] = sapkg.runtime.CodeCacheSweeperThread;
 vmType2Class["SurrogateLockerThread"] = sapkg.runtime.JavaThread;
 vmType2Class["DebuggerThread"] = sapkg.runtime.DebuggerThread;
 
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Thu Nov 06 01:31:31 2014 +0000
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Thu Nov 06 07:27:25 2014 +0100
@@ -1594,6 +1594,7 @@
            declare_type(JvmtiAgentThread, JavaThread)                     \
            declare_type(ServiceThread, JavaThread)                        \
   declare_type(CompilerThread, JavaThread)                                \
+  declare_type(CodeCacheSweeperThread, JavaThread)                        \
   declare_toplevel_type(OSThread)                                         \
   declare_toplevel_type(JavaFrameAnchor)                                  \
                                                                           \