Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: runtime/vm/thread_interrupter_win.cc

Issue 1412733008: Switch profiler from isolates to threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/profiler.h"
10 #include "vm/thread_interrupter.h" 11 #include "vm/thread_interrupter.h"
11 12
13
siva 2015/10/29 21:47:41 extra blank line?
Cutch 2015/11/02 20:47:12 Done.
12 namespace dart { 14 namespace dart {
13 15
14 DECLARE_FLAG(bool, thread_interrupter); 16 DECLARE_FLAG(bool, thread_interrupter);
15 DECLARE_FLAG(bool, trace_thread_interrupter); 17 DECLARE_FLAG(bool, trace_thread_interrupter);
16 18
17 #define kThreadError -1 19 #define kThreadError -1
18 20
19 class ThreadInterrupterWin : public AllStatic { 21 class ThreadInterrupterWin : public AllStatic {
20 public: 22 public:
21 static bool GrabRegisters(HANDLE handle, InterruptedThreadState* state) { 23 static bool GrabRegisters(HANDLE handle, InterruptedThreadState* state) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 DWORD result = SuspendThread(handle); 64 DWORD result = SuspendThread(handle);
63 if (result == kThreadError) { 65 if (result == kThreadError) {
64 if (FLAG_trace_thread_interrupter) { 66 if (FLAG_trace_thread_interrupter) {
65 OS::Print("ThreadInterrupter failed to suspend thread %p\n", 67 OS::Print("ThreadInterrupter failed to suspend thread %p\n",
66 reinterpret_cast<void*>(thread->id())); 68 reinterpret_cast<void*>(thread->id()));
67 } 69 }
68 CloseHandle(handle); 70 CloseHandle(handle);
69 return; 71 return;
70 } 72 }
71 InterruptedThreadState its; 73 InterruptedThreadState its;
72 its.tid = thread->id();
73 if (!GrabRegisters(handle, &its)) { 74 if (!GrabRegisters(handle, &its)) {
74 // Failed to get thread registers. 75 // Failed to get thread registers.
75 ResumeThread(handle); 76 ResumeThread(handle);
76 if (FLAG_trace_thread_interrupter) { 77 if (FLAG_trace_thread_interrupter) {
77 OS::Print("ThreadInterrupter failed to get registers for %p\n", 78 OS::Print("ThreadInterrupter failed to get registers for %p\n",
78 reinterpret_cast<void*>(thread->id())); 79 reinterpret_cast<void*>(thread->id()));
79 } 80 }
80 CloseHandle(handle); 81 CloseHandle(handle);
81 return; 82 return;
82 } 83 }
83 ThreadInterruptCallback callback = NULL; 84 Profiler::SampleThread(thread, its);
84 void* callback_data = NULL;
85 if (thread->IsThreadInterrupterEnabled(&callback, &callback_data)) {
86 callback(its, callback_data);
87 }
88 ResumeThread(handle); 85 ResumeThread(handle);
89 CloseHandle(handle); 86 CloseHandle(handle);
90 } 87 }
91 }; 88 };
92 89
93 90
94 void ThreadInterrupter::InterruptThread(Thread* thread) { 91 void ThreadInterrupter::InterruptThread(Thread* thread) {
95 if (FLAG_trace_thread_interrupter) { 92 if (FLAG_trace_thread_interrupter) {
96 OS::Print("ThreadInterrupter suspending %p\n", 93 OS::Print("ThreadInterrupter suspending %p\n",
97 reinterpret_cast<void*>(thread->id())); 94 reinterpret_cast<void*>(thread->id()));
(...skipping 13 matching lines...) Expand all
111 108
112 void ThreadInterrupter::RemoveSignalHandler() { 109 void ThreadInterrupter::RemoveSignalHandler() {
113 // Nothing to do on Windows. 110 // Nothing to do on Windows.
114 } 111 }
115 112
116 113
117 } // namespace dart 114 } // namespace dart
118 115
119 #endif // defined(TARGET_OS_WINDOWS) 116 #endif // defined(TARGET_OS_WINDOWS)
120 117
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698