Merge
authorbrutisso
Thu, 28 Feb 2013 09:01:08 +0100
changeset 15812 532d71e2da3d
parent 15802 bc8dab3bb5f9 (current diff)
parent 15811 8214dcd0be2a (diff)
child 15818 7e6541a165ed
Merge
hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PermStat.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java	Thu Feb 28 09:01:08 2013 +0100
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2003, 2013, 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.tools;
+
+import java.io.*;
+import java.util.*;
+
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.memory.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.tools.*;
+import sun.jvm.hotspot.utilities.*;
+
+/**
+  A command line tool to print class loader statistics.
+*/
+
+public class ClassLoaderStats extends Tool {
+   boolean verbose = true;
+
+   public static void main(String[] args) {
+      ClassLoaderStats cls = new ClassLoaderStats();
+      cls.start(args);
+      cls.stop();
+   }
+
+   private static class ClassData {
+      Klass klass;
+      long  size;
+
+      ClassData(Klass klass, long size) {
+         this.klass = klass; this.size = size;
+      }
+   }
+
+   private static class LoaderData {
+      long     numClasses;
+      long     classSize;
+      List     classDetail = new ArrayList(); // List<ClassData>
+   }
+
+   public void run() {
+      printClassLoaderStatistics();
+   }
+
+   private void printClassLoaderStatistics() {
+      final PrintStream out = System.out;
+      final PrintStream err = System.err;
+      final Map loaderMap = new HashMap();
+      // loader data for bootstrap class loader
+      final LoaderData bootstrapLoaderData = new LoaderData();
+      if (verbose) {
+         err.print("finding class loader instances ..");
+      }
+
+      VM vm = VM.getVM();
+      ObjectHeap heap = vm.getObjectHeap();
+      Klass classLoaderKlass = vm.getSystemDictionary().getClassLoaderKlass();
+      try {
+         heap.iterateObjectsOfKlass(new DefaultHeapVisitor() {
+                         public boolean doObj(Oop oop) {
+                            loaderMap.put(oop, new LoaderData());
+                                                        return false;
+                         }
+                      }, classLoaderKlass);
+      } catch (Exception se) {
+         se.printStackTrace();
+      }
+
+      if (verbose) {
+         err.println("done.");
+         err.print("computing per loader stat ..");
+      }
+
+      SystemDictionary dict = VM.getVM().getSystemDictionary();
+      dict.classesDo(new SystemDictionary.ClassAndLoaderVisitor() {
+                        public void visit(Klass k, Oop loader) {
+                           if (! (k instanceof InstanceKlass)) {
+                              return;
+                           }
+                           LoaderData ld = (loader != null) ? (LoaderData)loaderMap.get(loader)
+                                                            : bootstrapLoaderData;
+                           if (ld != null) {
+                              ld.numClasses++;
+                              long size = computeSize((InstanceKlass)k);
+                              ld.classDetail.add(new ClassData(k, size));
+                              ld.classSize += size;
+                           }
+                        }
+                     });
+
+      if (verbose) {
+         err.println("done.");
+         err.print("please wait.. computing liveness");
+      }
+
+      // compute reverse pointer analysis (takes long time for larger app)
+      ReversePtrsAnalysis analysis = new ReversePtrsAnalysis();
+
+      if (verbose) {
+         analysis.setHeapProgressThunk(new HeapProgressThunk() {
+            public void heapIterationFractionUpdate(double fractionOfHeapVisited) {
+               err.print('.');
+            }
+            // This will be called after the iteration is complete
+            public void heapIterationComplete() {
+               err.println("done.");
+            }
+         });
+      }
+
+      try {
+         analysis.run();
+      } catch (Exception e) {
+         // e.printStackTrace();
+         if (verbose)
+           err.println("liveness analysis may be inaccurate ...");
+      }
+      ReversePtrs liveness = VM.getVM().getRevPtrs();
+
+      out.println("class_loader\tclasses\tbytes\tparent_loader\talive?\ttype");
+      out.println();
+
+      long numClassLoaders = 1L;
+      long totalNumClasses = bootstrapLoaderData.numClasses;
+      long totalClassSize  = bootstrapLoaderData.classSize;
+      long numAliveLoaders = 1L;
+      long numDeadLoaders  = 0L;
+
+      // print bootstrap loader details
+      out.print("<bootstrap>");
+      out.print('\t');
+      out.print(bootstrapLoaderData.numClasses);
+      out.print('\t');
+      out.print(bootstrapLoaderData.classSize);
+      out.print('\t');
+      out.print("  null  ");
+      out.print('\t');
+      // bootstrap loader is always alive
+      out.print("live");
+      out.print('\t');
+      out.println("<internal>");
+
+      for (Iterator keyItr = loaderMap.keySet().iterator(); keyItr.hasNext();) {
+         Oop loader = (Oop) keyItr.next();
+         LoaderData data = (LoaderData) loaderMap.get(loader);
+         numClassLoaders ++;
+         totalNumClasses += data.numClasses;
+         totalClassSize  += data.classSize;
+
+         out.print(loader.getHandle());
+         out.print('\t');
+         out.print(data.numClasses);
+         out.print('\t');
+         out.print(data.classSize);
+         out.print('\t');
+
+         class ParentFinder extends DefaultOopVisitor {
+            public void doOop(OopField field, boolean isVMField) {
+               if (field.getID().getName().equals("parent")) {
+                  parent = field.getValue(getObj());
+               }
+            }
+            private Oop parent = null;
+            public Oop getParent() { return parent; }
+         }
+
+         ParentFinder parentFinder = new ParentFinder();
+         loader.iterate(parentFinder, false);
+         Oop parent = parentFinder.getParent();
+         out.print((parent != null)? parent.getHandle().toString() : "  null  ");
+         out.print('\t');
+         boolean alive = (liveness != null) ? (liveness.get(loader) != null) : true;
+         out.print(alive? "live" : "dead");
+         if (alive) numAliveLoaders++; else numDeadLoaders++;
+         out.print('\t');
+         Klass loaderKlass = loader.getKlass();
+         if (loaderKlass != null) {
+            out.print(loaderKlass.getName().asString());
+            out.print('@');
+            out.print(loader.getKlass().getAddress());
+         } else {
+            out.print("    null!    ");
+         }
+         out.println();
+      }
+
+      out.println();
+      // summary line
+      out.print("total = ");
+      out.print(numClassLoaders);
+      out.print('\t');
+      out.print(totalNumClasses);
+      out.print('\t');
+      out.print(totalClassSize);
+      out.print('\t');
+      out.print("    N/A    ");
+      out.print('\t');
+      out.print("alive=");
+      out.print(numAliveLoaders);
+      out.print(", dead=");
+      out.print(numDeadLoaders);
+      out.print('\t');
+      out.print("    N/A    ");
+      out.println();
+   }
+
+   private static long objectSize(Oop oop) {
+      return oop == null ? 0L : oop.getObjectSize();
+   }
+
+   // Don't count the shared empty arrays
+   private static long arraySize(GenericArray arr) {
+     return arr.getLength() != 0L ? arr.getSize() : 0L;
+   }
+
+   private long computeSize(InstanceKlass k) {
+      long size = 0L;
+      // the InstanceKlass object itself
+      size += k.getSize();
+
+      // Constant pool
+      ConstantPool cp = k.getConstants();
+      size += cp.getSize();
+      if (cp.getCache() != null) {
+        size += cp.getCache().getSize();
+      }
+      size += arraySize(cp.getTags());
+
+      // Interfaces
+      size += arraySize(k.getLocalInterfaces());
+      size += arraySize(k.getTransitiveInterfaces());
+
+      // Inner classes
+      size += arraySize(k.getInnerClasses());
+
+      // Fields
+      size += arraySize(k.getFields());
+
+      // Methods
+      MethodArray methods = k.getMethods();
+      int nmethods = (int) methods.getLength();
+      if (nmethods != 0L) {
+         size += methods.getSize();
+         for (int i = 0; i < nmethods; ++i) {
+            Method m = methods.at(i);
+            size += m.getSize();
+            size += m.getConstMethod().getSize();
+         }
+      }
+
+      return size;
+   }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java	Wed Feb 27 12:20:34 2013 -0800
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java	Thu Feb 28 09:01:08 2013 +0100
@@ -57,17 +57,18 @@
       printGCAlgorithm(flagMap);
       System.out.println();
       System.out.println("Heap Configuration:");
-      printValue("MinHeapFreeRatio = ", getFlagValue("MinHeapFreeRatio", flagMap));
-      printValue("MaxHeapFreeRatio = ", getFlagValue("MaxHeapFreeRatio", flagMap));
-      printValMB("MaxHeapSize      = ", getFlagValue("MaxHeapSize", flagMap));
-      printValMB("NewSize          = ", getFlagValue("NewSize", flagMap));
-      printValMB("MaxNewSize       = ", getFlagValue("MaxNewSize", flagMap));
-      printValMB("OldSize          = ", getFlagValue("OldSize", flagMap));
-      printValue("NewRatio         = ", getFlagValue("NewRatio", flagMap));
-      printValue("SurvivorRatio    = ", getFlagValue("SurvivorRatio", flagMap));
-      printValMB("MetaspaceSize    = ", getFlagValue("MetaspaceSize", flagMap));
-      printValMB("MaxMetaspaceSize = ", getFlagValue("MaxMetaspaceSize", flagMap));
-      printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes());
+      printValue("MinHeapFreeRatio   = ", getFlagValue("MinHeapFreeRatio", flagMap));
+      printValue("MaxHeapFreeRatio   = ", getFlagValue("MaxHeapFreeRatio", flagMap));
+      printValMB("MaxHeapSize        = ", getFlagValue("MaxHeapSize", flagMap));
+      printValMB("NewSize            = ", getFlagValue("NewSize", flagMap));
+      printValMB("MaxNewSize         = ", getFlagValue("MaxNewSize", flagMap));
+      printValMB("OldSize            = ", getFlagValue("OldSize", flagMap));
+      printValue("NewRatio           = ", getFlagValue("NewRatio", flagMap));
+      printValue("SurvivorRatio      = ", getFlagValue("SurvivorRatio", flagMap));
+      printValMB("MetaspaceSize      = ", getFlagValue("MetaspaceSize", flagMap));
+      printValMB("ClassMetaspaceSize = ", getFlagValue("ClassMetaspaceSize", flagMap));
+      printValMB("MaxMetaspaceSize   = ", getFlagValue("MaxMetaspaceSize", flagMap));
+      printValMB("G1HeapRegionSize   = ", HeapRegion.grainBytes());
 
       System.out.println();
       System.out.println("Heap Usage:");
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JMap.java	Wed Feb 27 12:20:34 2013 -0800
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JMap.java	Thu Feb 28 09:01:08 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, 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
@@ -45,7 +45,7 @@
     }
 
     protected String getCommandFlags() {
-        return "-heap|-heap:format=b|-histo|-permstat|-finalizerinfo";
+        return "-heap|-heap:format=b|-histo|-clstats|-finalizerinfo";
     }
 
     protected void printFlagsUsage() {
@@ -53,14 +53,14 @@
         System.out.println("    -heap\tto print java heap summary");
         System.out.println("    -heap:format=b\tto dump java heap in hprof binary format");
         System.out.println("    -histo\tto print histogram of java object heap");
-        System.out.println("    -permstat\tto print permanent generation statistics");
+        System.out.println("    -clstats\tto print class loader statistics");
         System.out.println("    -finalizerinfo\tto print information on objects awaiting finalization");
         super.printFlagsUsage();
     }
 
     public static final int MODE_HEAP_SUMMARY = 0;
     public static final int MODE_HISTOGRAM = 1;
