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/thread_interrupter.h" | 8 #include "vm/thread_interrupter.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
(...skipping 20 matching lines...) Expand all Loading... |
31 state->sp = reinterpret_cast<uintptr_t>(context.Rsp); | 31 state->sp = reinterpret_cast<uintptr_t>(context.Rsp); |
32 #else | 32 #else |
33 UNIMPLEMENTED(); | 33 UNIMPLEMENTED(); |
34 #endif | 34 #endif |
35 return true; | 35 return true; |
36 } | 36 } |
37 return false; | 37 return false; |
38 } | 38 } |
39 | 39 |
40 | 40 |
41 static void Interrupt(ThreadInterrupter::ThreadState* state) { | 41 static void Interrupt(InterruptableThreadState* state) { |
42 ASSERT(GetCurrentThread() != state->id); | 42 ASSERT(GetCurrentThread() != state->id); |
43 DWORD result = SuspendThread(state->id); | 43 DWORD result = SuspendThread(state->id); |
44 if (result == kThreadError) { | 44 if (result == kThreadError) { |
45 if (FLAG_trace_thread_interrupter) { | 45 if (FLAG_trace_thread_interrupter) { |
46 OS::Print("ThreadInterrupted failed to suspend thread %p\n", | 46 OS::Print("ThreadInterrupted failed to suspend thread %p\n", |
47 reinterpret_cast<void*>(state->id)); | 47 reinterpret_cast<void*>(state->id)); |
48 } | 48 } |
49 return; | 49 return; |
50 } | 50 } |
51 InterruptedThreadState its; | 51 InterruptedThreadState its; |
(...skipping 11 matching lines...) Expand all Loading... |
63 // No callback registered. | 63 // No callback registered. |
64 ResumeThread(state->id); | 64 ResumeThread(state->id); |
65 return; | 65 return; |
66 } | 66 } |
67 state->callback(its, state->data); | 67 state->callback(its, state->data); |
68 ResumeThread(state->id); | 68 ResumeThread(state->id); |
69 } | 69 } |
70 }; | 70 }; |
71 | 71 |
72 | 72 |
73 void ThreadInterrupter::InterruptThreads(int64_t current_time) { | 73 void ThreadInterrupter::InterruptThread(InterruptableThreadState* state) { |
74 for (intptr_t i = 0; i < threads_size_; i++) { | 74 if (FLAG_trace_thread_interrupter) { |
75 ThreadState* state = threads_[i]; | 75 OS::Print("ThreadInterrupter suspending %p\n", |
76 ASSERT(state->id != Thread::kInvalidThreadId); | 76 reinterpret_cast<void*>(state->id)); |
77 if (FLAG_trace_thread_interrupter) { | 77 } |
78 OS::Print("ThreadInterrupter suspending %p\n", | 78 ThreadInterrupterWin::Interrupt(state); |
79 reinterpret_cast<void*>(state->id)); | 79 if (FLAG_trace_thread_interrupter) { |
80 } | 80 OS::Print("ThreadInterrupter resuming %p\n", |
81 ThreadInterrupterWin::Interrupt(state); | 81 reinterpret_cast<void*>(state->id)); |
82 if (FLAG_trace_thread_interrupter) { | |
83 OS::Print("ThreadInterrupter resuming %p\n", | |
84 reinterpret_cast<void*>(state->id)); | |
85 } | |
86 } | 82 } |
87 } | 83 } |
88 | 84 |
89 | 85 |
90 void ThreadInterrupter::InstallSignalHandler() { | 86 void ThreadInterrupter::InstallSignalHandler() { |
91 // Nothing to do on Windows. | 87 // Nothing to do on Windows. |
92 } | 88 } |
93 | 89 |
94 | 90 |
95 } // namespace dart | 91 } // namespace dart |
96 | 92 |
97 #endif // defined(TARGET_OS_WINDOWS) | 93 #endif // defined(TARGET_OS_WINDOWS) |
98 | 94 |
OLD | NEW |