< prev index next >

src/share/vm/prims/perf.cpp

Print this page




 278 
 279 PERF_ENTRY(jlong, Perf_HighResFrequency(JNIEnv *env, jobject perf))
 280 
 281   PerfWrapper("Perf_HighResFrequency");
 282 
 283   // this should be a method in java.lang.System. This value could
 284   // be acquired through access to a PerfData performance counter, but
 285   // doing so would require that the PerfData monitoring overhead be
 286   // incurred by all Java applications, which is unacceptable.
 287 
 288   return os::elapsed_frequency();
 289 
 290 PERF_END
 291 
 292 /// JVM_RegisterPerfMethods
 293 
 294 #define CC (char*)  /*cast a literal from (const char*)*/
 295 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 296 #define BB "Ljava/nio/ByteBuffer;"
 297 #define JLS "Ljava/lang/String;"
 298 #define CL_ARGS     CC"("JLS"IIJ)"BB
 299 #define CBA_ARGS    CC"("JLS"II[BI)"BB
 300 
 301 static JNINativeMethod perfmethods[] = {
 302 
 303   {CC"attach",              CC"("JLS"II)"BB,  FN_PTR(Perf_Attach)},
 304   {CC"detach",              CC"("BB")V",      FN_PTR(Perf_Detach)},
 305   {CC"createLong",          CL_ARGS,          FN_PTR(Perf_CreateLong)},
 306   {CC"createByteArray",     CBA_ARGS,         FN_PTR(Perf_CreateByteArray)},
 307   {CC"highResCounter",      CC"()J",          FN_PTR(Perf_HighResCounter)},
 308   {CC"highResFrequency",    CC"()J",          FN_PTR(Perf_HighResFrequency)}
 309 };
 310 
 311 #undef CBA_ARGS
 312 #undef CL_ARGS
 313 #undef JLS
 314 #undef BB
 315 #undef FN_PTR
 316 #undef CC
 317 
 318 // This one function is exported, used by NativeLookup.
 319 JVM_ENTRY(void, JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass))
 320   PerfWrapper("JVM_RegisterPerfMethods");
 321   {
 322     ThreadToNativeFromVM ttnfv(thread);
 323     int ok = env->RegisterNatives(perfclass, perfmethods, sizeof(perfmethods)/sizeof(JNINativeMethod));
 324     guarantee(ok == 0, "register perf natives");
 325   }
 326 JVM_END


 278 
 279 PERF_ENTRY(jlong, Perf_HighResFrequency(JNIEnv *env, jobject perf))
 280 
 281   PerfWrapper("Perf_HighResFrequency");
 282 
 283   // this should be a method in java.lang.System. This value could
 284   // be acquired through access to a PerfData performance counter, but
 285   // doing so would require that the PerfData monitoring overhead be
 286   // incurred by all Java applications, which is unacceptable.
 287 
 288   return os::elapsed_frequency();
 289 
 290 PERF_END
 291 
 292 /// JVM_RegisterPerfMethods
 293 
 294 #define CC (char*)  /*cast a literal from (const char*)*/
 295 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 296 #define BB "Ljava/nio/ByteBuffer;"
 297 #define JLS "Ljava/lang/String;"
 298 #define CL_ARGS     CC "(" JLS "IIJ)" BB
 299 #define CBA_ARGS    CC "(" JLS "II[BI)" BB
 300 
 301 static JNINativeMethod perfmethods[] = {
 302 
 303   {CC "attach",              CC "(" JLS "II)" BB, FN_PTR(Perf_Attach)},
 304   {CC "detach",              CC "(" BB ")V",      FN_PTR(Perf_Detach)},
 305   {CC "createLong",          CL_ARGS,             FN_PTR(Perf_CreateLong)},
 306   {CC "createByteArray",     CBA_ARGS,            FN_PTR(Perf_CreateByteArray)},
 307   {CC "highResCounter",      CC "()J",            FN_PTR(Perf_HighResCounter)},
 308   {CC "highResFrequency",    CC "()J",            FN_PTR(Perf_HighResFrequency)}
 309 };
 310 
 311 #undef CBA_ARGS
 312 #undef CL_ARGS
 313 #undef JLS
 314 #undef BB
 315 #undef FN_PTR
 316 #undef CC
 317 
 318 // This one function is exported, used by NativeLookup.
 319 JVM_ENTRY(void, JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass))
 320   PerfWrapper("JVM_RegisterPerfMethods");
 321   {
 322     ThreadToNativeFromVM ttnfv(thread);
 323     int ok = env->RegisterNatives(perfclass, perfmethods, sizeof(perfmethods)/sizeof(JNINativeMethod));
 324     guarantee(ok == 0, "register perf natives");
 325   }
 326 JVM_END
< prev index next >