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

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

Issue 1439483003: - Add an OSThread structure which is the generic TLS structure for all C++ (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review-comments 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
« no previous file with comments | « runtime/vm/thread_interrupter_macos.cc ('k') | runtime/vm/thread_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/profiler.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 state->dsp = static_cast<uintptr_t>(context.Rsp); 45 state->dsp = static_cast<uintptr_t>(context.Rsp);
46 #else 46 #else
47 #error Unsupported architecture. 47 #error Unsupported architecture.
48 #endif 48 #endif
49 return true; 49 return true;
50 } 50 }
51 return false; 51 return false;
52 } 52 }
53 53
54 54
55 static void Interrupt(Thread* thread) { 55 static void Interrupt(OSThread* os_thread) {
56 ASSERT(!OSThread::Compare(GetCurrentThreadId(), thread->id())); 56 // Currently we sample only threads that are associated
57 // with an isolate.
58 Thread* thread = Thread::Current();
Cutch 2015/11/17 23:19:01 On Windows this is running on a different thread t
siva 2015/11/18 20:25:10 Addressed this as discussed offline.
59 if (thread == NULL) {
60 return;
61 }
62 ASSERT(!OSThread::Compare(GetCurrentThreadId(), os_thread->id()));
57 HANDLE handle = OpenThread(THREAD_GET_CONTEXT | 63 HANDLE handle = OpenThread(THREAD_GET_CONTEXT |
58 THREAD_QUERY_INFORMATION | 64 THREAD_QUERY_INFORMATION |
59 THREAD_SUSPEND_RESUME, 65 THREAD_SUSPEND_RESUME,
60 false, 66 false,
61 thread->id()); 67 os_thread->id());
62 ASSERT(handle != NULL); 68 ASSERT(handle != NULL);
63 DWORD result = SuspendThread(handle); 69 DWORD result = SuspendThread(handle);
64 if (result == kThreadError) { 70 if (result == kThreadError) {
65 if (FLAG_trace_thread_interrupter) { 71 if (FLAG_trace_thread_interrupter) {
66 OS::Print("ThreadInterrupter failed to suspend thread %p\n", 72 OS::Print("ThreadInterrupter failed to suspend thread %p\n",
67 reinterpret_cast<void*>(thread->id())); 73 reinterpret_cast<void*>(os_thread->id()));
68 } 74 }
69 CloseHandle(handle); 75 CloseHandle(handle);
70 return; 76 return;
71 } 77 }
72 InterruptedThreadState its; 78 InterruptedThreadState its;
73 if (!GrabRegisters(handle, &its)) { 79 if (!GrabRegisters(handle, &its)) {
74 // Failed to get thread registers. 80 // Failed to get thread registers.
75 ResumeThread(handle); 81 ResumeThread(handle);
76 if (FLAG_trace_thread_interrupter) { 82 if (FLAG_trace_thread_interrupter) {
77 OS::Print("ThreadInterrupter failed to get registers for %p\n", 83 OS::Print("ThreadInterrupter failed to get registers for %p\n",
78 reinterpret_cast<void*>(thread->id())); 84 reinterpret_cast<void*>(os_thread->id()));
79 } 85 }
80 CloseHandle(handle); 86 CloseHandle(handle);
81 return; 87 return;
82 } 88 }
83 Profiler::SampleThread(thread, its); 89 Profiler::SampleThread(thread, its);
84 ResumeThread(handle); 90 ResumeThread(handle);
85 CloseHandle(handle); 91 CloseHandle(handle);
86 } 92 }
87 }; 93 };
88 94
89 95
90 void ThreadInterrupter::InterruptThread(Thread* thread) { 96 void ThreadInterrupter::InterruptThread(OSThread* thread) {
91 if (FLAG_trace_thread_interrupter) { 97 if (FLAG_trace_thread_interrupter) {
92 OS::Print("ThreadInterrupter suspending %p\n", 98 OS::Print("ThreadInterrupter suspending %p\n",
93 reinterpret_cast<void*>(thread->id())); 99 reinterpret_cast<void*>(thread->id()));
94 } 100 }
95 ThreadInterrupterWin::Interrupt(thread); 101 ThreadInterrupterWin::Interrupt(thread);
96 if (FLAG_trace_thread_interrupter) { 102 if (FLAG_trace_thread_interrupter) {
97 OS::Print("ThreadInterrupter resuming %p\n", 103 OS::Print("ThreadInterrupter resuming %p\n",
98 reinterpret_cast<void*>(thread->id())); 104 reinterpret_cast<void*>(thread->id()));
99 } 105 }
100 } 106 }
101 107
102 108
103 void ThreadInterrupter::InstallSignalHandler() { 109 void ThreadInterrupter::InstallSignalHandler() {
104 // Nothing to do on Windows. 110 // Nothing to do on Windows.
105 } 111 }
106 112
107 113
108 void ThreadInterrupter::RemoveSignalHandler() { 114 void ThreadInterrupter::RemoveSignalHandler() {
109 // Nothing to do on Windows. 115 // Nothing to do on Windows.
110 } 116 }
111 117
112 118
113 } // namespace dart 119 } // namespace dart
114 120
115 #endif // defined(TARGET_OS_WINDOWS) 121 #endif // defined(TARGET_OS_WINDOWS)
116
OLDNEW
« no previous file with comments | « runtime/vm/thread_interrupter_macos.cc ('k') | runtime/vm/thread_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698