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