Merge
authorcoleenp
Mon, 24 Jul 2017 22:56:43 +0000
changeset 46712 15288889f0c6
parent 46710 941f16147746 (current diff)
parent 46711 0ccef2260315 (diff)
child 46713 97900a4c5ff4
child 46714 3cc3fd32a5d6
Merge
--- a/hotspot/src/share/vm/services/memBaseline.cpp	Mon Jul 24 17:46:06 2017 -0400
+++ b/hotspot/src/share/vm/services/memBaseline.cpp	Mon Jul 24 22:56:43 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, 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
@@ -59,6 +59,15 @@
   return s1.call_stack()->compare(*s2.call_stack());
 }
 
+// Sort into allocation site addresses and memory type order for baseline comparison
+int compare_malloc_site_and_type(const MallocSite& s1, const MallocSite& s2) {
+  int res = compare_malloc_site(s1, s2);
+  if (res == 0) {
+    res = (int)(s1.flags() - s2.flags());
+  }
+
+  return res;
+}
 
 int compare_virtual_memory_site(const VirtualMemoryAllocationSite& s1,
   const VirtualMemoryAllocationSite& s2) {
@@ -225,6 +234,9 @@
     case by_site:
       malloc_sites_to_allocation_site_order();
       break;
+    case by_site_and_type:
+      malloc_sites_to_allocation_site_and_type_order();
+      break;
     case by_address:
     default:
       ShouldNotReachHere();
@@ -263,7 +275,7 @@
 }
 
 void MemBaseline::malloc_sites_to_allocation_site_order() {
-  if (_malloc_sites_order != by_site) {
+  if (_malloc_sites_order != by_site && _malloc_sites_order != by_site_and_type) {
     SortedLinkedList<MallocSite, compare_malloc_site> tmp;
     // Add malloc sites to sorted linked list to sort into site (address) order
     tmp.move(&_malloc_sites);
@@ -273,6 +285,17 @@
   }
 }
 
+void MemBaseline::malloc_sites_to_allocation_site_and_type_order() {
+  if (_malloc_sites_order != by_site_and_type) {
+    SortedLinkedList<MallocSite, compare_malloc_site_and_type> tmp;
+    // Add malloc sites to sorted linked list to sort into site (address) order
+    tmp.move(&_malloc_sites);
+    _malloc_sites.set_head(tmp.head());
+    tmp.set_head(NULL);
+    _malloc_sites_order = by_site_and_type;
+  }
+}
+
 void MemBaseline::virtual_memory_sites_to_size_order() {
   if (_virtual_memory_sites_order != by_size) {
     SortedLinkedList<VirtualMemoryAllocationSite, compare_virtual_memory_size> tmp;
--- a/hotspot/src/share/vm/services/memBaseline.hpp	Mon Jul 24 17:46:06 2017 -0400
+++ b/hotspot/src/share/vm/services/memBaseline.hpp	Mon Jul 24 22:56:43 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, 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
@@ -55,9 +55,10 @@
   };
 
   enum SortingOrder {
-    by_address,   // by memory address
-    by_size,      // by memory size
-    by_site       // by call site where the memory is allocated from
+    by_address,      // by memory address
+    by_size,         // by memory size
+    by_site,         // by call site where the memory is allocated from
+    by_site_and_type // by call site and memory type
   };
 
  private:
@@ -188,6 +189,8 @@
   void malloc_sites_to_size_order();
   // Sort allocation sites in call site address order
   void malloc_sites_to_allocation_site_order();
+  // Sort allocation sites in call site address and memory type order
+  void malloc_sites_to_allocation_site_and_type_order();
 
   // Sort allocation sites in reserved size order
   void virtual_memory_sites_to_size_order();
--- a/hotspot/src/share/vm/services/memReporter.cpp	Mon Jul 24 17:46:06 2017 -0400
+++ b/hotspot/src/share/vm/services/memReporter.cpp	Mon Jul 24 22:56:43 2017 +0000
@@ -312,11 +312,16 @@
 }
 
 void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count,
-    size_t early_amount, size_t early_count) const {
+    size_t early_amount, size_t early_count, MEMFLAGS flags) const {
   const char* scale = current_scale();
   outputStream* out = output();
 
   out->print("malloc=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale);
+  // Report type only if it is valid
+  if (flags != mtNone) {
+    out->print(" type=%s", NMTUtil::flag_to_name(flags));
+  }
+
   long amount_diff = diff_in_current_scale(current_amount, early_amount);
   if (amount_diff != 0) {
     out->print(" %+ld%s", amount_diff, scale);
@@ -445,7 +450,7 @@
         diff_in_current_scale(current_malloc_amount, early_malloc_amount) != 0) {
       out->print("%28s(", " ");
       print_malloc_diff(current_malloc_amount, (flag == mtChunk) ? 0 : current_malloc->malloc_count(),
-        early_malloc_amount, early_malloc->malloc_count());
+        early_malloc_amount, early_malloc->malloc_count(), mtNone);
       out->print_cr(")");
     }
 
@@ -493,8 +498,8 @@
 }
 
 void MemDetailDiffReporter::diff_malloc_sites() const {
-  MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site);
-  MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site);
+  MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site_and_type);
+  MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site_and_type);
 
   const MallocSite* early_site   = early_itr.next();
   const MallocSite* current_site = current_itr.next();
@@ -557,22 +562,23 @@
 
 void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const {
   diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(),
-    0, 0);
+    0, 0, malloc_site->flags());
 }
 
 void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const {
   diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(),
-    malloc_site->count());
+    malloc_site->count(), malloc_site->flags());
 }
 
 void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early,
   const MallocSite* current)  const {
+  assert(early->flags() == current->flags(), "Must be the same memory type");
   diff_malloc_site(current->call_stack(), current->size(), current->count(),
-    early->size(), early->count());
+    early->size(), early->count(), early->flags());
 }
 
 void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size,
-  size_t current_count, size_t early_size, size_t early_count) const {
+  size_t current_count, size_t early_size, size_t early_count, MEMFLAGS flags) const {
   outputStream* out = output();
 
   assert(stack != NULL, "NULL stack");
@@ -584,7 +590,7 @@
   stack->print_on(out);
   out->print("%28s (", " ");
   print_malloc_diff(current_size, current_count,
-    early_size, early_count);
+    early_size, early_count, flags);
 
   out->print_cr(")\n");
 }
--- a/hotspot/src/share/vm/services/memReporter.hpp	Mon Jul 24 17:46:06 2017 -0400
+++ b/hotspot/src/share/vm/services/memReporter.hpp	Mon Jul 24 22:56:43 2017 +0000
@@ -174,7 +174,7 @@
 
  protected:
   void print_malloc_diff(size_t current_amount, size_t current_count,
-    size_t early_amount, size_t early_count) const;
+    size_t early_amount, size_t early_count, MEMFLAGS flags) const;
   void print_virtual_memory_diff(size_t current_reserved, size_t current_committed,
     size_t early_reserved, size_t early_committed) const;
   void print_arena_diff(size_t current_amount, size_t current_count,
@@ -216,7 +216,7 @@
                                 const VirtualMemoryAllocationSite* current)  const;
 
   void diff_malloc_site(const NativeCallStack* stack, size_t current_size,
-    size_t currrent_count, size_t early_size, size_t early_count) const;
+    size_t currrent_count, size_t early_size, size_t early_count, MEMFLAGS flags) const;
   void diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved,
     size_t current_committed, size_t early_reserved, size_t early_committed) const;
 };