-    public static final int MODE_PERMSTAT = 2;
+    public static final int MODE_CLSTATS = 2;
     public static final int MODE_PMAP = 3;
     public static final int MODE_HEAP_GRAPH_HPROF_BIN = 4;
     public static final int MODE_HEAP_GRAPH_GXL = 5;
@@ -78,8 +78,8 @@
             tool = new ObjectHistogram();
             break;
 
-        case MODE_PERMSTAT:
-            tool = new PermStat();
+        case MODE_CLSTATS:
+            tool = new ClassLoaderStats();
             break;
 
         case MODE_PMAP:
@@ -118,7 +118,9 @@
             } else if (modeFlag.equals("-histo")) {
                 mode = MODE_HISTOGRAM;
             } else if (modeFlag.equals("-permstat")) {
-                mode = MODE_PERMSTAT;
+                mode = MODE_CLSTATS;
+            } else if (modeFlag.equals("-clstats")) {
+                mode = MODE_CLSTATS;
             } else if (modeFlag.equals("-finalizerinfo")) {
                 mode = MODE_FINALIZERINFO;
             } else {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PermStat.java	Wed Feb 27 12:20:34 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,277 +0,0 @@
-/*
- * Copyright (c) 2003, 2012, 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.tools;
-
-import java.io.*;
-import java.util.*;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.memory.*;
-import sun.jvm.hotspot.oops.*;
-import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.tools.*;
-import sun.jvm.hotspot.utilities.*;
-
-/**
-  A command line tool to print perm. generation statistics.
-*/
-
-public class PermStat extends Tool {
-   boolean verbose = true;
-
-   public static void main(String[] args) {
-      PermStat ps = new PermStat();
-      ps.start(args);
-      ps.stop();
-   }
-
-   private static class ClassData {
-      Klass klass;
-      long  size;
-
-      ClassData(Klass klass, long size) {
-         this.klass = klass; this.size = size;
-      }
-   }
-
-   private static class LoaderData {
-      long     numClasses;
-      long     classSize;
-      List     classDetail = new ArrayList(); // List<ClassData>
-   }
-
-   public void run() {
-      printClassLoaderStatistics();
-   }
-
-   private void printClassLoaderStatistics() {
-      final PrintStream out = System.out;
-      final PrintStream err = System.err;
-      final Map loaderMap = new HashMap();
-      // loader data for bootstrap class loader
-      final LoaderData bootstrapLoaderData = new LoaderData();
-      if (verbose) {
-         err.print("finding class loader instances ..");
-      }
-
-      VM vm = VM.getVM();
-      ObjectHeap heap = vm.getObjectHeap();
-      Klass classLoaderKlass = vm.getSystemDictionary().getClassLoaderKlass();
-      try {
-         heap.iterateObjectsOfKlass(new DefaultHeapVisitor() {
-                         public boolean doObj(Oop oop) {
-                            loaderMap.put(oop, new LoaderData());
-                                                        return false;
-                         }
-                      }, classLoaderKlass);
-      } catch (Exception se) {
-         se.printStackTrace();
-      }
-
-      if (verbose) {
-         err.println("done.");
-         err.print("computing per loader stat ..");
-      }
-
-      SystemDictionary dict = VM.getVM().getSystemDictionary();
-      dict.classesDo(new SystemDictionary.ClassAndLoaderVisitor() {
-                        public void visit(Klass k, Oop loader) {
-                           if (! (k instanceof InstanceKlass)) {
-                              return;
-                           }
-                           LoaderData ld = (loader != null) ? (LoaderData)loaderMap.get(loader)
-                                                            : bootstrapLoaderData;
-                           if (ld != null) {
-                              ld.numClasses++;
-                              long size = computeSize((InstanceKlass)k);
-                              ld.classDetail.add(new ClassData(k, size));
-                              ld.classSize += size;
-                           }
-                        }
-                     });
-
-      if (verbose) {
-         err.println("done.");
-         err.print("please wait.. computing liveness");
-      }
-
-      // compute reverse pointer analysis (takes long time for larger app)
-      ReversePtrsAnalysis analysis = new ReversePtrsAnalysis();
-
-      if (verbose) {
-         analysis.setHeapProgressThunk(new HeapProgressThunk() {
-            public void heapIterationFractionUpdate(double fractionOfHeapVisited) {
-               err.print('.');
-            }
-            // This will be called after the iteration is complete
-            public void heapIterationComplete() {
-               err.println("done.");
-            }
-         });
-      }
-
-      try {
-         analysis.run();
-      } catch (Exception e) {
-         // e.printStackTrace();
-         if (verbose)
-           err.println("liveness analysis may be inaccurate ...");
-      }
-      ReversePtrs liveness = VM.getVM().getRevPtrs();
-
-      out.println("class_loader\tclasses\tbytes\tparent_loader\talive?\ttype");
-      out.println();
-
-      long numClassLoaders = 1L;
-      long totalNumClasses = bootstrapLoaderData.numClasses;
-      long totalClassSize  = bootstrapLoaderData.classSize;
-      long numAliveLoaders = 1L;
-      long numDeadLoaders  = 0L;
-
-      // print bootstrap loader details
-      out.print("<bootstrap>");
-      out.print('\t');
-      out.print(bootstrapLoaderData.numClasses);
-      out.print('\t');
-      out.print(bootstrapLoaderData.classSize);
-      out.print('\t');
-      out.print("  null  ");
-      out.print('\t');
-      // bootstrap loader is always alive
-      out.print("live");
-      out.print('\t');
-      out.println("<internal>");
-
-      for (Iterator keyItr = loaderMap.keySet().iterator(); keyItr.hasNext();) {
-         Oop loader = (Oop) keyItr.next();
-         LoaderData data = (LoaderData) loaderMap.get(loader);
-         numClassLoaders ++;
-         totalNumClasses += data.numClasses;
-         totalClassSize  += data.classSize;
-
-         out.print(loader.getHandle());
-         out.print('\t');
-         out.print(data.numClasses);
-         out.print('\t');
-         out.print(data.classSize);
-         out.print('\t');
-
-         class ParentFinder extends DefaultOopVisitor {
-            public void doOop(OopField field, boolean isVMField) {
-               if (field.getID().getName().equals("parent")) {
-                  parent = field.getValue(getObj());
-               }
-            }
-            private Oop parent = null;
-            public Oop getParent() { return parent; }
-         }
-
-         ParentFinder parentFinder = new ParentFinder();
-         loader.iterate(parentFinder, false);
-         Oop parent = parentFinder.getParent();
-         out.print((parent != null)? parent.getHandle().toString() : "  null  ");
-         out.print('\t');
-         boolean alive = (liveness != null) ? (liveness.get(loader) != null) : true;
-         out.print(alive? "live" : "dead");
-         if (alive) numAliveLoaders++; else numDeadLoaders++;
-         out.print('\t');
-         Klass loaderKlass = loader.getKlass();
-         if (loaderKlass != null) {
-            out.print(loaderKlass.getName().asString());
-            out.print('@');
-            out.print(loader.getKlass().getAddress());
-         } else {
-            out.print("    null!    ");
-         }
-         out.println();
-      }
-
-      out.println();
-      // summary line
-      out.print("total = ");
-      out.print(numClassLoaders);
-      out.print('\t');
-      out.print(totalNumClasses);
-      out.print('\t');
-      out.print(totalClassSize);
-      out.print('\t');
-      out.print("    N/A    ");
-      out.print('\t');
-      out.print("alive=");
-      out.print(numAliveLoaders);
-      out.print(", dead=");
-      out.print(numDeadLoaders);
-      out.print('\t');
-      out.print("    N/A    ");
-      out.println();
-   }
-
-   private static long objectSize(Oop oop) {
-      return oop == null ? 0L : oop.getObjectSize();
-   }
-
-   // Don't count the shared empty arrays
-   private static long arraySize(GenericArray arr) {
-     return arr.getLength() != 0L ? arr.getSize() : 0L;
-   }
-
-   private long computeSize(InstanceKlass k) {
-      long size = 0L;
-      // the InstanceKlass object itself
-      size += k.getSize();
-
-      // Constant pool
-      ConstantPool cp = k.getConstants();
-      size += cp.getSize();
-      if (cp.getCache() != null) {
-        size += cp.getCache().getSize();
-      }
-      size += arraySize(cp.getTags());
-
-      // Interfaces
-      size += arraySize(k.getLocalInterfaces());
-      size += arraySize(k.getTransitiveInterfaces());
-
-      // Inner classes
-      size += arraySize(k.getInnerClasses());
-
-      // Fields
-      size += arraySize(k.getFields());
-
-      // Methods
-      MethodArray methods = k.getMethods();
-      int nmethods = (int) methods.getLength();
-      if (nmethods != 0L) {
-         size += methods.getSize();
-         for (int i = 0; i < nmethods; ++i) {
-            Method m = methods.at(i);
-            size += m.getSize();
-            size += m.getConstMethod().getSize();
-         }
-      }
-
-      return size;
-   }
-}
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Wed Feb 27 12:20:34 2013 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Thu Feb 28 09:01:08 2013 +0100
@@ -117,7 +117,7 @@
         if (G1Log::fine()) {
           gclog_or_tty->date_stamp(PrintGCDateStamps);
           gclog_or_tty->stamp(PrintGCTimeStamps);
-          gclog_or_tty->print_cr("[GC concurrent-root-region-scan-end, %1.7lf]",
+          gclog_or_tty->print_cr("[GC concurrent-root-region-scan-end, %1.7lf secs]",
                                  scan_end - scan_start);
         }
       }
@@ -150,7 +150,7 @@
           if (G1Log::fine()) {
             gclog_or_tty->date_stamp(PrintGCDateStamps);
             gclog_or_tty->stamp(PrintGCTimeStamps);
-            gclog_or_tty->print_cr("[GC concurrent-mark-end, %1.7lf sec]",
+            gclog_or_tty->print_cr("[GC concurrent-mark-end, %1.7lf secs]",
                                       mark_end_sec - mark_start_sec);
           }
 
@@ -234,7 +234,7 @@
         if (G1Log::fine()) {
           gclog_or_tty->date_stamp(PrintGCDateStamps);
           gclog_or_tty->stamp(PrintGCTimeStamps);
-          gclog_or_tty->print_cr("[GC concurrent-cleanup-end, %1.7lf]",
+          gclog_or_tty->print_cr("[GC concurrent-cleanup-end, %1.7lf secs]",
                                  cleanup_end_sec - cleanup_start_sec);
         }
       }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Feb 27 12:20:34 2013 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Thu Feb 28 09:01:08 2013 +0100
@@ -267,7 +267,15 @@
   double max_gc_time = (double) MaxGCPauseMillis / 1000.0;
   double time_slice  = (double) GCPauseIntervalMillis / 1000.0;
   _mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time);
-  _sigma = (double) G1ConfidencePercent / 100.0;
+
+  uintx confidence_perc = G1ConfidencePercent;
+  // Put an artificial ceiling on this so that it's not set to a silly value.
+  if (confidence_perc > 100) {
+    confidence_perc = 100;
+    warning("G1ConfidencePercent is set to a value that is too large, "
+            "it's been updated to %u", confidence_perc);
+  }
+  _sigma = (double) confidence_perc / 100.0;
 
   // start conservatively (around 50ms is about right)
   _concurrent_mark_remark_times_ms->add(0.05);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp	Wed Feb 27 12:20:34 2013 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp	Thu Feb 28 09:01:08 2013 +0100
@@ -32,7 +32,7 @@
 
 #define G1_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, manageable, product_rw) \
                                                                             \
-  product(intx, G1ConfidencePercent, 50,                                    \
+  product(uintx, G1ConfidencePercent, 50,                                   \
           "Confidence level for MMU/pause predictions")                     \
                                                                             \
   develop(intx, G1MarkingOverheadPercent, 0,                                \
--- a/hotspot/src/share/vm/runtime/atomic.hpp	Wed Feb 27 12:20:34 2013 -0800
+++ b/hotspot/src/share/vm/runtime/atomic.hpp	Thu Feb 28 09:01:08 2013 +0100
@@ -29,10 +29,17 @@
 
 class Atomic : AllStatic {
  public:
+  // Atomic operations on jlong types are not available on all 32-bit
+  // platforms. If atomic ops on jlongs are defined here they must only
+  // be used from code that verifies they are available at runtime and
+  // can provide an alternative action if not - see supports_cx8() for
+  // a means to test availability.
+
   // Atomically store to a location
   inline static void store    (jbyte    store_value, jbyte*    dest);
   inline static void store    (jshort   store_value, jshort*   dest);
   inline static void store    (jint     store_value, jint*     dest);
+  // See comment above about using jlong atomics on 32-bit platforms
   inline static void store    (jlong    store_value, jlong*    dest);
   inline static void store_ptr(intptr_t store_value, intptr_t* dest);
   inline static void store_ptr(void*    store_value, void*     dest);
@@ -40,17 +47,19 @@
   inline static void store    (jbyte    store_value, volatile jbyte*    dest);
   inline static void store    (jshort   store_value, volatile jshort*   dest);
   inline static void store    (jint     store_value, volatile jint*     dest);
+  // See comment above about using jlong atomics on 32-bit platforms
   inline static void store    (jlong    store_value, volatile jlong*    dest);
   inline static void store_ptr(intptr_t store_value, volatile intptr_t* dest);
   inline static void store_ptr(void*    store_value, volatile void*     dest);
 
+  // See comment above about using jlong atomics on 32-bit platforms
   inline static jlong load(volatile jlong* src);
 
   // Atomically add to a location, return updated value
   inline static jint     add    (jint     add_value, volatile jint*     dest);
   inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest);
   inline static void*    add_ptr(intptr_t add_value, volatile void*     dest);
-
+  // See comment above about using jlong atomics on 32-bit platforms
          static jlong    add    (jlong    add_value, volatile jlong*    dest);
 
   // Atomically increment location
@@ -75,6 +84,7 @@
   // barrier across the cmpxchg.  I.e., it's really a 'fence_cmpxchg_acquire'.
          static jbyte    cmpxchg    (jbyte    exchange_value, volatile jbyte*    dest, jbyte    compare_value);
   inline static jint     cmpxchg    (jint     exchange_value, volatile jint*     dest, jint     compare_value);
+  // See comment above about using jlong atomics on 32-bit platforms
   inline static jlong    cmpxchg    (jlong    exchange_value, volatile jlong*    dest, jlong    compare_value);
 
          static unsigned int cmpxchg(unsigned int exchange_value,
--- a/hotspot/src/share/vm/utilities/ostream.cpp	Wed Feb 27 12:20:34 2013 -0800
+++ b/hotspot/src/share/vm/utilities/ostream.cpp	Thu Feb 28 09:01:08 2013 +0100
@@ -431,7 +431,7 @@
 
 rotatingFileStream::rotatingFileStream(const char* file_name) {
   _cur_file_num = 0;
-  _bytes_writen = 0L;
+  _bytes_written = 0L;
   _file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal);
   jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num);
   _file = fopen(_file_name, "w");
@@ -440,7 +440,7 @@
 
 rotatingFileStream::rotatingFileStream(const char* file_name, const char* opentype) {
   _cur_file_num = 0;
-  _bytes_writen = 0L;
+  _bytes_written = 0L;
   _file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal);
   jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num);
   _file = fopen(_file_name, opentype);
@@ -448,10 +448,9 @@
 }
 
 void rotatingFileStream::write(const char* s, size_t len) {
-  if (_file != NULL)  {
-    // Make an unused local variable to avoid warning from gcc 4.x compiler.
+  if (_file != NULL) {
     size_t count = fwrite(s, 1, len, _file);
-    Atomic::add((jlong)count, &_bytes_writen);
+    _bytes_written += count;
   }
   update_position(s, len);
 }
@@ -465,7 +464,10 @@
 // concurrent GC threads to run parallel with VMThread at safepoint, write and rotate_log
 // must be synchronized.
 void rotatingFileStream::rotate_log() {
-  if (_bytes_writen < (jlong)GCLogFileSize) return;
+  if (_bytes_written < (jlong)GCLogFileSize) {
+    return;
+  }
+
 #ifdef ASSERT
   Thread *thread = Thread::current();
   assert(thread == NULL ||
@@ -475,7 +477,7 @@
   if (NumberOfGCLogFiles == 1) {
     // rotate in same file
     rewind();
-    _bytes_writen = 0L;
+    _bytes_written = 0L;
     return;
   }
 
@@ -491,7 +493,7 @@
   }
   _file = fopen(_file_name, "w");
   if (_file != NULL) {
-    _bytes_writen = 0L;
+    _bytes_written = 0L;
     _need_close = true;
   } else {
     tty->print_cr("failed to open rotation log file %s due to %s\n",
--- a/hotspot/src/share/vm/utilities/ostream.hpp	Wed Feb 27 12:20:34 2013 -0800
+++ b/hotspot/src/share/vm/utilities/ostream.hpp	Thu Feb 28 09:01:08 2013 +0100
@@ -231,7 +231,7 @@
 class rotatingFileStream : public fileStream {
  protected:
   char*  _file_name;
-  jlong  _bytes_writen;
+  jlong  _bytes_written;
   uintx  _cur_file_num;             // current logfile rotation number, from 0 to MaxGCLogFileNumbers-1
  public:
   rotatingFileStream(const char* file_name);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java	Thu Feb 28 09:01:08 2013 +0100
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test ClassMetaspaceSizeInJmapHeap
+ * @bug 8004924
+ * @summary Checks that jmap -heap contains the flag ClassMetaspaceSize
+ * @library /testlibrary
+ * @run main/othervm -XX:ClassMetaspaceSize=50m ClassMetaspaceSizeInJmapHeap
+ */
+
+import com.oracle.java.testlibrary.*;
+import java.nio.file.*;
+import java.io.File;
+import java.nio.charset.Charset;
+import java.util.List;
+
+public class ClassMetaspaceSizeInJmapHeap {
+    public static void main(String[] args) throws Exception {
+        String pid = Integer.toString(ProcessTools.getProcessId());
+
+        ProcessBuilder pb = new ProcessBuilder();
+        pb.command(JDKToolFinder.getJDKTool("jmap"), "-heap",  pid);
+
+        File out = new File("ClassMetaspaceSizeInJmapHeap.stdout.txt");
+        pb.redirectOutput(out);
+
+        File err = new File("ClassMetaspaceSizeInJmapHeap.stderr.txt");
+        pb.redirectError(err);
+
+        run(pb);
+
+        OutputAnalyzer output = new OutputAnalyzer(read(out));
+        output.shouldContain("ClassMetaspaceSize = 52428800 (50.0MB)");
+        out.delete();
+    }
+
+    private static void run(ProcessBuilder pb) throws Exception {
+        Process p = pb.start();
+        p.waitFor();
+        int exitValue = p.exitValue();
+        if (exitValue != 0) {
+            throw new Exception("jmap -heap exited with error code: " + exitValue);
+        }
+    }
+
+    private static String read(File f) throws Exception {
+        Path p = f.toPath();
+        List<String> lines = Files.readAllLines(p, Charset.defaultCharset());
+
+        StringBuilder sb = new StringBuilder();
+        for (String line : lines) {
+            sb.append(line).append('\n');
+        }
+        return sb.toString();
+    }
+}