src/share/vm/runtime/perfMemory.hpp

Wed, 19 Nov 2014 14:21:09 -0800

author
mchung
date
Wed, 19 Nov 2014 14:21:09 -0800
changeset 7368
fa6adc194d48
parent 2314
f95d63e2154a
child 6876
710a3c8b516e
permissions
-rw-r--r--

8064667: Add -XX:+CheckEndorsedAndExtDirs flag to JDK 8
Reviewed-by: coleenp, ccheung

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

mercurial