hotspot/src/share/vm/runtime/perfMemory.hpp
author phh
Wed, 28 Oct 2009 16:25:51 -0400
changeset 4434 4b41e5b42f81
parent 1623 a0dd9009e992
child 5547 f4b087cbb361
permissions -rw-r--r--
6887571: Increase default heap config sizes Summary: Apply modification of existing server heap size ergo to all collectors except CMS. Reviewed-by: jmasa, ysr, xlu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
1623
a0dd9009e992 6785258: Update copyright year
xdono
parents: 1553
diff changeset
     2
 * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
 * PerfData Version Constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
 *   - Major Version - change whenever the structure of PerfDataEntry changes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
 *   - Minor Version - change whenever the data within the PerfDataEntry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
 *                     structure changes. for example, new unit or variability
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
 *                     values are added or new PerfData subtypes are added.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
#define PERFDATA_MAJOR_VERSION 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
#define PERFDATA_MINOR_VERSION 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
/* Byte order of the PerfData memory region. The byte order is exposed in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
 * the PerfData memory region as the data in the memory region may have
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
 * been generated by a little endian JVM implementation. Tracking the byte
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
 * order in the PerfData memory region allows Java applications to adapt
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
 * to the native byte order for monitoring purposes. This indicator is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
 * also useful when a snapshot of the PerfData memory region is shipped
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
 * to a machine with a native byte order different from that of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
 * originating machine.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
#define PERFDATA_BIG_ENDIAN     0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
#define PERFDATA_LITTLE_ENDIAN  1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
 * The PerfDataPrologue structure is known by the PerfDataBuffer Java class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
 * libraries that read the PerfData memory region. The size and the position
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
 * of the fields must be changed along with their counterparts in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
 * PerfDataBuffer Java class. The first four bytes of this structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
 * should never change, or compatibility problems between the monitoring
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
 * applications and Hotspot VMs will result. The reserved fields are
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
 * available for future enhancements.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
typedef struct {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  jint   magic;              // magic number - 0xcafec0c0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  jbyte  byte_order;         // byte order of the buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  jbyte  major_version;      // major and minor version numbers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  jbyte  minor_version;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  jbyte  accessible;         // ready to access
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  jint   used;               // number of PerfData memory bytes used
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  jint   overflow;           // number of bytes of overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  jlong  mod_time_stamp;     // time stamp of last structural modification
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  jint   entry_offset;       // offset of the first PerfDataEntry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  jint   num_entries;        // number of allocated PerfData entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
} PerfDataPrologue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
/* The PerfDataEntry structure defines the fixed portion of an entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
 * in the PerfData memory region. The PerfDataBuffer Java libraries
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
 * are aware of this structure and need to be changed when this
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
 * structure changes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
typedef struct {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  jint entry_length;      // entry length in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  jint name_offset;       // offset of the data item name
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  jint vector_length;     // length of the vector. If 0, then scalar
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  jbyte data_type;        // type of the data item -
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
                          // 'B','Z','J','I','S','C','D','F','V','L','['
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  jbyte flags;            // flags indicating misc attributes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  jbyte data_units;       // unit of measure for the data type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  jbyte data_variability; // variability classification of data type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  jint  data_offset;      // offset of the data item
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  body of PerfData memory entry is variable length
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  jbyte[name_length] data_name;        // name of the data item
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  jbyte[pad_length] data_pad;          // alignment of data item
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  j<data_type>[data_length] data_item; // array of appropriate types.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
                                       // data_length is > 1 only when the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
                                       // data_type is T_ARRAY.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
*/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
} PerfDataEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
// Prefix of performance data file.
1553
fc10c169d15d 6772413: code cleanup
kvn
parents: 1
diff changeset
    98
extern const char PERFDATA_NAME[];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
// UINT_CHARS contains the number of characters holding a process id
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
// (i.e. pid). pid is defined as unsigned "int" so the maximum possible pid value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
// would be 2^32 - 1 (4294967295) which can be represented as a 10 characters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// string.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
static const size_t UINT_CHARS = 10;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
/* the PerfMemory class manages creation, destruction,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
 * and allocation of the PerfData region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
class PerfMemory : AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    static char*  _start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    static char*  _end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    static char*  _top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    static size_t _capacity;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    static PerfDataPrologue*  _prologue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    static jint   _initialized;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    static void create_memory_region(size_t sizep);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    static void delete_memory_region();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    enum PerfMemoryMode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
      PERF_MODE_RO = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
      PERF_MODE_RW = 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    static char* alloc(size_t size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    static char* start() { return _start; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    static char* end() { return _end; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    static size_t used() { return (size_t) (_top - _start); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    static size_t capacity() { return _capacity; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    static bool is_initialized() { return _initialized != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    static bool contains(char* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
      return ((_start != NULL) && (addr >= _start) && (addr < _end));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    static void mark_updated();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    // methods for attaching to and detaching from the PerfData
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    // memory segment of another JVM process on the same system.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    static void attach(const char* user, int vmid, PerfMemoryMode mode,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
                       char** addrp, size_t* size, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    static void detach(char* addr, size_t bytes, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    static void destroy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    static void set_accessible(bool value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
      if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
        _prologue->accessible = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    // filename of backing store or NULL if none.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    static char* backing_store_filename();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    // returns the complete file path of hsperfdata.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    // the caller is expected to free the allocated memory.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    static char* get_perfdata_file_path();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
void perfMemory_init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
void perfMemory_exit();