Index: runtime/vm/thread.h |
diff --git a/runtime/vm/thread.h b/runtime/vm/thread.h |
index 3bf5aab1e6de811ed47e911e26b2f34ae5ca814c..3dbc47306d3280f2efbaa0db37dfc348cefdf4ca 100644 |
--- a/runtime/vm/thread.h |
+++ b/runtime/vm/thread.h |
@@ -145,6 +145,60 @@ class Thread : public BaseThread { |
// Empties the store buffer block into the isolate. |
void PrepareForGC(); |
+ void SetStackLimit(uword value); |
+ void SetStackLimitFromStackBase(uword stack_base); |
+ void ClearStackLimit(); |
+ |
+ // Returns the current C++ stack pointer. Equivalent taking the address of a |
+ // stack allocated local, but plays well with AddressSanitizer. |
+ static uword GetCurrentStackPointer(); |
+ |
+ // Access to the current stack limit for generated code. This may be |
+ // overwritten with a special value to trigger interrupts. |
+ uword stack_limit_address() const { |
+ return reinterpret_cast<uword>(&stack_limit_); |
+ } |
+ static intptr_t stack_limit_offset() { |
+ return OFFSET_OF(Thread, stack_limit_); |
+ } |
+ |
+ // The true stack limit for this isolate. |
+ uword saved_stack_limit() const { return saved_stack_limit_; } |
+ |
+ // Stack overflow flags |
+ enum { |
+ kOsrRequest = 0x1, // Current stack overflow caused by OSR request. |
+ }; |
+ |
+ uword stack_overflow_flags_address() const { |
+ return reinterpret_cast<uword>(&stack_overflow_flags_); |
+ } |
+ static intptr_t stack_overflow_flags_offset() { |
+ return OFFSET_OF(Thread, stack_overflow_flags_); |
+ } |
+ |
+ int32_t IncrementAndGetStackOverflowCount() { |
+ return ++stack_overflow_count_; |
+ } |
+ |
+ // Retrieves and clears the stack overflow flags. These are set by |
+ // the generated code before the slow path runtime routine for a |
+ // stack overflow is called. |
+ uword GetAndClearStackOverflowFlags(); |
+ |
+ // Interrupt bits. |
+ enum { |
+ kVMInterrupt = 0x1, // Internal VM checks: safepoints, store buffers, etc. |
+ kMessageInterrupt = 0x2, // An interrupt to process an out of band message. |
+ |
+ kInterruptsMask = (kVMInterrupt | kMessageInterrupt), |
+ }; |
+ |
+ void ScheduleInterrupts(uword interrupt_bits); |
+ void ScheduleInterruptsLocked(uword interrupt_bits); |
+ RawError* HandleInterrupts(); |
+ uword GetAndClearInterrupts(); |
+ |
// OSThread corresponding to this thread. |
OSThread* os_thread() const { return os_thread_; } |
void set_os_thread(OSThread* os_thread) { |
@@ -533,17 +587,37 @@ LEAF_RUNTIME_ENTRY_LIST(DEFINE_OFFSET_METHOD) |
private: |
template<class T> T* AllocateReusableHandle(); |
- OSThread* os_thread_; |
- Monitor* thread_lock_; |
+ // Accessed from generated code: |
+ uword stack_limit_; |
+ uword stack_overflow_flags_; |
Isolate* isolate_; |
Heap* heap_; |
+ uword top_exit_frame_info_; |
+ StoreBufferBlock* store_buffer_block_; |
+ uword vm_tag_; |
+ // State that is cached in the TLS for fast access in generated code. |
+#define DECLARE_MEMBERS(type_name, member_name, expr, default_init_value) \ |
+ type_name member_name; |
+CACHED_CONSTANTS_LIST(DECLARE_MEMBERS) |
+#undef DECLARE_MEMBERS |
+ |
+#define DECLARE_MEMBERS(name) \ |
+ uword name##_entry_point_; |
+RUNTIME_ENTRY_LIST(DECLARE_MEMBERS) |
+#undef DECLARE_MEMBERS |
+ |
+#define DECLARE_MEMBERS(returntype, name, ...) \ |
+ uword name##_entry_point_; |
+LEAF_RUNTIME_ENTRY_LIST(DECLARE_MEMBERS) |
+#undef DECLARE_MEMBERS |
+ |
+ OSThread* os_thread_; |
+ Monitor* thread_lock_; |
Zone* zone_; |
ApiLocalScope* api_reusable_scope_; |
ApiLocalScope* api_top_scope_; |
- uword top_exit_frame_info_; |
StackResource* top_resource_; |
LongJumpScope* long_jump_base_; |
- StoreBufferBlock* store_buffer_block_; |
int32_t no_callback_scope_depth_; |
#if defined(DEBUG) |
HandleScope* top_handle_scope_; |
@@ -551,31 +625,18 @@ LEAF_RUNTIME_ENTRY_LIST(DEFINE_OFFSET_METHOD) |
int32_t no_safepoint_scope_depth_; |
#endif |
VMHandles reusable_handles_; |
+ uword saved_stack_limit_; |
+ uint16_t deferred_interrupts_mask_; |
+ uint16_t deferred_interrupts_; |
+ int32_t stack_overflow_count_; |
// Compiler state: |
CHA* cha_; |
intptr_t deopt_id_; // Compilation specific counter. |
- uword vm_tag_; |
RawGrowableObjectArray* pending_functions_; |
RawError* sticky_error_; |
- // State that is cached in the TLS for fast access in generated code. |
-#define DECLARE_MEMBERS(type_name, member_name, expr, default_init_value) \ |
- type_name member_name; |
-CACHED_CONSTANTS_LIST(DECLARE_MEMBERS) |
-#undef DECLARE_MEMBERS |
- |
-#define DECLARE_MEMBERS(name) \ |
- uword name##_entry_point_; |
-RUNTIME_ENTRY_LIST(DECLARE_MEMBERS) |
-#undef DECLARE_MEMBERS |
- |
-#define DECLARE_MEMBERS(returntype, name, ...) \ |
- uword name##_entry_point_; |
-LEAF_RUNTIME_ENTRY_LIST(DECLARE_MEMBERS) |
-#undef DECLARE_MEMBERS |
- |
// Reusable handles support. |
#define REUSABLE_HANDLE_FIELDS(object) \ |
object* object##_handle_; |
@@ -622,13 +683,19 @@ LEAF_RUNTIME_ENTRY_LIST(DECLARE_MEMBERS) |
OSThread::SetCurrentTLS(reinterpret_cast<uword>(current)); |
} |
+ void DeferOOBMessageInterrupts(); |
+ void RestoreOOBMessageInterrupts(); |
+ |
#define REUSABLE_FRIEND_DECLARATION(name) \ |
friend class Reusable##name##HandleScope; |
REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) |
#undef REUSABLE_FRIEND_DECLARATION |
friend class ApiZone; |
+ friend class InterruptChecker; |
friend class Isolate; |
+ friend class IsolateTestHelper; |
+ friend class NoOOBMessageScope; |
friend class Simulator; |
friend class StackZone; |
friend class ThreadRegistry; |