src/share/vm/runtime/perfMemory.hpp

Thu, 24 May 2018 19:24:53 +0800

author
aoqi
date
Thu, 24 May 2018 19:24:53 +0800
changeset 8861
2a33b32dd03c
parent 6876
710a3c8b516e
permissions
-rw-r--r--

#7046 Disable the compilation when branch offset is beyond short branch
Contributed-by: fujie, aoqi

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

mercurial