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_ISOLATE_H_ | 5 #ifndef VM_ISOLATE_H_ |
6 #define VM_ISOLATE_H_ | 6 #define VM_ISOLATE_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "vm/base_isolate.h" | 10 #include "vm/base_isolate.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 public: | 116 public: |
117 ~Isolate(); | 117 ~Isolate(); |
118 | 118 |
119 static inline Isolate* Current() { | 119 static inline Isolate* Current() { |
120 return reinterpret_cast<Isolate*>(OSThread::GetThreadLocal(isolate_key)); | 120 return reinterpret_cast<Isolate*>(OSThread::GetThreadLocal(isolate_key)); |
121 } | 121 } |
122 | 122 |
123 static void SetCurrent(Isolate* isolate); | 123 static void SetCurrent(Isolate* isolate); |
124 | 124 |
125 static void InitOnce(); | 125 static void InitOnce(); |
126 static Isolate* Init(const char* name_prefix); | 126 static Isolate* Init(const char* name_prefix, bool is_vm_isolate = false); |
127 void Shutdown(); | 127 void Shutdown(); |
128 | 128 |
129 Isolate* ShallowCopy(); | 129 Isolate* ShallowCopy(); |
130 | 130 |
131 // Register a newly introduced class. | 131 // Register a newly introduced class. |
132 void RegisterClass(const Class& cls); | 132 void RegisterClass(const Class& cls); |
133 void RegisterClassAt(intptr_t index, const Class& cls); | 133 void RegisterClassAt(intptr_t index, const Class& cls); |
134 void ValidateClassTable(); | 134 void ValidateClassTable(); |
135 | 135 |
136 // Visit all object pointers. | 136 // Visit all object pointers. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 environment_callback_ = value; | 241 environment_callback_ = value; |
242 } | 242 } |
243 | 243 |
244 Dart_LibraryTagHandler library_tag_handler() const { | 244 Dart_LibraryTagHandler library_tag_handler() const { |
245 return library_tag_handler_; | 245 return library_tag_handler_; |
246 } | 246 } |
247 void set_library_tag_handler(Dart_LibraryTagHandler value) { | 247 void set_library_tag_handler(Dart_LibraryTagHandler value) { |
248 library_tag_handler_ = value; | 248 library_tag_handler_ = value; |
249 } | 249 } |
250 | 250 |
| 251 void InitializeStackLimit(); |
251 void SetStackLimit(uword value); | 252 void SetStackLimit(uword value); |
252 void SetStackLimitFromStackBase(uword stack_base); | 253 void SetStackLimitFromStackBase(uword stack_base); |
253 void ClearStackLimit(); | 254 void ClearStackLimit(); |
254 | 255 |
| 256 // Returns the current C++ stack pointer. Equivalent taking the address of a |
| 257 // stack allocated local, but plays well with AddressSanitizer. |
| 258 static uword GetCurrentStackPointer(); |
| 259 |
255 uword stack_limit_address() const { | 260 uword stack_limit_address() const { |
256 return reinterpret_cast<uword>(&stack_limit_); | 261 return reinterpret_cast<uword>(&stack_limit_); |
257 } | 262 } |
258 | 263 |
259 // The current stack limit. This may be overwritten with a special | 264 // The current stack limit. This may be overwritten with a special |
260 // value to trigger interrupts. | 265 // value to trigger interrupts. |
261 uword stack_limit() const { return stack_limit_; } | 266 uword stack_limit() const { return stack_limit_; } |
262 static intptr_t stack_limit_offset() { | 267 static intptr_t stack_limit_offset() { |
263 return OFFSET_OF(Isolate, stack_limit_); | 268 return OFFSET_OF(Isolate, stack_limit_); |
264 } | 269 } |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 public: | 792 public: |
788 explicit StartIsolateScope(Isolate* new_isolate) | 793 explicit StartIsolateScope(Isolate* new_isolate) |
789 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) { | 794 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) { |
790 if (new_isolate_ == NULL) { | 795 if (new_isolate_ == NULL) { |
791 // Do nothing. | 796 // Do nothing. |
792 return; | 797 return; |
793 } | 798 } |
794 if (saved_isolate_ != new_isolate_) { | 799 if (saved_isolate_ != new_isolate_) { |
795 ASSERT(Isolate::Current() == NULL); | 800 ASSERT(Isolate::Current() == NULL); |
796 Isolate::SetCurrent(new_isolate_); | 801 Isolate::SetCurrent(new_isolate_); |
797 new_isolate_->SetStackLimitFromStackBase(reinterpret_cast<uword>(this)); | 802 new_isolate_->SetStackLimitFromStackBase( |
| 803 Isolate::GetCurrentStackPointer()); |
798 } | 804 } |
799 } | 805 } |
800 | 806 |
801 ~StartIsolateScope() { | 807 ~StartIsolateScope() { |
802 if (new_isolate_ == NULL) { | 808 if (new_isolate_ == NULL) { |
803 // Do nothing. | 809 // Do nothing. |
804 return; | 810 return; |
805 } | 811 } |
806 if (saved_isolate_ != new_isolate_) { | 812 if (saved_isolate_ != new_isolate_) { |
807 new_isolate_->ClearStackLimit(); | 813 new_isolate_->ClearStackLimit(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 uint8_t* serialized_args_; | 901 uint8_t* serialized_args_; |
896 intptr_t serialized_args_len_; | 902 intptr_t serialized_args_len_; |
897 uint8_t* serialized_message_; | 903 uint8_t* serialized_message_; |
898 intptr_t serialized_message_len_; | 904 intptr_t serialized_message_len_; |
899 bool paused_; | 905 bool paused_; |
900 }; | 906 }; |
901 | 907 |
902 } // namespace dart | 908 } // namespace dart |
903 | 909 |
904 #endif // VM_ISOLATE_H_ | 910 #endif // VM_ISOLATE_H_ |
OLD | NEW |