/* * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
if (!UsePerfData) { // With -XX:-UsePerfData, detach is just a NOP return;
}
void* address = 0;
jlong capacity = 0;
// get buffer address and capacity
{
ThreadToNativeFromVM ttnfv(thread);
address = env->GetDirectBufferAddress(buffer);
capacity = env->GetDirectBufferCapacity(buffer);
}
PerfMemory::detach((char*)address, capacity);
PERF_END
PERF_ENTRY(jobject, Perf_CreateLong(JNIEnv *env, jobject perf, jstring name, int variability, int units, jlong value))
PerfWrapper("Perf_CreateLong");
char* name_utf = NULL;
if (units <= 0 || units > PerfData::U_Last) {
debug_only(warning("unexpected units argument, units = %d", units));
THROW_0(vmSymbols::java_lang_IllegalArgumentException());
}
ResourceMark rm;
{
ThreadToNativeFromVM ttnfv(thread);
name_utf = jstr_to_utf(env, name, CHECK_NULL);
}
PerfLong* pl = NULL;
// check that the PerfData name doesn't already exist if (PerfDataManager::exists(name_utf)) {
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "PerfLong name already exists");
}
// check for valid units if (units != PerfData::U_String) { // only String based ByteArray objects are currently supported
debug_only(warning("unexpected units value: %d", variability));
THROW_0(vmSymbols::java_lang_IllegalArgumentException());
}
int value_length; char* name_utf = NULL;
jbyte* value_local = NULL;
// check that the counter name doesn't already exist if (PerfDataManager::exists((char*)name_utf)) {
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "PerfByteArray name already exists");
}
PerfByteArray* pbv = NULL;
if (units == PerfData::U_String) {
if (variability == PerfData::V_Constant) { // create the string constant
pbv = PerfDataManager::create_string_constant(NULL_NS, (char*)name_utf,
(char*)value_local,
CHECK_NULL);
assert(maxlength == value_length, "string constant length should be == maxlength");
maxlength = value_length;
} else {
// this should be a method in java.lang.System. This value could // be acquired through access to a PerfData performance counter, but // doing so would require that the PerfData monitoring overhead be // incurred by all Java applications, which is unacceptable.
// this should be a method in java.lang.System. This value could // be acquired through access to a PerfData performance counter, but // doing so would require that the PerfData monitoring overhead be // incurred by all Java applications, which is unacceptable.
return os::elapsed_frequency();
PERF_END
/// JVM_RegisterPerfMethods
#define CC (char*) /*cast a literal from (const char*)*/ #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f) #define BB "Ljava/nio/ByteBuffer;" #define JLS "Ljava/lang/String;" #define CL_ARGS CC "(" JLS "IIJ)" BB #define CBA_ARGS CC "(" JLS "II[BI)" BB
static JNINativeMethod perfmethods[] = {
{CC "attach0", CC "(I)" BB, FN_PTR(Perf_Attach)},
{CC "detach", CC "(" BB ")V", FN_PTR(Perf_Detach)},
{CC "createLong", CL_ARGS, FN_PTR(Perf_CreateLong)},
{CC "createByteArray", CBA_ARGS, FN_PTR(Perf_CreateByteArray)},
{CC "highResCounter", CC "()J", FN_PTR(Perf_HighResCounter)},
{CC "highResFrequency", CC "()J", FN_PTR(Perf_HighResFrequency)}
};
// This one function is exported, used by NativeLookup.
JVM_ENTRY(void, JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass))
PerfWrapper("JVM_RegisterPerfMethods");
{
ThreadToNativeFromVM ttnfv(thread); int ok = env->RegisterNatives(perfclass, perfmethods, sizeof(perfmethods)/sizeof(JNINativeMethod));
guarantee(ok == 0, "register perf natives");
}
JVM_END
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.