annotate src/share/vm/runtime/perfMemory.cpp @ 18096:ca6d25be853b jdk8u25-b13

8044269: Analysis of archive files. Summary: Add checksum verification. Reviewed-by: iklam, dholmes, mschoene
author jiangli
date Tue, 12 Aug 2014 17:46:16 -0400
parents 78bbf4d43a14
children 52b4284cb496 ce8f6bb717c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17632
2604e2767d2c 8030955: assert(_prologue != NULL) failed: prologue pointer must be initialized
hseigel
parents: 6842
diff changeset
2 * Copyright (c) 2001, 2014, 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 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "runtime/arguments.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "runtime/java.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "runtime/mutex.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "runtime/mutexLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "runtime/os.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "runtime/perfData.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "runtime/perfMemory.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "runtime/statSampler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "utilities/globalDefinitions.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17632
diff changeset
37 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17632
diff changeset
38
434
de78b80cedec 6772413: code cleanup
kvn
parents: 0
diff changeset
39 // Prefix of performance data file.
de78b80cedec 6772413: code cleanup
kvn
parents: 0
diff changeset
40 const char PERFDATA_NAME[] = "hsperfdata";
de78b80cedec 6772413: code cleanup
kvn
parents: 0
diff changeset
41
de78b80cedec 6772413: code cleanup
kvn
parents: 0
diff changeset
42 // Add 1 for the '_' character between PERFDATA_NAME and pid. The '\0' terminating
de78b80cedec 6772413: code cleanup
kvn
parents: 0
diff changeset
43 // character will be included in the sizeof(PERFDATA_NAME) operation.
de78b80cedec 6772413: code cleanup
kvn
parents: 0
diff changeset
44 static const size_t PERFDATA_FILENAME_LEN = sizeof(PERFDATA_NAME) +
de78b80cedec 6772413: code cleanup
kvn
parents: 0
diff changeset
45 UINT_CHARS + 1;
de78b80cedec 6772413: code cleanup
kvn
parents: 0
diff changeset
46
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47 char* PerfMemory::_start = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 char* PerfMemory::_end = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 char* PerfMemory::_top = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 size_t PerfMemory::_capacity = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 jint PerfMemory::_initialized = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 PerfDataPrologue* PerfMemory::_prologue = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 void perfMemory_init() {
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 PerfMemory::initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 void perfMemory_exit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 if (!PerfMemory::is_initialized()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // if the StatSampler is active, then we don't want to remove
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // resources it may be dependent on. Typically, the StatSampler
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // is disengaged from the watcher thread when this method is called,
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // but it is not disengaged if this method is invoked during a
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // VM abort.
a61af66fc99e Initial load
duke
parents:
diff changeset
71 //
a61af66fc99e Initial load
duke
parents:
diff changeset
72 if (!StatSampler::is_active())
a61af66fc99e Initial load
duke
parents:
diff changeset
73 PerfDataManager::destroy();
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // remove the persistent external resources, if any. this method
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // does not unmap or invalidate any virtual memory allocated during
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // initialization.
a61af66fc99e Initial load
duke
parents:
diff changeset
78 //
a61af66fc99e Initial load
duke
parents:
diff changeset
79 PerfMemory::destroy();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 void PerfMemory::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 if (_prologue != NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // initialization already performed
a61af66fc99e Initial load
duke
parents:
diff changeset
86 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 size_t capacity = align_size_up(PerfDataMemorySize,
a61af66fc99e Initial load
duke
parents:
diff changeset
89 os::vm_allocation_granularity());
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 if (PerfTraceMemOps) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 tty->print("PerfDataMemorySize = " SIZE_FORMAT ","
a61af66fc99e Initial load
duke
parents:
diff changeset
93 " os::vm_allocation_granularity = " SIZE_FORMAT ","
a61af66fc99e Initial load
duke
parents:
diff changeset
94 " adjusted size = " SIZE_FORMAT "\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
95 PerfDataMemorySize,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 os::vm_allocation_granularity(),
a61af66fc99e Initial load
duke
parents:
diff changeset
97 capacity);
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // allocate PerfData memory region
a61af66fc99e Initial load
duke
parents:
diff changeset
101 create_memory_region(capacity);
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if (_start == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // the PerfMemory region could not be created as desired. Rather
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // than terminating the JVM, we revert to creating the instrumentation
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // on the C heap. When running in this mode, external monitoring
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // clients cannot attach to and monitor this JVM.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 //
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // the warning is issued only in debug mode in order to avoid
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // additional output to the stdout or stderr output streams.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 //
a61af66fc99e Initial load
duke
parents:
diff changeset
113 if (PrintMiscellaneous && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 warning("Could not create PerfData Memory region, reverting to malloc");
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
117 _prologue = NEW_C_HEAP_OBJ(PerfDataPrologue, mtInternal);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // the PerfMemory region was created as expected.
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 if (PerfTraceMemOps) {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 tty->print("PerfMemory created: address = " INTPTR_FORMAT ","
a61af66fc99e Initial load
duke
parents:
diff changeset
125 " size = " SIZE_FORMAT "\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
126 (void*)_start,
a61af66fc99e Initial load
duke
parents:
diff changeset
127 _capacity);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 _prologue = (PerfDataPrologue *)_start;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 _end = _start + _capacity;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 _top = _start + sizeof(PerfDataPrologue);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 assert(_prologue != NULL, "prologue pointer must be initialized");
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 #ifdef VM_LITTLE_ENDIAN
a61af66fc99e Initial load
duke
parents:
diff changeset
138 _prologue->magic = (jint)0xc0c0feca;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 _prologue->byte_order = PERFDATA_LITTLE_ENDIAN;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
141 _prologue->magic = (jint)0xcafec0c0;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 _prologue->byte_order = PERFDATA_BIG_ENDIAN;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 _prologue->major_version = PERFDATA_MAJOR_VERSION;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 _prologue->minor_version = PERFDATA_MINOR_VERSION;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 _prologue->accessible = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 _prologue->entry_offset = sizeof(PerfDataPrologue);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 _prologue->num_entries = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 _prologue->used = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 _prologue->overflow = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 _prologue->mod_time_stamp = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 OrderAccess::release_store(&_initialized, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 void PerfMemory::destroy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
159
17632
2604e2767d2c 8030955: assert(_prologue != NULL) failed: prologue pointer must be initialized
hseigel
parents: 6842
diff changeset
160 if (_prologue == NULL) return;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (_start != NULL && _prologue->overflow != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // This state indicates that the contiguous memory region exists and
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // that it wasn't large enough to hold all the counters. In this case,
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // we output a warning message to the user on exit if the -XX:+Verbose
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // flag is set (a debug only flag). External monitoring tools can detect
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // this condition by monitoring the _prologue->overflow word.
a61af66fc99e Initial load
duke
parents:
diff changeset
169 //
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // There are two tunables that can help resolve this issue:
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // - increase the size of the PerfMemory with -XX:PerfDataMemorySize=<n>
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // - decrease the maximum string constant length with
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // -XX:PerfMaxStringConstLength=<n>
a61af66fc99e Initial load
duke
parents:
diff changeset
174 //
a61af66fc99e Initial load
duke
parents:
diff changeset
175 if (PrintMiscellaneous && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 warning("PerfMemory Overflow Occurred.\n"
a61af66fc99e Initial load
duke
parents:
diff changeset
177 "\tCapacity = " SIZE_FORMAT " bytes"
a61af66fc99e Initial load
duke
parents:
diff changeset
178 " Used = " SIZE_FORMAT " bytes"
a61af66fc99e Initial load
duke
parents:
diff changeset
179 " Overflow = " INT32_FORMAT " bytes"
a61af66fc99e Initial load
duke
parents:
diff changeset
180 "\n\tUse -XX:PerfDataMemorySize=<size> to specify larger size.",
a61af66fc99e Initial load
duke
parents:
diff changeset
181 PerfMemory::capacity(),
a61af66fc99e Initial load
duke
parents:
diff changeset
182 PerfMemory::used(),
a61af66fc99e Initial load
duke
parents:
diff changeset
183 _prologue->overflow);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 if (_start != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // this state indicates that the contiguous memory region was successfully
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // and that persistent resources may need to be cleaned up. This is
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // expected to be the typical condition.
a61af66fc99e Initial load
duke
parents:
diff changeset
192 //
a61af66fc99e Initial load
duke
parents:
diff changeset
193 delete_memory_region();
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 _start = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 _end = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 _top = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 _prologue = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 _capacity = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // allocate an aligned block of memory from the PerfData memory
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // region. This method assumes that the PerfData memory region
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // was aligned on a double word boundary when created.
a61af66fc99e Initial load
duke
parents:
diff changeset
206 //
a61af66fc99e Initial load
duke
parents:
diff changeset
207 char* PerfMemory::alloc(size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 if (!UsePerfData) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 MutexLocker ml(PerfDataMemAlloc_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 assert(_prologue != NULL, "called before initialization");
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // check that there is enough memory for this request
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if ((_top + size) >= _end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 _prologue->overflow += (jint)size;
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 char* result = _top;
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 _top += size;
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 assert(contains(result), "PerfData memory pointer out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 _prologue->used = (jint)used();
a61af66fc99e Initial load
duke
parents:
diff changeset
230 _prologue->num_entries = _prologue->num_entries + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 void PerfMemory::mark_updated() {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 if (!UsePerfData) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 _prologue->mod_time_stamp = os::elapsed_counter();
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // Returns the complete path including the file name of performance data file.
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // Caller is expected to release the allocated memory.
a61af66fc99e Initial load
duke
parents:
diff changeset
243 char* PerfMemory::get_perfdata_file_path() {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 char* dest_file = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246 if (PerfDataSaveFile != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // dest_file_name stores the validated file name if file_name
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // contains %p which will be replaced by pid.
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
249 dest_file = NEW_C_HEAP_ARRAY(char, JVM_MAXPATHLEN, mtInternal);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
250 if(!Arguments::copy_expand_pid(PerfDataSaveFile, strlen(PerfDataSaveFile),
a61af66fc99e Initial load
duke
parents:
diff changeset
251 dest_file, JVM_MAXPATHLEN)) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
252 FREE_C_HEAP_ARRAY(char, dest_file, mtInternal);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
253 if (PrintMiscellaneous && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 warning("Invalid performance data file path name specified, "\
a61af66fc99e Initial load
duke
parents:
diff changeset
255 "fall back to a default name");
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return dest_file;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // create the name of the file for retaining the instrumentation memory.
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
262 dest_file = NEW_C_HEAP_ARRAY(char, PERFDATA_FILENAME_LEN, mtInternal);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
263 jio_snprintf(dest_file, PERFDATA_FILENAME_LEN,
a61af66fc99e Initial load
duke
parents:
diff changeset
264 "%s_%d", PERFDATA_NAME, os::current_process_id());
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 return dest_file;
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }