annotate src/share/vm/services/nmtCommon.hpp @ 9038:4b8584c24ff4

8215934: G1 Old Gen MemoryPool CollectionUsage.used values don't reflect mixed GC results Summary: Memory pools can now be optional collection participants, e.g., G1 Old Gen in an incremental collection. Reviewed-by: tschatzl, jcbeyler, andrew
author phh
date Mon, 28 Jan 2019 17:51:10 +0000
parents 833b0f92429a
children
rev   line source
zgu@6558 1 /*
zgu@6558 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
zgu@6558 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
zgu@6558 4 *
zgu@6558 5 * This code is free software; you can redistribute it and/or modify it
zgu@6558 6 * under the terms of the GNU General Public License version 2 only, as
zgu@6558 7 * published by the Free Software Foundation.
zgu@6558 8 *
zgu@6558 9 * This code is distributed in the hope that it will be useful, but WITHOUT
zgu@6558 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
zgu@6558 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
zgu@6558 12 * version 2 for more details (a copy is included in the LICENSE file that
zgu@6558 13 * accompanied this code).
zgu@6558 14 *
zgu@6558 15 * You should have received a copy of the GNU General Public License version
zgu@6558 16 * 2 along with this work; if not, write to the Free Software Foundation,
zgu@6558 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
zgu@6558 18 *
zgu@6558 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
zgu@6558 20 * or visit www.oracle.com if you need additional information or have any
zgu@6558 21 * questions.
zgu@6558 22 *
zgu@6558 23 */
zgu@6558 24
zgu@6558 25 #ifndef SHARE_VM_SERVICES_NMT_COMMON_HPP
zgu@6558 26 #define SHARE_VM_SERVICES_NMT_COMMON_HPP
zgu@6558 27
zgu@6558 28 #include "memory/allocation.hpp"
zgu@6558 29 #include "utilities/globalDefinitions.hpp"
zgu@6558 30
zgu@6558 31 #define CALC_OBJ_SIZE_IN_TYPE(obj, type) (align_size_up_(sizeof(obj), sizeof(type))/sizeof(type))
zgu@6558 32
zgu@6558 33 // Data type for memory counters
zgu@6558 34 #ifdef _LP64
zgu@6558 35 typedef jlong MemoryCounterType;
zgu@6558 36 #else
zgu@6558 37 typedef jint MemoryCounterType;
zgu@6558 38 #endif
zgu@6558 39
zgu@6558 40 // Native memory tracking level
zgu@6558 41 enum NMT_TrackingLevel {
zgu@6558 42 NMT_unknown = 0xFF,
zgu@6558 43 NMT_off = 0x00,
zgu@6558 44 NMT_minimal = 0x01,
zgu@6558 45 NMT_summary = 0x02,
zgu@6558 46 NMT_detail = 0x03
zgu@6558 47 };
zgu@6558 48
zgu@6558 49 // Number of stack frames to capture. This is a
zgu@6558 50 // build time decision.
zgu@6558 51 const int NMT_TrackingStackDepth = 4;
zgu@6558 52
zgu@6558 53 // A few common utilities for native memory tracking
zgu@6558 54 class NMTUtil : AllStatic {
zgu@6558 55 public:
zgu@6558 56 // Map memory type to index
zgu@6558 57 static inline int flag_to_index(MEMFLAGS flag) {
zgu@6558 58 return (flag & 0xff);
zgu@6558 59 }
zgu@6558 60
zgu@6558 61 // Map memory type to human readable name
zgu@6558 62 static const char* flag_to_name(MEMFLAGS flag) {
zgu@6558 63 return _memory_type_names[flag_to_index(flag)];
zgu@6558 64 }
zgu@6558 65
zgu@6558 66 // Map an index to memory type
zgu@6558 67 static MEMFLAGS index_to_flag(int index) {
zgu@6558 68 return (MEMFLAGS)index;
zgu@6558 69 }
zgu@6558 70
zgu@6558 71 // Memory size scale
zgu@6558 72 static const char* scale_name(size_t scale);
zgu@6558 73 static size_t scale_from_name(const char* scale);
zgu@6558 74
zgu@6558 75 // Translate memory size in specified scale
zgu@6558 76 static size_t amount_in_scale(size_t amount, size_t scale) {
zgu@6558 77 return (amount + scale / 2) / scale;
zgu@6558 78 }
zgu@6558 79 private:
zgu@6558 80 static const char* _memory_type_names[mt_number_of_types];
zgu@6558 81 };
zgu@6558 82
zgu@6558 83
zgu@6558 84 #endif