1.1 --- a/src/share/vm/prims/jvm.cpp Mon Oct 10 21:01:36 2011 -0400 1.2 +++ b/src/share/vm/prims/jvm.cpp Thu Oct 13 09:35:42 2011 -0700 1.3 @@ -79,9 +79,11 @@ 1.4 1.5 #include <errno.h> 1.6 1.7 +#ifndef USDT2 1.8 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__begin, long long); 1.9 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__end, int); 1.10 HS_DTRACE_PROBE_DECL0(hotspot, thread__yield); 1.11 +#endif /* !USDT2 */ 1.12 1.13 /* 1.14 NOTE about use of any ctor or function call that can trigger a safepoint/GC: 1.15 @@ -2816,7 +2818,11 @@ 1.16 JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) 1.17 JVMWrapper("JVM_Yield"); 1.18 if (os::dont_yield()) return; 1.19 +#ifndef USDT2 1.20 HS_DTRACE_PROBE0(hotspot, thread__yield); 1.21 +#else /* USDT2 */ 1.22 + HOTSPOT_THREAD_YIELD(); 1.23 +#endif /* USDT2 */ 1.24 // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield. 1.25 // Critical for similar threading behaviour 1.26 if (ConvertYieldToSleep) { 1.27 @@ -2842,7 +2848,12 @@ 1.28 // And set new thread state to SLEEPING. 1.29 JavaThreadSleepState jtss(thread); 1.30 1.31 +#ifndef USDT2 1.32 HS_DTRACE_PROBE1(hotspot, thread__sleep__begin, millis); 1.33 +#else /* USDT2 */ 1.34 + HOTSPOT_THREAD_SLEEP_BEGIN( 1.35 + millis); 1.36 +#endif /* USDT2 */ 1.37 1.38 if (millis == 0) { 1.39 // When ConvertSleepToYield is on, this matches the classic VM implementation of 1.40 @@ -2864,7 +2875,12 @@ 1.41 // An asynchronous exception (e.g., ThreadDeathException) could have been thrown on 1.42 // us while we were sleeping. We do not overwrite those. 1.43 if (!HAS_PENDING_EXCEPTION) { 1.44 +#ifndef USDT2 1.45 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,1); 1.46 +#else /* USDT2 */ 1.47 + HOTSPOT_THREAD_SLEEP_END( 1.48 + 1); 1.49 +#endif /* USDT2 */ 1.50 // TODO-FIXME: THROW_MSG returns which means we will not call set_state() 1.51 // to properly restore the thread state. That's likely wrong. 1.52 THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"); 1.53 @@ -2872,7 +2888,12 @@ 1.54 } 1.55 thread->osthread()->set_state(old_state); 1.56 } 1.57 +#ifndef USDT2 1.58 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,0); 1.59 +#else /* USDT2 */ 1.60 + HOTSPOT_THREAD_SLEEP_END( 1.61 + 0); 1.62 +#endif /* USDT2 */ 1.63 JVM_END 1.64 1.65 JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass)) 1.66 @@ -2990,6 +3011,20 @@ 1.67 } 1.68 JVM_END 1.69 1.70 +JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name)) 1.71 + JVMWrapper("JVM_SetNativeThreadName"); 1.72 + ResourceMark rm(THREAD); 1.73 + oop java_thread = JNIHandles::resolve_non_null(jthread); 1.74 + JavaThread* thr = java_lang_Thread::thread(java_thread); 1.75 + // Thread naming only supported for the current thread, doesn't work for 1.76 + // target threads. 1.77 + if (Thread::current() == thr && !thr->has_attached_via_jni()) { 1.78 + // we don't set the name of an attached thread to avoid stepping 1.79 + // on other programs 1.80 + const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); 1.81 + os::set_native_thread_name(thread_name); 1.82 + } 1.83 +JVM_END 1.84 1.85 // java.lang.SecurityManager /////////////////////////////////////////////////////////////////////// 1.86