annotate src/share/vm/runtime/perfMemory.hpp @ 10241:d17700c82d7d

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