Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/thread_interrupter.h" | 10 #include "vm/thread_interrupter.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 state->dsp = static_cast<uintptr_t>(context.Rsp); | 44 state->dsp = static_cast<uintptr_t>(context.Rsp); |
| 45 #else | 45 #else |
| 46 #error Unsupported architecture. | 46 #error Unsupported architecture. |
| 47 #endif | 47 #endif |
| 48 return true; | 48 return true; |
| 49 } | 49 } |
| 50 return false; | 50 return false; |
| 51 } | 51 } |
| 52 | 52 |
| 53 | 53 |
| 54 static void Interrupt(InterruptableThreadState* state) { | 54 static void Interrupt(Thread* thread) { |
| 55 ASSERT(!OSThread::Compare(GetCurrentThreadId(), state->id)); | 55 ASSERT(!OSThread::Compare(GetCurrentThreadId(), thread->id())); |
| 56 HANDLE handle = OpenThread(THREAD_GET_CONTEXT | | 56 HANDLE handle = OpenThread(THREAD_GET_CONTEXT | |
| 57 THREAD_QUERY_INFORMATION | | 57 THREAD_QUERY_INFORMATION | |
| 58 THREAD_SUSPEND_RESUME, | 58 THREAD_SUSPEND_RESUME, |
| 59 false, | 59 false, |
| 60 state->id); | 60 thread->id()); |
| 61 ASSERT(handle != NULL); | 61 ASSERT(handle != NULL); |
| 62 DWORD result = SuspendThread(handle); | 62 DWORD result = SuspendThread(handle); |
| 63 if (result == kThreadError) { | 63 if (result == kThreadError) { |
| 64 if (FLAG_trace_thread_interrupter) { | 64 if (FLAG_trace_thread_interrupter) { |
| 65 OS::Print("ThreadInterrupted failed to suspend thread %p\n", | 65 OS::Print("ThreadInterrupted failed to suspend thread %p\n", |
|
koda
2015/08/20 15:45:14
ThreadInterrupted -> ThreadInterrupter
Cutch
2015/08/20 20:40:19
Done.
| |
| 66 reinterpret_cast<void*>(state->id)); | 66 reinterpret_cast<void*>(thread->id())); |
| 67 } | 67 } |
| 68 CloseHandle(handle); | 68 CloseHandle(handle); |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 InterruptedThreadState its; | 71 InterruptedThreadState its; |
| 72 its.tid = state->id; | 72 its.tid = thread->id(); |
| 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("ThreadInterrupted failed to get registers for %p\n", | 77 OS::Print("ThreadInterrupted failed to get registers for %p\n", |
|
koda
2015/08/20 15:45:14
Ditto.
Cutch
2015/08/20 20:40:19
Done.
| |
| 78 reinterpret_cast<void*>(state->id)); | 78 reinterpret_cast<void*>(thread->id())); |
| 79 } | 79 } |
| 80 CloseHandle(handle); | 80 CloseHandle(handle); |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 if (state->callback == NULL) { | 83 ThreadInterruptCallback callback = thread->thread_interrupt_callback(); |
| 84 if (callback == NULL) { | |
| 84 // No callback registered. | 85 // No callback registered. |
| 85 ResumeThread(handle); | 86 ResumeThread(handle); |
| 86 CloseHandle(handle); | 87 CloseHandle(handle); |
| 87 return; | 88 return; |
| 88 } | 89 } |
| 89 state->callback(its, state->data); | 90 callback(its, state->thread_interrupt_data()); |
|
koda
2015/08/20 15:45:14
Compile error: state -> thread
Cutch
2015/08/20 20:40:19
Done.
| |
| 90 ResumeThread(handle); | 91 ResumeThread(handle); |
| 91 CloseHandle(handle); | 92 CloseHandle(handle); |
| 92 } | 93 } |
| 93 }; | 94 }; |
| 94 | 95 |
| 95 | 96 |
| 96 void ThreadInterrupter::InterruptThread(InterruptableThreadState* state) { | 97 void ThreadInterrupter::InterruptThread(Thread* thread) { |
| 97 if (FLAG_trace_thread_interrupter) { | 98 if (FLAG_trace_thread_interrupter) { |
| 98 OS::Print("ThreadInterrupter suspending %p\n", | 99 OS::Print("ThreadInterrupter suspending %p\n", |
| 99 reinterpret_cast<void*>(state->id)); | 100 reinterpret_cast<void*>(thread->id())); |
| 100 } | 101 } |
| 101 ThreadInterrupterWin::Interrupt(state); | 102 ThreadInterrupterWin::Interrupt(thread); |
| 102 if (FLAG_trace_thread_interrupter) { | 103 if (FLAG_trace_thread_interrupter) { |
| 103 OS::Print("ThreadInterrupter resuming %p\n", | 104 OS::Print("ThreadInterrupter resuming %p\n", |
| 104 reinterpret_cast<void*>(state->id)); | 105 reinterpret_cast<void*>(thread->id())); |
| 105 } | 106 } |
| 106 } | 107 } |
| 107 | 108 |
| 108 | 109 |
| 109 void ThreadInterrupter::InstallSignalHandler() { | 110 void ThreadInterrupter::InstallSignalHandler() { |
| 110 // Nothing to do on Windows. | 111 // Nothing to do on Windows. |
| 111 } | 112 } |
| 112 | 113 |
| 113 | 114 |
| 114 void ThreadInterrupter::RemoveSignalHandler() { | 115 void ThreadInterrupter::RemoveSignalHandler() { |
| 115 // Nothing to do on Windows. | 116 // Nothing to do on Windows. |
| 116 } | 117 } |
| 117 | 118 |
| 118 | 119 |
| 119 } // namespace dart | 120 } // namespace dart |
| 120 | 121 |
| 121 #endif // defined(TARGET_OS_WINDOWS) | 122 #endif // defined(TARGET_OS_WINDOWS) |
| 122 | 123 |
| OLD | NEW |