Index: runtime/vm/thread.h |
diff --git a/runtime/vm/thread.h b/runtime/vm/thread.h |
index 44b804013e7b6ec3c85ff4c0d8ef290d7ac88ca5..c9e35175eb55460d06db53d5b43e9a44d4332def 100644 |
--- a/runtime/vm/thread.h |
+++ b/runtime/vm/thread.h |
@@ -39,6 +39,24 @@ class Zone; |
CACHED_VM_OBJECTS_LIST(V) \ |
CACHED_ADDRESSES_LIST(V) |
+struct InterruptedThreadState { |
+ ThreadId tid; |
+ uintptr_t pc; |
+ uintptr_t csp; |
+ uintptr_t dsp; |
+ uintptr_t fp; |
+ uintptr_t lr; |
+}; |
+ |
+// When a thread is interrupted the thread specific interrupt callback will be |
+// invoked. Each callback is given an InterruptedThreadState and the user data |
+// pointer. When inside a thread interrupt callback doing any of the following |
+// is forbidden: |
+// * Accessing TLS. |
Ivan Posva
2015/08/20 18:00:10
Can you please explain in the comments why these t
Cutch
2015/08/20 20:40:19
Done.
|
+// * Allocating memory. |
koda
2015/08/20 15:45:14
To catch violations of this in DEBUG mode, conside
Cutch
2015/08/20 20:40:19
This comment was about native C allocations.
|
+// * Taking a lock. |
+typedef void (*ThreadInterruptCallback)(const InterruptedThreadState& state, |
+ void* data); |
// A VM thread; may be executing Dart code or performing helper tasks like |
// garbage collection or compilation. The Thread structure associated with |
@@ -233,9 +251,28 @@ CACHED_CONSTANTS_LIST(DEFINE_OFFSET_METHOD) |
state_.long_jump_base = value; |
} |
+ ThreadId id() const { |
+ return id_; |
+ } |
+ |
+ ThreadInterruptCallback thread_interrupt_callback() const { |
+ return thread_interrupt_callback_; |
+ } |
+ |
+ void* thread_interrupt_data() const { |
+ return thread_interrupt_data_; |
+ } |
+ |
+ void SetThreadInterrupter(ThreadInterruptCallback callback, void* data); |
+ |
+ bool ShouldInterrupt() const; |
+ |
private: |
static ThreadLocalKey thread_key_; |
+ const ThreadId id_; |
+ ThreadInterruptCallback thread_interrupt_callback_; |
+ void* thread_interrupt_data_; |
Isolate* isolate_; |
Heap* heap_; |
State state_; |