changeset 26929:71df0764084d

Merge
author coleenp
date Fri, 26 Sep 2014 18:59:09 -0400
parents 744b310d4fdd b9bd979b7d75
children 03e80d01349b
files
diffstat 7 files changed, 149 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/agent/src/os/win32/windbg/sawindbg.cpp	Fri Sep 26 17:11:27 2014 -0400
+++ b/hotspot/agent/src/os/win32/windbg/sawindbg.cpp	Fri Sep 26 18:59:09 2014 -0400
@@ -318,12 +318,18 @@
 
   path = (jstring) env->GetStaticObjectField(clazz, imagePath_ID);
   CHECK_EXCEPTION_(false);
+  if (path == NULL) {
+     THROW_NEW_DEBUGGER_EXCEPTION_("Windbg Error: not able to get imagePath field ID!", false);
+  }
   buf = env->GetStringUTFChars(path, &isCopy);
   CHECK_EXCEPTION_(false);
   AutoJavaString imagePath(env, path, buf);
 
   path = (jstring) env->GetStaticObjectField(clazz, symbolPath_ID);
   CHECK_EXCEPTION_(false);
+  if (path == NULL) {
+     THROW_NEW_DEBUGGER_EXCEPTION_("Windbg Error: not able to get symbolPath field ID!", false);
+  }
   buf = env->GetStringUTFChars(path, &isCopy);
   CHECK_EXCEPTION_(false);
   AutoJavaString symbolPath(env, path, buf);
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp	Fri Sep 26 17:11:27 2014 -0400
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp	Fri Sep 26 18:59:09 2014 -0400
@@ -636,6 +636,7 @@
     }
 
     // set the classLoader field in the java_lang_Class instance
+    assert(class_loader() == k->class_loader(), "should be same");
     set_class_loader(mirror(), class_loader());
 
     // Setup indirection from klass->mirror last
