Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Side by Side Diff: runtime/vm/isolate.h

Issue 506933002: Keep track of stack base whenever Dart code is invoked. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_entry.cc ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 233 }
234 234
235 Dart_LibraryTagHandler library_tag_handler() const { 235 Dart_LibraryTagHandler library_tag_handler() const {
236 return library_tag_handler_; 236 return library_tag_handler_;
237 } 237 }
238 void set_library_tag_handler(Dart_LibraryTagHandler value) { 238 void set_library_tag_handler(Dart_LibraryTagHandler value) {
239 library_tag_handler_ = value; 239 library_tag_handler_ = value;
240 } 240 }
241 241
242 void SetStackLimit(uword value); 242 void SetStackLimit(uword value);
243 void SetStackLimitFromCurrentTOS(uword isolate_stack_top); 243 void SetStackLimitFromStackBase(uword stack_base);
244 void ClearStackLimit();
244 245
245 uword stack_limit_address() const { 246 uword stack_limit_address() const {
246 return reinterpret_cast<uword>(&stack_limit_); 247 return reinterpret_cast<uword>(&stack_limit_);
247 } 248 }
248 249
249 // The current stack limit. This may be overwritten with a special 250 // The current stack limit. This may be overwritten with a special
250 // value to trigger interrupts. 251 // value to trigger interrupts.
251 uword stack_limit() const { return stack_limit_; } 252 uword stack_limit() const { return stack_limit_; }
252 static intptr_t stack_limit_offset() { 253 static intptr_t stack_limit_offset() {
253 return OFFSET_OF(Isolate, stack_limit_); 254 return OFFSET_OF(Isolate, stack_limit_);
254 } 255 }
255 256
256 // The true stack limit for this isolate. 257 // The true stack limit for this isolate.
257 uword saved_stack_limit() const { return saved_stack_limit_; } 258 uword saved_stack_limit() const { return saved_stack_limit_; }
258 259
260 uword stack_base() const { return stack_base_; }
261
259 // Stack overflow flags 262 // Stack overflow flags
260 enum { 263 enum {
261 kOsrRequest = 0x1, // Current stack overflow caused by OSR request. 264 kOsrRequest = 0x1, // Current stack overflow caused by OSR request.
262 }; 265 };
263 266
264 uword stack_overflow_flags_address() const { 267 uword stack_overflow_flags_address() const {
265 return reinterpret_cast<uword>(&stack_overflow_flags_); 268 return reinterpret_cast<uword>(&stack_overflow_flags_);
266 } 269 }
267 270
268 int32_t IncrementAndGetStackOverflowCount() { 271 int32_t IncrementAndGetStackOverflowCount() {
269 return ++stack_overflow_count_; 272 return ++stack_overflow_count_;
270 } 273 }
271 274
272 // Retrieves and clears the stack overflow flags. These are set by 275 // Retrieves and clears the stack overflow flags. These are set by
273 // the generated code before the slow path runtime routine for a 276 // the generated code before the slow path runtime routine for a
274 // stack overflow is called. 277 // stack overflow is called.
275 uword GetAndClearStackOverflowFlags(); 278 uword GetAndClearStackOverflowFlags();
276 279
277 // Retrieve the stack address bounds. 280 // Retrieve the stack address bounds for profiler.
278 bool GetStackBounds(uword* lower, uword* upper); 281 bool GetProfilerStackBounds(uword* lower, uword* upper) const;
279 282
280 static uword GetSpecifiedStackSize(); 283 static uword GetSpecifiedStackSize();
281 284
282 static const intptr_t kStackSizeBuffer = (4 * KB * kWordSize); 285 static const intptr_t kStackSizeBuffer = (4 * KB * kWordSize);
283 286
284 // Interrupt bits. 287 // Interrupt bits.
285 enum { 288 enum {
286 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate. 289 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate.
287 kMessageInterrupt = 0x2, // An interrupt to process an out of band message. 290 kMessageInterrupt = 0x2, // An interrupt to process an out of band message.
288 kStoreBufferInterrupt = 0x4, // An interrupt to process the store buffer. 291 kStoreBufferInterrupt = 0x4, // An interrupt to process the store buffer.
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 bool single_step_; 645 bool single_step_;
643 bool resume_request_; 646 bool resume_request_;
644 Random random_; 647 Random random_;
645 Simulator* simulator_; 648 Simulator* simulator_;
646 LongJumpScope* long_jump_base_; 649 LongJumpScope* long_jump_base_;
647 TimerList timer_list_; 650 TimerList timer_list_;
648 intptr_t deopt_id_; 651 intptr_t deopt_id_;
649 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. 652 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_.
650 uword stack_limit_; 653 uword stack_limit_;
651 uword saved_stack_limit_; 654 uword saved_stack_limit_;
655 uword stack_base_;
652 uword stack_overflow_flags_; 656 uword stack_overflow_flags_;
653 int32_t stack_overflow_count_; 657 int32_t stack_overflow_count_;
654 MessageHandler* message_handler_; 658 MessageHandler* message_handler_;
655 IsolateSpawnState* spawn_state_; 659 IsolateSpawnState* spawn_state_;
656 bool is_runnable_; 660 bool is_runnable_;
657 Dart_GcPrologueCallback gc_prologue_callback_; 661 Dart_GcPrologueCallback gc_prologue_callback_;
658 Dart_GcEpilogueCallback gc_epilogue_callback_; 662 Dart_GcEpilogueCallback gc_epilogue_callback_;
659 intptr_t defer_finalization_count_; 663 intptr_t defer_finalization_count_;
660 DeoptContext* deopt_context_; 664 DeoptContext* deopt_context_;
661 665
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 // When we need to execute code in an isolate, we use the 746 // When we need to execute code in an isolate, we use the
743 // StartIsolateScope. 747 // StartIsolateScope.
744 class StartIsolateScope { 748 class StartIsolateScope {
745 public: 749 public:
746 explicit StartIsolateScope(Isolate* new_isolate) 750 explicit StartIsolateScope(Isolate* new_isolate)
747 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) { 751 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) {
748 ASSERT(new_isolate_ != NULL); 752 ASSERT(new_isolate_ != NULL);
749 if (saved_isolate_ != new_isolate_) { 753 if (saved_isolate_ != new_isolate_) {
750 ASSERT(Isolate::Current() == NULL); 754 ASSERT(Isolate::Current() == NULL);
751 Isolate::SetCurrent(new_isolate_); 755 Isolate::SetCurrent(new_isolate_);
752 new_isolate_->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(this)); 756 new_isolate_->SetStackLimitFromStackBase(reinterpret_cast<uword>(this));
753 } 757 }
754 } 758 }
755 759
756 ~StartIsolateScope() { 760 ~StartIsolateScope() {
757 if (saved_isolate_ != new_isolate_) { 761 if (saved_isolate_ != new_isolate_) {
758 new_isolate_->SetStackLimit(~static_cast<uword>(0)); 762 new_isolate_->ClearStackLimit();
759 Isolate::SetCurrent(saved_isolate_); 763 Isolate::SetCurrent(saved_isolate_);
760 } 764 }
761 } 765 }
762 766
763 private: 767 private:
764 Isolate* new_isolate_; 768 Isolate* new_isolate_;
765 Isolate* saved_isolate_; 769 Isolate* saved_isolate_;
766 770
767 DISALLOW_COPY_AND_ASSIGN(StartIsolateScope); 771 DISALLOW_COPY_AND_ASSIGN(StartIsolateScope);
768 }; 772 };
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 char* exception_callback_name_; 845 char* exception_callback_name_;
842 uint8_t* serialized_args_; 846 uint8_t* serialized_args_;
843 intptr_t serialized_args_len_; 847 intptr_t serialized_args_len_;
844 uint8_t* serialized_message_; 848 uint8_t* serialized_message_;
845 intptr_t serialized_message_len_; 849 intptr_t serialized_message_len_;
846 }; 850 };
847 851
848 } // namespace dart 852 } // namespace dart
849 853
850 #endif // VM_ISOLATE_H_ 854 #endif // VM_ISOLATE_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_entry.cc ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698