diff --git a/src/share/vm/services/allocationSite.hpp b/src/share/vm/services/allocationSite.hpp index 07f8595f81543959ea30b0a4305d66edbba6a35b..d747c1b72e5d92a9116a7160c99797478ff0c989 100644 --- a/src/share/vm/services/allocationSite.hpp +++ b/src/share/vm/services/allocationSite.hpp @@ -34,8 +34,9 @@ template class AllocationSite VALUE_OBJ_CLASS_SPEC { private: NativeCallStack _call_stack; E e; + MEMFLAGS _flag; public: - AllocationSite(const NativeCallStack& stack) : _call_stack(stack) { } + AllocationSite(const NativeCallStack& stack, MEMFLAGS flag) : _call_stack(stack), _flag(flag) { } int hash() const { return _call_stack.hash(); } bool equals(const NativeCallStack& stack) const { return _call_stack.equals(stack); @@ -52,6 +53,8 @@ template class AllocationSite VALUE_OBJ_CLASS_SPEC { // Information regarding this allocation E* data() { return &e; } const E* peek() const { return &e; } + + MEMFLAGS flag() const { return _flag; } }; #endif // SHARE_VM_SERVICES_ALLOCATION_SITE_HPP diff --git a/src/share/vm/services/mallocSiteTable.cpp b/src/share/vm/services/mallocSiteTable.cpp index 94fe1b96f3719643e01a0a698a9b2ec2eba222fd..6a948dca23f98e397c4091d9ad6a7859ba2aabf5 100644 --- a/src/share/vm/services/mallocSiteTable.cpp +++ b/src/share/vm/services/mallocSiteTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -158,7 +158,7 @@ MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, size_t* b MallocSiteHashtableEntry* head = _table[index]; while (head != NULL && (*pos_idx) <= MAX_BUCKET_LENGTH) { MallocSite* site = head->data(); - if (site->flags() == flags && site->equals(key)) { + if (site->flag() == flags && site->equals(key)) { return head->data(); } diff --git a/src/share/vm/services/mallocSiteTable.hpp b/src/share/vm/services/mallocSiteTable.hpp index b2e34affcad7dce3c095d1a6deec9d242ed03f94..819f4e7373a28ad3bbab05ba2a4b094f84e39328 100644 --- a/src/share/vm/services/mallocSiteTable.hpp +++ b/src/share/vm/services/mallocSiteTable.hpp @@ -37,15 +37,12 @@ // MallocSite represents a code path that eventually calls // os::malloc() to allocate memory class MallocSite : public AllocationSite { - private: - MEMFLAGS _flags; - public: MallocSite() : - AllocationSite(NativeCallStack::empty_stack()), _flags(mtNone) {} + AllocationSite(NativeCallStack::empty_stack(), mtNone) {} MallocSite(const NativeCallStack& stack, MEMFLAGS flags) : - AllocationSite(stack), _flags(flags) {} + AllocationSite(stack, flags) {} void allocate(size_t size) { data()->allocate(size); } @@ -55,7 +52,6 @@ class MallocSite : public AllocationSite { size_t size() const { return peek()->size(); } // The number of calls were made size_t count() const { return peek()->count(); } - MEMFLAGS flags() const { return (MEMFLAGS)_flags; } }; // Malloc site hashtable entry diff --git a/src/share/vm/services/memBaseline.cpp b/src/share/vm/services/memBaseline.cpp index f580aada254684c4fc17d33f38ad9ae59d29ee49..1856749a722592074349269eaa4bd11d75b57f66 100644 --- a/src/share/vm/services/memBaseline.cpp +++ b/src/share/vm/services/memBaseline.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -63,7 +63,7 @@ int compare_malloc_site(const MallocSite& s1, const MallocSite& s2) { 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()); + res = (int)(s1.flag() - s2.flag()); } return res; @@ -209,7 +209,7 @@ bool MemBaseline::aggregate_virtual_memory_allocation_sites() { const ReservedMemoryRegion* rgn; VirtualMemoryAllocationSite* site; while ((rgn = itr.next()) != NULL) { - VirtualMemoryAllocationSite tmp(*rgn->call_stack()); + VirtualMemoryAllocationSite tmp(*rgn->call_stack(), rgn->flag()); site = allocation_sites.find(tmp); if (site == NULL) { LinkedListNode* node = diff --git a/src/share/vm/services/memReporter.cpp b/src/share/vm/services/memReporter.cpp index 67e3eea092944c82029fee1bca0391c32be1445c..a324890d34c24c335ae61343316780c19fb77140 100644 --- a/src/share/vm/services/memReporter.cpp +++ b/src/share/vm/services/memReporter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -205,7 +205,7 @@ void MemDetailReporter::report_malloc_sites() { const NativeCallStack* stack = malloc_site->call_stack(); stack->print_on(out); out->print("%29s", " "); - MEMFLAGS flag = malloc_site->flags(); + MEMFLAGS flag = malloc_site->flag(); assert((flag >= 0 && flag < (int)mt_number_of_types) && flag != mtNone, "Must have a valid memory type"); print_malloc(malloc_site->size(), malloc_site->count(),flag); @@ -231,6 +231,10 @@ void MemDetailReporter::report_virtual_memory_allocation_sites() { stack->print_on(out); out->print("%28s (", " "); print_total(virtual_memory_site->reserved(), virtual_memory_site->committed()); + MEMFLAGS flag = virtual_memory_site->flag(); + if (flag != mtNone) { + out->print(" Type=%s", NMTUtil::flag_to_name(flag)); + } out->print_cr(")\n"); } } @@ -562,24 +566,24 @@ void MemDetailDiffReporter::diff_virtual_memory_sites() const { 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, malloc_site->flags()); + 0, 0, malloc_site->flag()); } 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->flags()); + malloc_site->count(), malloc_site->flag()); } void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, const MallocSite* current) const { - if (early->flags() != current->flags()) { + if (early->flag() != current->flag()) { // If malloc site type changed, treat it as deallocation of old type and // allocation of new type. old_malloc_site(early); new_malloc_site(current); } else { diff_malloc_site(current->call_stack(), current->size(), current->count(), - early->size(), early->count(), early->flags()); + early->size(), early->count(), early->flag()); } } @@ -603,21 +607,22 @@ void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_ void MemDetailDiffReporter::new_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { - diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0); + diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0, site->flag()); } void MemDetailDiffReporter::old_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { - diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed()); + diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed(), site->flag()); } void MemDetailDiffReporter::diff_virtual_memory_site(const VirtualMemoryAllocationSite* early, const VirtualMemoryAllocationSite* current) const { + assert(early->flag() == current->flag(), "Should be the same"); diff_virtual_memory_site(current->call_stack(), current->reserved(), current->committed(), - early->reserved(), early->committed()); + early->reserved(), early->committed(), current->flag()); } void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, - size_t current_committed, size_t early_reserved, size_t early_committed) const { + size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const { outputStream* out = output(); // no change @@ -631,6 +636,10 @@ void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stac print_virtual_memory_diff(current_reserved, current_committed, early_reserved, early_committed); + if (flag != mtNone) { + out->print(" Type=%s", NMTUtil::flag_to_name(flag)); + } + out->print_cr(")\n"); } diff --git a/src/share/vm/services/memReporter.hpp b/src/share/vm/services/memReporter.hpp index 9b83f8ce4f0e7ee0d298821172c8fbf2ba86ff4a..794804dc2f510095c7413a34619b481fe1894c35 100644 --- a/src/share/vm/services/memReporter.hpp +++ b/src/share/vm/services/memReporter.hpp @@ -218,7 +218,7 @@ class MemDetailDiffReporter : public MemSummaryDiffReporter { void diff_malloc_site(const NativeCallStack* stack, size_t current_size, 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; + size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const; }; #endif // INCLUDE_NMT diff --git a/src/share/vm/services/virtualMemoryTracker.hpp b/src/share/vm/services/virtualMemoryTracker.hpp index 1be43b554c4cb5d54873a20c7c294127fd3c7170..16c9be7f94e334a34b2e8655f2523d5fd6327321 100644 --- a/src/share/vm/services/virtualMemoryTracker.hpp +++ b/src/share/vm/services/virtualMemoryTracker.hpp @@ -69,8 +69,8 @@ class VirtualMemory VALUE_OBJ_CLASS_SPEC { // Virtual memory allocation site, keeps track where the virtual memory is reserved. class VirtualMemoryAllocationSite : public AllocationSite { public: - VirtualMemoryAllocationSite(const NativeCallStack& stack) : - AllocationSite(stack) { } + VirtualMemoryAllocationSite(const NativeCallStack& stack, MEMFLAGS flag) : + AllocationSite(stack, flag) { } inline void reserve_memory(size_t sz) { data()->reserve_memory(sz); } inline void commit_memory (size_t sz) { data()->commit_memory(sz); }