Mercurial > hg > graal-compiler
comparison src/os/windows/vm/os_windows.cpp @ 10405:f2110083203d
8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
author | sla |
---|---|
date | Mon, 10 Jun 2013 11:30:51 +0200 |
parents | e72f7eecc96d |
children | 836a62f43af9 a837fa3d3f86 |
comparison
equal
deleted
inserted
replaced
10404:d0add7016434 | 10405:f2110083203d |
---|---|
5046 int os::set_sock_opt(int fd, int level, int optname, | 5046 int os::set_sock_opt(int fd, int level, int optname, |
5047 const char* optval, socklen_t optlen) { | 5047 const char* optval, socklen_t optlen) { |
5048 return ::setsockopt(fd, level, optname, optval, optlen); | 5048 return ::setsockopt(fd, level, optname, optval, optlen); |
5049 } | 5049 } |
5050 | 5050 |
5051 // WINDOWS CONTEXT Flags for THREAD_SAMPLING | |
5052 #if defined(IA32) | |
5053 # define sampling_context_flags (CONTEXT_FULL | CONTEXT_FLOATING_POINT | CONTEXT_EXTENDED_REGISTERS) | |
5054 #elif defined (AMD64) | |
5055 # define sampling_context_flags (CONTEXT_FULL | CONTEXT_FLOATING_POINT) | |
5056 #endif | |
5057 | |
5058 // returns true if thread could be suspended, | |
5059 // false otherwise | |
5060 static bool do_suspend(HANDLE* h) { | |
5061 if (h != NULL) { | |
5062 if (SuspendThread(*h) != ~0) { | |
5063 return true; | |
5064 } | |
5065 } | |
5066 return false; | |
5067 } | |
5068 | |
5069 // resume the thread | |
5070 // calling resume on an active thread is a no-op | |
5071 static void do_resume(HANDLE* h) { | |
5072 if (h != NULL) { | |
5073 ResumeThread(*h); | |
5074 } | |
5075 } | |
5076 | |
5077 // retrieve a suspend/resume context capable handle | |
5078 // from the tid. Caller validates handle return value. | |
5079 void get_thread_handle_for_extended_context(HANDLE* h, OSThread::thread_id_t tid) { | |
5080 if (h != NULL) { | |
5081 *h = OpenThread(THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION, FALSE, tid); | |
5082 } | |
5083 } | |
5084 | |
5085 // | |
5086 // Thread sampling implementation | |
5087 // | |
5088 void os::SuspendedThreadTask::internal_do_task() { | |
5089 CONTEXT ctxt; | |
5090 HANDLE h = NULL; | |
5091 | |
5092 // get context capable handle for thread | |
5093 get_thread_handle_for_extended_context(&h, _thread->osthread()->thread_id()); | |
5094 | |
5095 // sanity | |
5096 if (h == NULL || h == INVALID_HANDLE_VALUE) { | |
5097 return; | |
5098 } | |
5099 | |
5100 // suspend the thread | |
5101 if (do_suspend(&h)) { | |
5102 ctxt.ContextFlags = sampling_context_flags; | |
5103 // get thread context | |
5104 GetThreadContext(h, &ctxt); | |
5105 SuspendedThreadTaskContext context(_thread, &ctxt); | |
5106 // pass context to Thread Sampling impl | |
5107 do_task(context); | |
5108 // resume thread | |
5109 do_resume(&h); | |
5110 } | |
5111 | |
5112 // close handle | |
5113 CloseHandle(h); | |
5114 } | |
5115 | |
5051 | 5116 |
5052 // Kernel32 API | 5117 // Kernel32 API |
5053 typedef SIZE_T (WINAPI* GetLargePageMinimum_Fn)(void); | 5118 typedef SIZE_T (WINAPI* GetLargePageMinimum_Fn)(void); |
5054 typedef LPVOID (WINAPI *VirtualAllocExNuma_Fn) (HANDLE, LPVOID, SIZE_T, DWORD, DWORD, DWORD); | 5119 typedef LPVOID (WINAPI *VirtualAllocExNuma_Fn) (HANDLE, LPVOID, SIZE_T, DWORD, DWORD, DWORD); |
5055 typedef BOOL (WINAPI *GetNumaHighestNodeNumber_Fn) (PULONG); | 5120 typedef BOOL (WINAPI *GetNumaHighestNodeNumber_Fn) (PULONG); |