hotspot/src/share/vm/runtime/perfMemory.hpp
author pliden
Fri, 11 Apr 2014 12:29:24 +0200
changeset 24094 5dbf1f44de18
parent 22551 9bf46d16dcc6
child 27007 3cacf4ad4fc9
permissions -rw-r--r--
8039147: Cleanup SuspendibleThreadSet Reviewed-by: brutisso, tschatzl, mgerdin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. 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
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1623
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1623
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1623
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_RUNTIME_PERFMEMORY_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_RUNTIME_PERFMEMORY_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "utilities/exceptions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
 * PerfData Version Constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
 *   - Major Version - change whenever the structure of PerfDataEntry changes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
 *   - Minor Version - change whenever the data within the PerfDataEntry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
 *                     structure changes. for example, new unit or variability
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
 *                     values are added or new PerfData subtypes are added.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
#define PERFDATA_MAJOR_VERSION 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
#define PERFDATA_MINOR_VERSION 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
/* Byte order of the PerfData memory region. The byte order is exposed in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
 * the PerfData memory region as the data in the memory region may have
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
 * been generated by a little endian JVM implementation. Tracking the byte
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
 * order in the PerfData memory region allows Java applications to adapt
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
 * to the native byte order for monitoring purposes. This indicator is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
 * also useful when a snapshot of the PerfData memory region is shipped
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
 * to a machine with a native byte order different from that of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
 * originating machine.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
#define PERFDATA_BIG_ENDIAN     0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
#define PERFDATA_LITTLE_ENDIAN  1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
 * The PerfDataPrologue structure is known by the PerfDataBuffer Java class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
 * libraries that read the PerfData memory region. The size and the position
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
 * of the fields must be changed along with their counterparts in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
 * PerfDataBuffer Java class. The first four bytes of this structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
 * should never change, or compatibility problems between the monitoring
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 7397
diff changeset
    58
 * applications and HotSpot VMs will result. The reserved fields are
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
 * available for future enhancements.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
typedef struct {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  jint   magic;              // magic number - 0xcafec0c0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  jbyte  byte_order;         // byte order of the buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  jbyte  major_version;      // major and minor version numbers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  jbyte  minor_version;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  jbyte  accessible;         // ready to access
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  jint   used;               // number of PerfData memory bytes used
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  jint   overflow;           // number of bytes of overflow
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  jlong  mod_time_stamp;     // time stamp of last structural modification
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  jint   entry_offset;       // offset of the first PerfDataEntry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  jint   num_entries;        // number of allocated PerfData entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
} PerfDataPrologue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
/* The PerfDataEntry structure defines the fixed portion of an entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
 * in the PerfData memory region. The PerfDataBuffer Java libraries
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
 * are aware of this structure and need to be changed when this
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
 * structure changes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
typedef struct {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  jint entry_length;      // entry length in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  jint name_offset;       // offset of the data item name
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  jint vector_length;     // length of the vector. If 0, then scalar
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  jbyte data_type;        // type of the data item -
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
                          // 'B','Z','J','I','S','C','D','F','V','L','['
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  jbyte flags;            // flags indicating misc attributes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  jbyte data_units;       // unit of measure for the data type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  jbyte data_variability; // variability classification of data type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  jint  data_offset;      // offset of the data item
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  body of PerfData memory entry is variable length
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  jbyte[name_length] data_name;        // name of the data item
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  jbyte[pad_length] data_pad;          // alignment of data item
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  j<data_type>[data_length] data_item; // array of appropriate types.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
                                       // data_length is > 1 only when the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
                                       // data_type is T_ARRAY.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
*/
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
} PerfDataEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
// Prefix of performance data file.
1553
fc10c169d15d 6772413: code cleanup
kvn
parents: 1
diff changeset
   103
extern const char PERFDATA_NAME[];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
// UINT_CHARS contains the number of characters holding a process id
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// (i.e. pid). pid is defined as unsigned "int" so the maximum possible pid value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// would be 2^32 - 1 (4294967295) which can be represented as a 10 characters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
// string.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
static const size_t UINT_CHARS = 10;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
/* the PerfMemory class manages creation, destruction,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
 * and allocation of the PerfData region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
class PerfMemory : AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    static char*  _start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    static char*  _end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    static char*  _top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    static size_t _capacity;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    static PerfDataPrologue*  _prologue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    static jint   _initialized;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    static void create_memory_region(size_t sizep);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    static void delete_memory_region();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    enum PerfMemoryMode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
      PERF_MODE_RO = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
      PERF_MODE_RW = 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    static char* alloc(size_t size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    static char* start() { return _start; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    static char* end() { return _end; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    static size_t used() { return (size_t) (_top - _start); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    static size_t capacity() { return _capacity; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    static bool is_initialized() { return _initialized != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    static bool contains(char* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
      return ((_start != NULL) && (addr >= _start) && (addr < _end));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    static void mark_updated();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    // methods for attaching to and detaching from the PerfData
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    // memory segment of another JVM process on the same system.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    static void attach(const char* user, int vmid, PerfMemoryMode mode,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
                       char** addrp, size_t* size, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    static void detach(char* addr, size_t bytes, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    static void destroy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    static void set_accessible(bool value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
      if (UsePerfData) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
        _prologue->accessible = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    // filename of backing store or NULL if none.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    static char* backing_store_filename();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    // returns the complete file path of hsperfdata.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    // the caller is expected to free the allocated memory.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    static char* get_perfdata_file_path();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
void perfMemory_init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
void perfMemory_exit();
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   168
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   169
#endif // SHARE_VM_RUNTIME_PERFMEMORY_HPP