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

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 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 ASSERT(!OSThread::Compare(GetCurrentThreadId(), os_thread->id()));
57 HANDLE handle = OpenThread(THREAD_GET_CONTEXT | 57 HANDLE handle = OpenThread(THREAD_GET_CONTEXT |
58 THREAD_QUERY_INFORMATION | 58 THREAD_QUERY_INFORMATION |
59 THREAD_SUSPEND_RESUME, 59 THREAD_SUSPEND_RESUME,
60 false, 60 false,
61 thread->id()); 61 os_thread->id());
62 ASSERT(handle != NULL); 62 ASSERT(handle != NULL);
63 DWORD result = SuspendThread(handle); 63 DWORD result = SuspendThread(handle);
64 if (result == kThreadError) { 64 if (result == kThreadError) {
65 if (FLAG_trace_thread_interrupter) { 65 if (FLAG_trace_thread_interrupter) {
66 OS::Print("ThreadInterrupter failed to suspend thread %p\n", 66 OS::Print("ThreadInterrupter failed to suspend thread %p\n",
67 reinterpret_cast<void*>(thread->id())); 67 reinterpret_cast<void*>(os_thread->id()));
68 } 68 }
69 CloseHandle(handle); 69 CloseHandle(handle);
70 return; 70 return;
71 } 71 }
72 InterruptedThreadState its; 72 InterruptedThreadState its;
73 if (!GrabRegisters(handle, &its)) { 73 if (!GrabRegisters(handle, &its)) {
74 // Failed to get thread registers. 74 // Failed to get thread registers.
75 ResumeThread(handle); 75 ResumeThread(handle);
76 if (FLAG_trace_thread_interrupter) { 76 if (FLAG_trace_thread_interrupter) {
77 OS::Print("ThreadInterrupter failed to get registers for %p\n", 77 OS::Print("ThreadInterrupter failed to get registers for %p\n",
78 reinterpret_cast<void*>(thread->id())); 78 reinterpret_cast<void*>(os_thread->id()));
79 } 79 }
80 CloseHandle(handle); 80 CloseHandle(handle);
81 return; 81 return;
82 } 82 }
83 Profiler::SampleThread(thread, its); 83 // Currently we sample only threads that are associated
84 // with an isolate. It is safe to call 'os_thread->thread()'
85 // here as the thread which is being queried is suspended.
86 Thread* thread = os_thread->thread();
87 if (thread != NULL) {
88 Profiler::SampleThread(thread, its);
89 }
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