hotspot/src/share/vm/services/nmtCommon.hpp
author coleenp
Tue, 22 Dec 2015 11:11:29 -0500
changeset 35214 d86005e0b4c2
parent 26144 35e11b657728
child 42593 d7be1cb119a2
permissions -rw-r--r--
8074457: Remove the non-Zero CPP Interpreter Summary: Remove cppInterpreter assembly files and reorganize InterpreterGenerator includes Reviewed-by: goetz, bdelsart
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
     1
/*
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
     4
 *
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
     8
 *
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    13
 * accompanied this code).
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    14
 *
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    18
 *
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    21
 * questions.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    22
 *
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    23
 */
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    24
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    25
#ifndef SHARE_VM_SERVICES_NMT_COMMON_HPP
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    26
#define SHARE_VM_SERVICES_NMT_COMMON_HPP
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    27
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    28
#include "memory/allocation.hpp"
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    29
#include "utilities/globalDefinitions.hpp"
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    30
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    31
#define CALC_OBJ_SIZE_IN_TYPE(obj, type) (align_size_up_(sizeof(obj), sizeof(type))/sizeof(type))
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    32
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    33
// Data type for memory counters
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    34
#ifdef _LP64
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    35
  typedef jlong    MemoryCounterType;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    36
#else
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    37
  typedef jint     MemoryCounterType;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    38
#endif
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    39
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    40
// Native memory tracking level
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    41
enum NMT_TrackingLevel {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    42
  NMT_unknown = 0xFF,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    43
  NMT_off     = 0x00,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    44
  NMT_minimal = 0x01,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    45
  NMT_summary = 0x02,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    46
  NMT_detail  = 0x03
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    47
};
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    48
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    49
// Number of stack frames to capture. This is a
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    50
// build time decision.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    51
const int NMT_TrackingStackDepth = 4;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    52
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    53
// A few common utilities for native memory tracking
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    54
class NMTUtil : AllStatic {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    55
 public:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    56
  // Map memory type to index
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    57
  static inline int flag_to_index(MEMFLAGS flag) {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    58
    return (flag & 0xff);
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    59
  }
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    60
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    61
  // Map memory type to human readable name
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    62
  static const char* flag_to_name(MEMFLAGS flag) {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    63
    return _memory_type_names[flag_to_index(flag)];
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    64
  }
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    65
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    66
  // Map an index to memory type
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    67
  static MEMFLAGS index_to_flag(int index) {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    68
    return (MEMFLAGS)index;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    69
  }
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    70
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    71
  // Memory size scale
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    72
  static const char* scale_name(size_t scale);
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    73
  static size_t scale_from_name(const char* scale);
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    74
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    75
  // Translate memory size in specified scale
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    76
  static size_t amount_in_scale(size_t amount, size_t scale) {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    77
    return (amount + scale / 2) / scale;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    78
  }
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    79
 private:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    80
  static const char* _memory_type_names[mt_number_of_types];
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    81
};
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    82
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    83
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents:
diff changeset
    84
#endif