1 /*
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
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.
103 extern const char PERFDATA_NAME[];
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 // returns the complete file path of hsperfdata.
|
1 /*
2 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
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.
103 extern const char PERFDATA_NAME[];
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 friend class PerfMemoryTest;
117 private:
118 static char* _start;
119 static char* _end;
120 static char* _top;
121 static size_t _capacity;
122 static PerfDataPrologue* _prologue;
123 static jint _initialized;
124 static bool _destroyed;
125
126 static void create_memory_region(size_t sizep);
127 static void delete_memory_region();
128
129 public:
130 enum PerfMemoryMode {
131 PERF_MODE_RO = 0,
132 PERF_MODE_RW = 1
133 };
134
135 static char* alloc(size_t size);
136 static char* start() { return _start; }
137 static char* end() { return _end; }
138 static size_t used() { return (size_t) (_top - _start); }
139 static size_t capacity() { return _capacity; }
140 static bool is_initialized() { return _initialized != 0; }
141 static bool is_destroyed() { return _destroyed; }
142 static bool contains(char* addr) {
143 return ((_start != NULL) && (addr >= _start) && (addr < _end));
144 }
145 static void mark_updated();
146
147 // methods for attaching to and detaching from the PerfData
148 // memory segment of another JVM process on the same system.
149 static void attach(const char* user, int vmid, PerfMemoryMode mode,
150 char** addrp, size_t* size, TRAPS);
151 static void detach(char* addr, size_t bytes, TRAPS);
152
153 static void initialize();
154 static void destroy();
155 static void set_accessible(bool value) {
156 if (UsePerfData) {
157 _prologue->accessible = value;
158 }
159 }
160
161 // returns the complete file path of hsperfdata.
|