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/atomic.h" | 10 #include "vm/atomic.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 uword stack_limit_address() const { | 247 uword stack_limit_address() const { |
248 return reinterpret_cast<uword>(&stack_limit_); | 248 return reinterpret_cast<uword>(&stack_limit_); |
249 } | 249 } |
250 static intptr_t stack_limit_offset() { | 250 static intptr_t stack_limit_offset() { |
251 return OFFSET_OF(Isolate, stack_limit_); | 251 return OFFSET_OF(Isolate, stack_limit_); |
252 } | 252 } |
253 | 253 |
254 // The true stack limit for this isolate. | 254 // The true stack limit for this isolate. |
255 uword saved_stack_limit() const { return saved_stack_limit_; } | 255 uword saved_stack_limit() const { return saved_stack_limit_; } |
256 | 256 |
257 uword stack_base() const { return stack_base_; } | |
258 | |
259 // Stack overflow flags | 257 // Stack overflow flags |
260 enum { | 258 enum { |
261 kOsrRequest = 0x1, // Current stack overflow caused by OSR request. | 259 kOsrRequest = 0x1, // Current stack overflow caused by OSR request. |
262 }; | 260 }; |
263 | 261 |
264 uword stack_overflow_flags_address() const { | 262 uword stack_overflow_flags_address() const { |
265 return reinterpret_cast<uword>(&stack_overflow_flags_); | 263 return reinterpret_cast<uword>(&stack_overflow_flags_); |
266 } | 264 } |
267 | 265 |
268 int32_t IncrementAndGetStackOverflowCount() { | 266 int32_t IncrementAndGetStackOverflowCount() { |
269 return ++stack_overflow_count_; | 267 return ++stack_overflow_count_; |
270 } | 268 } |
271 | 269 |
272 // Retrieves and clears the stack overflow flags. These are set by | 270 // Retrieves and clears the stack overflow flags. These are set by |
273 // the generated code before the slow path runtime routine for a | 271 // the generated code before the slow path runtime routine for a |
274 // stack overflow is called. | 272 // stack overflow is called. |
275 uword GetAndClearStackOverflowFlags(); | 273 uword GetAndClearStackOverflowFlags(); |
276 | 274 |
277 // Retrieve the stack address bounds for profiler. | |
278 bool GetProfilerStackBounds(uword* lower, uword* upper) const; | |
279 | |
280 static uword GetSpecifiedStackSize(); | |
281 | |
282 static const intptr_t kStackSizeBuffer = (4 * KB * kWordSize); | |
283 | |
284 // Interrupt bits. | 275 // Interrupt bits. |
285 enum { | 276 enum { |
286 kVMInterrupt = 0x1, // Internal VM checks: safepoints, store buffers, etc. | 277 kVMInterrupt = 0x1, // Internal VM checks: safepoints, store buffers, etc. |
287 kMessageInterrupt = 0x2, // An interrupt to process an out of band message. | 278 kMessageInterrupt = 0x2, // An interrupt to process an out of band message. |
288 | 279 |
289 kInterruptsMask = (kVMInterrupt | kMessageInterrupt), | 280 kInterruptsMask = (kVMInterrupt | kMessageInterrupt), |
290 }; | 281 }; |
291 | 282 |
292 void ScheduleInterrupts(uword interrupt_bits); | 283 void ScheduleInterrupts(uword interrupt_bits); |
293 RawError* HandleInterrupts(); | 284 RawError* HandleInterrupts(); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 #endif // DEBUG | 720 #endif // DEBUG |
730 | 721 |
731 // DEPRECATED: Use Thread's methods instead. During migration, these default | 722 // DEPRECATED: Use Thread's methods instead. During migration, these default |
732 // to using the mutator thread (which must also be the current thread). | 723 // to using the mutator thread (which must also be the current thread). |
733 Zone* current_zone() const { | 724 Zone* current_zone() const { |
734 ASSERT(Thread::Current() == mutator_thread_); | 725 ASSERT(Thread::Current() == mutator_thread_); |
735 return mutator_thread_->zone(); | 726 return mutator_thread_->zone(); |
736 } | 727 } |
737 | 728 |
738 // Accessed from generated code: | 729 // Accessed from generated code: |
| 730 // TODO(asiva): Need to consider moving the stack_limit_ from isolate to |
| 731 // being thread specific. |
739 uword stack_limit_; | 732 uword stack_limit_; |
740 StoreBuffer* store_buffer_; | 733 StoreBuffer* store_buffer_; |
741 Heap* heap_; | 734 Heap* heap_; |
742 uword user_tag_; | 735 uword user_tag_; |
743 RawUserTag* current_tag_; | 736 RawUserTag* current_tag_; |
744 RawUserTag* default_tag_; | 737 RawUserTag* default_tag_; |
745 RawCode* ic_miss_code_; | 738 RawCode* ic_miss_code_; |
746 ClassTable class_table_; | 739 ClassTable class_table_; |
747 bool single_step_; | 740 bool single_step_; |
748 | 741 |
(...skipping 15 matching lines...) Expand all Loading... |
764 ApiState* api_state_; | 757 ApiState* api_state_; |
765 Debugger* debugger_; | 758 Debugger* debugger_; |
766 bool resume_request_; | 759 bool resume_request_; |
767 int64_t last_resume_timestamp_; | 760 int64_t last_resume_timestamp_; |
768 bool has_compiled_code_; // Can check that no compilation occured. | 761 bool has_compiled_code_; // Can check that no compilation occured. |
769 Flags flags_; | 762 Flags flags_; |
770 Random random_; | 763 Random random_; |
771 Simulator* simulator_; | 764 Simulator* simulator_; |
772 Mutex* mutex_; // protects stack_limit_, saved_stack_limit_, compiler stats. | 765 Mutex* mutex_; // protects stack_limit_, saved_stack_limit_, compiler stats. |
773 uword saved_stack_limit_; | 766 uword saved_stack_limit_; |
774 uword stack_base_; | |
775 uword stack_overflow_flags_; | 767 uword stack_overflow_flags_; |
776 int32_t stack_overflow_count_; | 768 int32_t stack_overflow_count_; |
777 MessageHandler* message_handler_; | 769 MessageHandler* message_handler_; |
778 IsolateSpawnState* spawn_state_; | 770 IsolateSpawnState* spawn_state_; |
779 bool is_runnable_; | 771 bool is_runnable_; |
780 Dart_GcPrologueCallback gc_prologue_callback_; | 772 Dart_GcPrologueCallback gc_prologue_callback_; |
781 Dart_GcEpilogueCallback gc_epilogue_callback_; | 773 Dart_GcEpilogueCallback gc_epilogue_callback_; |
782 intptr_t defer_finalization_count_; | 774 intptr_t defer_finalization_count_; |
783 DeoptContext* deopt_context_; | 775 DeoptContext* deopt_context_; |
784 | 776 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) { | 893 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) { |
902 // TODO(koda): Audit users; passing NULL goes against naming of this class. | 894 // TODO(koda): Audit users; passing NULL goes against naming of this class. |
903 if (new_isolate_ == NULL) { | 895 if (new_isolate_ == NULL) { |
904 ASSERT(Isolate::Current() == NULL); | 896 ASSERT(Isolate::Current() == NULL); |
905 // Do nothing. | 897 // Do nothing. |
906 return; | 898 return; |
907 } | 899 } |
908 if (saved_isolate_ != new_isolate_) { | 900 if (saved_isolate_ != new_isolate_) { |
909 ASSERT(Isolate::Current() == NULL); | 901 ASSERT(Isolate::Current() == NULL); |
910 // Ensure this is not a nested 'isolate enter' with prior state. | 902 // Ensure this is not a nested 'isolate enter' with prior state. |
911 ASSERT(new_isolate_->stack_base() == 0); | 903 ASSERT(new_isolate_->saved_stack_limit() == 0); |
912 Thread::EnterIsolate(new_isolate_); | 904 Thread::EnterIsolate(new_isolate_); |
913 } | 905 } |
914 } | 906 } |
915 | 907 |
916 ~StartIsolateScope() { | 908 ~StartIsolateScope() { |
917 if (new_isolate_ == NULL) { | 909 if (new_isolate_ == NULL) { |
918 ASSERT(Isolate::Current() == NULL); | 910 ASSERT(Isolate::Current() == NULL); |
919 // Do nothing. | 911 // Do nothing. |
920 return; | 912 return; |
921 } | 913 } |
922 if (saved_isolate_ != new_isolate_) { | 914 if (saved_isolate_ != new_isolate_) { |
923 ASSERT(saved_isolate_ == NULL); | 915 ASSERT(saved_isolate_ == NULL); |
924 // ASSERT that we have bottomed out of all Dart invocations. | 916 // ASSERT that we have bottomed out of all Dart invocations. |
925 ASSERT(new_isolate_->stack_base() == 0); | 917 ASSERT(new_isolate_->saved_stack_limit() == 0); |
926 Thread::ExitIsolate(); | 918 Thread::ExitIsolate(); |
927 } | 919 } |
928 } | 920 } |
929 | 921 |
930 private: | 922 private: |
931 Isolate* new_isolate_; | 923 Isolate* new_isolate_; |
932 Isolate* saved_isolate_; | 924 Isolate* saved_isolate_; |
933 | 925 |
934 DISALLOW_COPY_AND_ASSIGN(StartIsolateScope); | 926 DISALLOW_COPY_AND_ASSIGN(StartIsolateScope); |
935 }; | 927 }; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 uint8_t* serialized_message_; | 985 uint8_t* serialized_message_; |
994 intptr_t serialized_message_len_; | 986 intptr_t serialized_message_len_; |
995 Isolate::Flags isolate_flags_; | 987 Isolate::Flags isolate_flags_; |
996 bool paused_; | 988 bool paused_; |
997 bool errors_are_fatal_; | 989 bool errors_are_fatal_; |
998 }; | 990 }; |
999 | 991 |
1000 } // namespace dart | 992 } // namespace dart |
1001 | 993 |
1002 #endif // VM_ISOLATE_H_ | 994 #endif // VM_ISOLATE_H_ |
OLD | NEW |