/* * 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 * 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. *
*/ #include"precompiled.hpp"
// Sort into allocation site addresses order for baseline comparison int compare_malloc_site(const MallocSite& s1, const MallocSite& s2) { 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)(NMTUtil::flag_to_index(s1.flag()) - NMTUtil::flag_to_index(s2.flag()));
}
/* * Walker to walk malloc allocation site table
*/ class MallocAllocationSiteWalker : public MallocSiteWalker { private:
SortedLinkedList<MallocSite, compare_malloc_size> _malloc_sites;
size_t _count;
// Entries in MallocSiteTable with size = 0 and count = 0, // when the malloc site is not longer there. public:
MallocAllocationSiteWalker() : _count(0) { }
// Compare virtual memory region's base address int compare_virtual_memory_base(const ReservedMemoryRegion& r1, const ReservedMemoryRegion& r2) { return r1.compare(r2);
}
// Walk all virtual memory regions for baselining class VirtualMemoryAllocationWalker : public VirtualMemoryWalker { private:
SortedLinkedList<ReservedMemoryRegion, compare_virtual_memory_base>
_virtual_memory_regions;
size_t _count;
// Virtual memory allocations are collected in call stack order
_virtual_memory_allocations.move(virtual_memory_walker.virtual_memory_allocations());
if (!aggregate_virtual_memory_allocation_sites()) { returnfalse;
} // Virtual memory allocation sites are aggregrated in call stack order
_virtual_memory_sites_order = by_address;
MallocSiteIterator MemBaseline::malloc_sites(SortingOrder order) {
assert(!_malloc_sites.is_empty(), "Not detail baseline"); switch(order) { case by_size:
malloc_sites_to_size_order(); break; 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();
} return MallocSiteIterator(_malloc_sites.head());
}
VirtualMemorySiteIterator MemBaseline::virtual_memory_sites(SortingOrder order) {
assert(!_virtual_memory_sites.is_empty(), "Not detail baseline"); switch(order) { case by_size:
virtual_memory_sites_to_size_order(); break; case by_site:
virtual_memory_sites_to_reservation_site_order(); break; case by_address: default:
ShouldNotReachHere();
} return VirtualMemorySiteIterator(_virtual_memory_sites.head());
}
// Sorting allocations sites in different orders void MemBaseline::malloc_sites_to_size_order() { if (_malloc_sites_order != by_size) {
SortedLinkedList<MallocSite, compare_malloc_size> tmp;
// Add malloc sites to sorted linked list to sort into size order
tmp.move(&_malloc_sites);
_malloc_sites.set_head(tmp.head());
tmp.set_head(NULL);
_malloc_sites_order = by_size;
}
}
void MemBaseline::malloc_sites_to_allocation_site_order() { 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);
_malloc_sites.set_head(tmp.head());
tmp.set_head(NULL);
_malloc_sites_order = by_site;
}
}
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;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.