Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/services/nmtCommon.hpp
32285 views
/*1* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_SERVICES_NMT_COMMON_HPP25#define SHARE_VM_SERVICES_NMT_COMMON_HPP2627#include "memory/allocation.hpp"28#include "utilities/globalDefinitions.hpp"2930#define CALC_OBJ_SIZE_IN_TYPE(obj, type) (align_size_up_(sizeof(obj), sizeof(type))/sizeof(type))3132// Data type for memory counters33#ifdef _LP6434typedef jlong MemoryCounterType;35#else36typedef jint MemoryCounterType;37#endif3839// Native memory tracking level40enum NMT_TrackingLevel {41NMT_unknown = 0xFF,42NMT_off = 0x00,43NMT_minimal = 0x01,44NMT_summary = 0x02,45NMT_detail = 0x0346};4748// Number of stack frames to capture. This is a49// build time decision.50const int NMT_TrackingStackDepth = 4;5152// A few common utilities for native memory tracking53class NMTUtil : AllStatic {54public:55// Map memory type to index56static inline int flag_to_index(MEMFLAGS flag) {57return (flag & 0xff);58}5960// Map memory type to human readable name61static const char* flag_to_name(MEMFLAGS flag) {62return _memory_type_names[flag_to_index(flag)];63}6465// Map an index to memory type66static MEMFLAGS index_to_flag(int index) {67return (MEMFLAGS)index;68}6970// Memory size scale71static const char* scale_name(size_t scale);72static size_t scale_from_name(const char* scale);7374// Translate memory size in specified scale75static size_t amount_in_scale(size_t amount, size_t scale) {76return (amount + scale / 2) / scale;77}78private:79static const char* _memory_type_names[mt_number_of_types];80};818283#endif848586