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
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-09-03)
¤
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 und die Messung sind noch experimentell.