| 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 #ifndef VM_THREAD_INTERRUPTER_H_ | 5 #ifndef VM_THREAD_INTERRUPTER_H_ |
| 6 #define VM_THREAD_INTERRUPTER_H_ | 6 #define VM_THREAD_INTERRUPTER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/signal_handler.h" | 9 #include "vm/signal_handler.h" |
| 10 #include "vm/os_thread.h" | 10 #include "vm/os_thread.h" |
| 11 #include "vm/thread.h" | 11 #include "vm/thread.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 struct InterruptedThreadState { |
| 16 uintptr_t pc; |
| 17 uintptr_t csp; |
| 18 uintptr_t dsp; |
| 19 uintptr_t fp; |
| 20 uintptr_t lr; |
| 21 }; |
| 22 |
| 23 |
| 15 class ThreadInterrupter : public AllStatic { | 24 class ThreadInterrupter : public AllStatic { |
| 16 public: | 25 public: |
| 17 static void InitOnce(); | 26 static void InitOnce(); |
| 18 | 27 |
| 19 static void Startup(); | 28 static void Startup(); |
| 20 static void Shutdown(); | 29 static void Shutdown(); |
| 21 | 30 |
| 22 // Delay between interrupts. | 31 // Delay between interrupts. |
| 23 static void SetInterruptPeriod(intptr_t period); | 32 static void SetInterruptPeriod(intptr_t period); |
| 24 | 33 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 static bool woken_up_; | 45 static bool woken_up_; |
| 37 static ThreadJoinId interrupter_thread_id_; | 46 static ThreadJoinId interrupter_thread_id_; |
| 38 static Monitor* monitor_; | 47 static Monitor* monitor_; |
| 39 static intptr_t interrupt_period_; | 48 static intptr_t interrupt_period_; |
| 40 static intptr_t current_wait_time_; | 49 static intptr_t current_wait_time_; |
| 41 | 50 |
| 42 static bool InDeepSleep() { | 51 static bool InDeepSleep() { |
| 43 return current_wait_time_ == Monitor::kNoTimeout; | 52 return current_wait_time_ == Monitor::kNoTimeout; |
| 44 } | 53 } |
| 45 | 54 |
| 46 static void UpdateStateObject(ThreadInterruptCallback callback, void* data); | |
| 47 | |
| 48 static void ThreadMain(uword parameters); | 55 static void ThreadMain(uword parameters); |
| 49 | 56 |
| 50 static void InstallSignalHandler(); | 57 static void InstallSignalHandler(); |
| 51 | 58 |
| 52 static void RemoveSignalHandler(); | 59 static void RemoveSignalHandler(); |
| 53 | 60 |
| 54 friend class ThreadInterrupterVisitIsolates; | 61 friend class ThreadInterrupterVisitIsolates; |
| 55 }; | 62 }; |
| 56 | 63 |
| 57 } // namespace dart | 64 } // namespace dart |
| 58 | 65 |
| 59 #endif // VM_THREAD_INTERRUPTER_H_ | 66 #endif // VM_THREAD_INTERRUPTER_H_ |
| OLD | NEW |