Mercurial > hg > truffle
comparison src/share/vm/prims/jvm.cpp @ 1324:e392695de029
6935224: Adding new DTrace probes to work with Palantir
Summary: Adding probes related to thread scheduling and class initialization
Reviewed-by: kamg, never
author | fparain |
---|---|
date | Wed, 17 Mar 2010 11:01:05 +0100 |
parents | 9b9c1ee9b3f6 |
children | c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
1323:cd20a6f46fec | 1324:e392695de029 |
---|---|
23 */ | 23 */ |
24 | 24 |
25 #include "incls/_precompiled.incl" | 25 #include "incls/_precompiled.incl" |
26 #include "incls/_jvm.cpp.incl" | 26 #include "incls/_jvm.cpp.incl" |
27 #include <errno.h> | 27 #include <errno.h> |
28 | |
29 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__begin, long long); | |
30 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__end, int); | |
31 HS_DTRACE_PROBE_DECL0(hotspot, thread__yield); | |
28 | 32 |
29 /* | 33 /* |
30 NOTE about use of any ctor or function call that can trigger a safepoint/GC: | 34 NOTE about use of any ctor or function call that can trigger a safepoint/GC: |
31 such ctors and calls MUST NOT come between an oop declaration/init and its | 35 such ctors and calls MUST NOT come between an oop declaration/init and its |
32 usage because if objects are move this may cause various memory stomps, bus | 36 usage because if objects are move this may cause various memory stomps, bus |
2760 | 2764 |
2761 | 2765 |
2762 JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) | 2766 JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) |
2763 JVMWrapper("JVM_Yield"); | 2767 JVMWrapper("JVM_Yield"); |
2764 if (os::dont_yield()) return; | 2768 if (os::dont_yield()) return; |
2769 HS_DTRACE_PROBE0(hotspot, thread__yield); | |
2765 // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield. | 2770 // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield. |
2766 // Critical for similar threading behaviour | 2771 // Critical for similar threading behaviour |
2767 if (ConvertYieldToSleep) { | 2772 if (ConvertYieldToSleep) { |
2768 os::sleep(thread, MinSleepInterval, false); | 2773 os::sleep(thread, MinSleepInterval, false); |
2769 } else { | 2774 } else { |
2784 } | 2789 } |
2785 | 2790 |
2786 // Save current thread state and restore it at the end of this block. | 2791 // Save current thread state and restore it at the end of this block. |
2787 // And set new thread state to SLEEPING. | 2792 // And set new thread state to SLEEPING. |
2788 JavaThreadSleepState jtss(thread); | 2793 JavaThreadSleepState jtss(thread); |
2794 | |
2795 HS_DTRACE_PROBE1(hotspot, thread__sleep__begin, millis); | |
2789 | 2796 |
2790 if (millis == 0) { | 2797 if (millis == 0) { |
2791 // When ConvertSleepToYield is on, this matches the classic VM implementation of | 2798 // When ConvertSleepToYield is on, this matches the classic VM implementation of |
2792 // JVM_Sleep. Critical for similar threading behaviour (Win32) | 2799 // JVM_Sleep. Critical for similar threading behaviour (Win32) |
2793 // It appears that in certain GUI contexts, it may be beneficial to do a short sleep | 2800 // It appears that in certain GUI contexts, it may be beneficial to do a short sleep |
2805 thread->osthread()->set_state(SLEEPING); | 2812 thread->osthread()->set_state(SLEEPING); |
2806 if (os::sleep(thread, millis, true) == OS_INTRPT) { | 2813 if (os::sleep(thread, millis, true) == OS_INTRPT) { |
2807 // An asynchronous exception (e.g., ThreadDeathException) could have been thrown on | 2814 // An asynchronous exception (e.g., ThreadDeathException) could have been thrown on |
2808 // us while we were sleeping. We do not overwrite those. | 2815 // us while we were sleeping. We do not overwrite those. |
2809 if (!HAS_PENDING_EXCEPTION) { | 2816 if (!HAS_PENDING_EXCEPTION) { |
2817 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,1); | |
2810 // TODO-FIXME: THROW_MSG returns which means we will not call set_state() | 2818 // TODO-FIXME: THROW_MSG returns which means we will not call set_state() |
2811 // to properly restore the thread state. That's likely wrong. | 2819 // to properly restore the thread state. That's likely wrong. |
2812 THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"); | 2820 THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"); |
2813 } | 2821 } |
2814 } | 2822 } |
2815 thread->osthread()->set_state(old_state); | 2823 thread->osthread()->set_state(old_state); |
2816 } | 2824 } |
2825 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,0); | |
2817 JVM_END | 2826 JVM_END |
2818 | 2827 |
2819 JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass)) | 2828 JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass)) |
2820 JVMWrapper("JVM_CurrentThread"); | 2829 JVMWrapper("JVM_CurrentThread"); |
2821 oop jthread = thread->threadObj(); | 2830 oop jthread = thread->threadObj(); |