--- a/hotspot/src/share/vm/classfile/symbolTable.cpp	Fri Sep 26 17:11:27 2014 -0400
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp	Fri Sep 26 18:59:09 2014 -0400
@@ -496,77 +496,65 @@
 void SymbolTable::print_histogram() {
   MutexLocker ml(SymbolTable_lock);
   const int results_length = 100;
-  int results[results_length];
+  int counts[results_length];
+  int sizes[results_length];
   int i,j;
 
   // initialize results to zero
   for (j = 0; j < results_length; j++) {
-    results[j] = 0;
+    counts[j] = 0;
+    sizes[j] = 0;
   }
 
-  int total = 0;
-  int max_symbols = 0;
-  int out_of_range = 0;
-  int memory_total = 0;
-  int count = 0;
+  int total_size = 0;
+  int total_count = 0;
+  int total_length = 0;
+  int max_length = 0;
+  int out_of_range_count = 0;
+  int out_of_range_size = 0;
   for (i = 0; i < the_table()->table_size(); i++) {
     HashtableEntry<Symbol*, mtSymbol>* p = the_table()->bucket(i);
     for ( ; p != NULL; p = p->next()) {
-      memory_total += p->literal()->size();
-      count++;
-      int counter = p->literal()->utf8_length();
-      total += counter;
-      if (counter < results_length) {
-        results[counter]++;
+      int size = p->literal()->size();
+      int len = p->literal()->utf8_length();
+      if (len < results_length) {
+        counts[len]++;
+        sizes[len] += size;
       } else {
-        out_of_range++;
+        out_of_range_count++;
+        out_of_range_size += size;
       }
-      max_symbols = MAX2(max_symbols, counter);
+      total_count++;
+      total_size += size;
+      total_length += len;
+      max_length = MAX2(max_length, len);
     }
   }
-  tty->print_cr("Symbol Table:");
-  tty->print_cr("Total number of symbols  %5d", count);
-  tty->print_cr("Total size in memory     %5dK",
-          (memory_total*HeapWordSize)/1024);
-  tty->print_cr("Total counted            %5d", _symbols_counted);
-  tty->print_cr("Total removed            %5d", _symbols_removed);
+  tty->print_cr("Symbol Table Histogram:");
+  tty->print_cr("  Total number of symbols  %7d", total_count);
+  tty->print_cr("  Total size in memory     %7dK",
+          (total_size*HeapWordSize)/1024);
+  tty->print_cr("  Total counted            %7d", _symbols_counted);
+  tty->print_cr("  Total removed            %7d", _symbols_removed);
   if (_symbols_counted > 0) {
-    tty->print_cr("Percent removed          %3.2f",
+    tty->print_cr("  Percent removed          %3.2f",
           ((float)_symbols_removed/(float)_symbols_counted)* 100);
   }
-  tty->print_cr("Reference counts         %5d", Symbol::_total_count);
-  tty->print_cr("Symbol arena size        %5d used %5d",
-                 arena()->size_in_bytes(), arena()->used());
-  tty->print_cr("Histogram of symbol length:");
-  tty->print_cr("%8s %5d", "Total  ", total);
-  tty->print_cr("%8s %5d", "Maximum", max_symbols);
-  tty->print_cr("%8s %3.2f", "Average",
-          ((float) total / (float) the_table()->table_size()));
-  tty->print_cr("%s", "Histogram:");
-  tty->print_cr(" %s %29s", "Length", "Number chains that length");
+  tty->print_cr("  Reference counts         %7d", Symbol::_total_count);
+  tty->print_cr("  Symbol arena used        %7dK", arena()->used()/1024);
+  tty->print_cr("  Symbol arena size        %7dK", arena()->size_in_bytes()/1024);
+  tty->print_cr("  Total symbol length      %7d", total_length);
+  tty->print_cr("  Maximum symbol length    %7d", max_length);
+  tty->print_cr("  Average symbol length    %7.2f", ((float) total_length / (float) total_count));
+  tty->print_cr("  Symbol length histogram:");
+  tty->print_cr("    %6s %10s %10s", "Length", "#Symbols", "Size");
   for (i = 0; i < results_length; i++) {
-    if (results[i] > 0) {
-      tty->print_cr("%6d %10d", i, results[i]);
+    if (counts[i] > 0) {
+      tty->print_cr("    %6d %10d %10dK", i, counts[i], (sizes[i]*HeapWordSize)/1024);
     }
   }
-  if (Verbose) {
-    int line_length = 70;
-    tty->print_cr("%s %30s", " Length", "Number chains that length");
-    for (i = 0; i < results_length; i++) {
-      if (results[i] > 0) {
-        tty->print("%4d", i);
-        for (j = 0; (j < results[i]) && (j < line_length);  j++) {
-          tty->print("%1s", "*");
-        }
-        if (j == line_length) {
-          tty->print("%1s", "+");
-        }
-        tty->cr();
-      }
-    }
-  }
-  tty->print_cr(" %s %d: %d\n", "Number chains longer than",
-                    results_length, out_of_range);
+  tty->print_cr("  >=%6d %10d %10dK\n", results_length,
+          out_of_range_count, (out_of_range_size*HeapWordSize)/1024);
 }
 
 void SymbolTable::print() {
--- a/hotspot/src/share/vm/oops/arrayKlass.cpp	Fri Sep 26 17:11:27 2014 -0400
+++ b/hotspot/src/share/vm/oops/arrayKlass.cpp	Fri Sep 26 18:59:09 2014 -0400
@@ -92,7 +92,7 @@
   ResourceMark rm(THREAD);
   k->initialize_supers(super_klass(), CHECK);
   k->vtable()->initialize_vtable(false, CHECK);
-  java_lang_Class::create_mirror(k, Handle(NULL), Handle(NULL), CHECK);
+  java_lang_Class::create_mirror(k, Handle(THREAD, k->class_loader()), Handle(NULL), CHECK);
 }
 
 GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots) {
--- a/hotspot/src/share/vm/services/mallocTracker.cpp	Fri Sep 26 17:11:27 2014 -0400
+++ b/hotspot/src/share/vm/services/mallocTracker.cpp	Fri Sep 26 18:59:09 2014 -0400
@@ -140,11 +140,6 @@
     return NULL;
   }
 
-  // Check malloc size, size has to <= MAX_MALLOC_SIZE. This is only possible on 32-bit
-  // systems, when malloc size >= 1GB, but is is safe to assume it won't happen.
-  if (size > MAX_MALLOC_SIZE) {
-    fatal("Should not use malloc for big memory block, use virtual memory instead");
-  }
   // Uses placement global new operator to initialize malloc header
   switch(level) {
     case NMT_off:
@@ -154,10 +149,12 @@
       break;
     }
     case NMT_summary: {
+      assert(size <= MAX_MALLOC_SIZE, "malloc size overrun for NMT");
       header = ::new (malloc_base) MallocHeader(size, flags);
       break;
     }
     case NMT_detail: {
+      assert(size <= MAX_MALLOC_SIZE, "malloc size overrun for NMT");
       header = ::new (malloc_base) MallocHeader(size, flags, stack);
       break;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/LoadClass/ShowClassLoader.java	Fri Sep 26 18:59:09 2014 -0400
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @key regression
+ * @bug 8058927
+ * @summary Make sure array class has the right class loader
+ * @run main ShowClassLoader
+ */
+
+public class ShowClassLoader {
+
+    public static void main(String[] args) {
+        Object[] oa = new Object[0];
+        ShowClassLoader[] sa = new ShowClassLoader[0];
+
+        System.out.println("Classloader for Object[] is " + oa.getClass().getClassLoader());
+        System.out.println("Classloader for SCL[] is " + sa.getClass().getClassLoader() );
+
+        if (sa.getClass().getClassLoader() == null) {
+            throw new RuntimeException("Wrong class loader");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/NMT/UnsafeMallocLimit2.java	Fri Sep 26 18:59:09 2014 -0400
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @bug 8058818
+ * @library /testlibrary
+ * @build UnsafeMallocLimit2
+ * @run main/othervm -Xmx32m -XX:NativeMemoryTracking=off UnsafeMallocLimit2
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+
+public class UnsafeMallocLimit2 {
+
+    public static void main(String args[]) throws Exception {
+        if (Platform.is32bit()) {
+            Unsafe unsafe = Utils.getUnsafe();
+            try {
+                // Allocate greater than MALLOC_MAX and likely won't fail to allocate,
+                // so it hits the NMT code that asserted.
+                // Test that this doesn't cause an assertion with NMT off.
+                // The option above overrides if all the tests are run with NMT on.
+                unsafe.allocateMemory(0x40000000);
+                System.out.println("Allocation succeeded");
+            } catch (OutOfMemoryError e) {
+                System.out.println("Allocation failed");
+            }
+        } else {
+            System.out.println("Test only valid on 32-bit platforms");
+        }
+    }
+}