* But for hashtable entry allocation site object, things get tricky. C runtime not only allocates * memory for it, but also calls its constructor at some later time. If we initialize the allocation site * at the first os::malloc() call, the object will be reinitialized when its constructor is called * by C runtime. * To workaround above issue, we declare a static size_t array with the size of the CallsiteHashtableEntry, * the memory is used to instantiate CallsiteHashtableEntry for the hashtable entry allocation site. * Given it is a primitive type array, C runtime will do nothing other than assign the memory block for the variable, * which is exactly what we want. * The same trick is also applied to create NativeCallStack object for CallsiteHashtableEntry memory allocation. * * Note: C++ object usually aligns to particular alignment, depends on compiler implementation, we declare * the memory as size_t arrays, to ensure the memory is aligned to native machine word alignment. */ // Reserve enough memory for NativeCallStack and MallocSiteHashtableEntry objects size_t MallocSiteTable::_hash_entry_allocation_stack[CALC_OBJ_SIZE_IN_TYPE(NativeCallStack, size_t)]; size_t MallocSiteTable::_hash_entry_allocation_site[CALC_OBJ_SIZE_IN_TYPE(MallocSiteHashtableEntry, size_t)]; // Malloc site hashtable buckets MallocSiteHashtableEntry* MallocSiteTable::_table[MallocSiteTable::table_size]; // concurrent access counter volatile int MallocSiteTable::_access_count = 0; // Tracking hashtable contention NOT_PRODUCT(int MallocSiteTable::_peak_count = 0;) /* * Initialize malloc site table. * Hashtable entry is malloc'd, so it can cause infinite recursion.
* * 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" #include "runtime/threadCritical.hpp" #include "services/virtualMemoryTracker.hpp" size_t VirtualMemorySummary::_snapshot[CALC_OBJ_SIZE_IN_TYPE(VirtualMemorySnapshot, size_t)]; void VirtualMemorySummary::initialize() { assert(sizeof(_snapshot) >= sizeof(VirtualMemorySnapshot), "Sanity Check"); // Use placement operator new to initialize static data area. ::new ((void*)_snapshot) VirtualMemorySnapshot(); } SortedLinkedList<ReservedMemoryRegion, compare_reserved_region_base>* VirtualMemoryTracker::_reserved_regions; int compare_committed_region(const CommittedMemoryRegion& r1, const CommittedMemoryRegion& r2) { return r1.compare(r2); } int compare_reserved_region_base(const ReservedMemoryRegion& r1, const ReservedMemoryRegion& r2) { return r1.compare(r2);