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