annotate src/share/vm/runtime/perfMemory.hpp @ 4731:1f114331df92

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