1 /*
2 * Copyright (c) 2001, 2015, 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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/vmSymbols.hpp"
27 #include "oops/oop.inline.hpp"
28 #include "runtime/handles.inline.hpp"
29 #include "runtime/java.hpp"
30 #include "runtime/mutex.hpp"
31 #include "runtime/mutexLocker.hpp"
32 #include "runtime/os.hpp"
33 #include "runtime/perfData.hpp"
34 #include "utilities/exceptions.hpp"
35 #include "utilities/globalDefinitions.hpp"
36
37 PerfDataList* PerfDataManager::_all = NULL;
38 PerfDataList* PerfDataManager::_sampled = NULL;
39 PerfDataList* PerfDataManager::_constants = NULL;
40 volatile bool PerfDataManager::_has_PerfData = 0;
41
42 /*
43 * The jvmstat global and subsystem jvmstat counter name spaces. The top
44 * level name spaces imply the interface stability level of the counter,
45 * which generally follows the Java package, class, and property naming
46 * conventions. The CounterNS enumeration values should be used to index
149 void* valuep = (void*) (psmp + data_start);
150
151 assert(is_on_c_heap() || PerfMemory::contains(cname), "just checking");
152 assert(is_on_c_heap() || PerfMemory::contains((char*)valuep), "just checking");
153
154 // copy the name, including null terminator, into PerfData memory
155 strcpy(cname, name());
156
157
158 // set the header values in PerfData memory
159 PerfDataEntry* pdep = (PerfDataEntry*)psmp;
160 pdep->entry_length = (jint)size;
161 pdep->name_offset = (jint) ((uintptr_t) cname - (uintptr_t) psmp);
162 pdep->vector_length = (jint)vlen;
163 pdep->data_type = (jbyte) type2char(dtype);
164 pdep->data_units = units();
165 pdep->data_variability = variability();
166 pdep->flags = (jbyte)flags();
167 pdep->data_offset = (jint) data_start;
168
169 if (PerfTraceDataCreation) {
170 tty->print("name = %s, dtype = %d, variability = %d,"
171 " units = %d, dsize = " SIZE_FORMAT ", vlen = " SIZE_FORMAT ","
172 " pad_length = " SIZE_FORMAT ", size = " SIZE_FORMAT ", on_c_heap = %s,"
173 " address = " INTPTR_FORMAT ","
174 " data address = " INTPTR_FORMAT "\n",
175 cname, dtype, variability(),
176 units(), dsize, vlen,
177 pad_length, size, is_on_c_heap() ? "TRUE":"FALSE",
178 p2i(psmp), p2i(valuep));
179 }
180
181 // record the start of the entry and the location of the data field.
182 _pdep = pdep;
183 _valuep = valuep;
184
185 // mark the PerfData memory region as having been updated.
186 PerfMemory::mark_updated();
187 }
188
189 PerfLong::PerfLong(CounterNS ns, const char* namep, Units u, Variability v)
190 : PerfData(ns, namep, u, v) {
191
192 create_entry(T_LONG, sizeof(jlong));
193 }
194
195 int PerfLong::format(char* buffer, int length) {
196 return jio_snprintf(buffer, length, JLONG_FORMAT, *(jlong*)_valuep);
197 }
198
199 PerfLongVariant::PerfLongVariant(CounterNS ns, const char* namep, Units u,
|
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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/vmSymbols.hpp"
27 #include "logging/log.hpp"
28 #include "oops/oop.inline.hpp"
29 #include "runtime/handles.inline.hpp"
30 #include "runtime/java.hpp"
31 #include "runtime/mutex.hpp"
32 #include "runtime/mutexLocker.hpp"
33 #include "runtime/os.hpp"
34 #include "runtime/perfData.hpp"
35 #include "utilities/exceptions.hpp"
36 #include "utilities/globalDefinitions.hpp"
37
38 PerfDataList* PerfDataManager::_all = NULL;
39 PerfDataList* PerfDataManager::_sampled = NULL;
40 PerfDataList* PerfDataManager::_constants = NULL;
41 volatile bool PerfDataManager::_has_PerfData = 0;
42
43 /*
44 * The jvmstat global and subsystem jvmstat counter name spaces. The top
45 * level name spaces imply the interface stability level of the counter,
46 * which generally follows the Java package, class, and property naming
47 * conventions. The CounterNS enumeration values should be used to index
150 void* valuep = (void*) (psmp + data_start);
151
152 assert(is_on_c_heap() || PerfMemory::contains(cname), "just checking");
153 assert(is_on_c_heap() || PerfMemory::contains((char*)valuep), "just checking");
154
155 // copy the name, including null terminator, into PerfData memory
156 strcpy(cname, name());
157
158
159 // set the header values in PerfData memory
160 PerfDataEntry* pdep = (PerfDataEntry*)psmp;
161 pdep->entry_length = (jint)size;
162 pdep->name_offset = (jint) ((uintptr_t) cname - (uintptr_t) psmp);
163 pdep->vector_length = (jint)vlen;
164 pdep->data_type = (jbyte) type2char(dtype);
165 pdep->data_units = units();
166 pdep->data_variability = variability();
167 pdep->flags = (jbyte)flags();
168 pdep->data_offset = (jint) data_start;
169
170 log_debug(perf, datacreation)("name = %s, dtype = %d, variability = %d,"
171 " units = %d, dsize = " SIZE_FORMAT ", vlen = " SIZE_FORMAT ","
172 " pad_length = " SIZE_FORMAT ", size = " SIZE_FORMAT ", on_c_heap = %s,"
173 " address = " INTPTR_FORMAT ","
174 " data address = " INTPTR_FORMAT "\n",
175 cname, dtype, variability(),
176 units(), dsize, vlen,
177 pad_length, size, is_on_c_heap() ? "TRUE":"FALSE",
178 p2i(psmp), p2i(valuep));
179
180 // record the start of the entry and the location of the data field.
181 _pdep = pdep;
182 _valuep = valuep;
183
184 // mark the PerfData memory region as having been updated.
185 PerfMemory::mark_updated();
186 }
187
188 PerfLong::PerfLong(CounterNS ns, const char* namep, Units u, Variability v)
189 : PerfData(ns, namep, u, v) {
190
191 create_entry(T_LONG, sizeof(jlong));
192 }
193
194 int PerfLong::format(char* buffer, int length) {
195 return jio_snprintf(buffer, length, JLONG_FORMAT, *(jlong*)_valuep);
196 }
197
198 PerfLongVariant::PerfLongVariant(CounterNS ns, const char* namep, Units u,
|