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 "platform/thread.h" | 10 #include "platform/thread.h" |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 kStoreBufferInterrupt = 0x4, // An interrupt to process the store buffer. | 372 kStoreBufferInterrupt = 0x4, // An interrupt to process the store buffer. |
373 kVmStatusInterrupt = 0x8, // An interrupt to process a status request. | 373 kVmStatusInterrupt = 0x8, // An interrupt to process a status request. |
374 | 374 |
375 kInterruptsMask = | 375 kInterruptsMask = |
376 kApiInterrupt | | 376 kApiInterrupt | |
377 kMessageInterrupt | | 377 kMessageInterrupt | |
378 kStoreBufferInterrupt | | 378 kStoreBufferInterrupt | |
379 kVmStatusInterrupt, | 379 kVmStatusInterrupt, |
380 }; | 380 }; |
381 | 381 |
382 enum IsolateRunState { | |
383 kIsolateWaiting = 0, // The isolate is waiting for code to execute. | |
384 kIsolateRunning, // The isolate is executing code. | |
385 }; | |
386 | |
387 void ScheduleInterrupts(uword interrupt_bits); | 382 void ScheduleInterrupts(uword interrupt_bits); |
388 uword GetAndClearInterrupts(); | 383 uword GetAndClearInterrupts(); |
389 | 384 |
390 bool MakeRunnable(); | 385 bool MakeRunnable(); |
391 void Run(); | 386 void Run(); |
392 | 387 |
393 MessageHandler* message_handler() const { return message_handler_; } | 388 MessageHandler* message_handler() const { return message_handler_; } |
394 void set_message_handler(MessageHandler* value) { message_handler_ = value; } | 389 void set_message_handler(MessageHandler* value) { message_handler_ = value; } |
395 | 390 |
396 bool is_runnable() const { return is_runnable_; } | 391 bool is_runnable() const { return is_runnable_; } |
397 void set_is_runnable(bool value) { is_runnable_ = value; } | 392 void set_is_runnable(bool value) { is_runnable_ = value; } |
398 | 393 |
399 IsolateRunState running_state() const { return running_state_; } | |
400 void set_running_state(IsolateRunState value) { running_state_ = value; } | |
401 | |
402 uword spawn_data() const { return spawn_data_; } | 394 uword spawn_data() const { return spawn_data_; } |
403 void set_spawn_data(uword value) { spawn_data_ = value; } | 395 void set_spawn_data(uword value) { spawn_data_ = value; } |
404 | 396 |
405 static const intptr_t kNoDeoptId = -1; | 397 static const intptr_t kNoDeoptId = -1; |
406 static const intptr_t kDeoptIdStep = 2; | 398 static const intptr_t kDeoptIdStep = 2; |
407 static const intptr_t kDeoptIdBeforeOffset = 0; | 399 static const intptr_t kDeoptIdBeforeOffset = 0; |
408 static const intptr_t kDeoptIdAfterOffset = 1; | 400 static const intptr_t kDeoptIdAfterOffset = 1; |
409 intptr_t deopt_id() const { return deopt_id_; } | 401 intptr_t deopt_id() const { return deopt_id_; } |
410 void set_deopt_id(int value) { | 402 void set_deopt_id(int value) { |
411 ASSERT(value >= 0); | 403 ASSERT(value >= 0); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 Simulator* simulator_; | 658 Simulator* simulator_; |
667 LongJump* long_jump_base_; | 659 LongJump* long_jump_base_; |
668 TimerList timer_list_; | 660 TimerList timer_list_; |
669 intptr_t deopt_id_; | 661 intptr_t deopt_id_; |
670 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. | 662 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. |
671 uword stack_limit_; | 663 uword stack_limit_; |
672 uword saved_stack_limit_; | 664 uword saved_stack_limit_; |
673 MessageHandler* message_handler_; | 665 MessageHandler* message_handler_; |
674 uword spawn_data_; | 666 uword spawn_data_; |
675 bool is_runnable_; | 667 bool is_runnable_; |
676 IsolateRunState running_state_; | |
677 GcPrologueCallbacks gc_prologue_callbacks_; | 668 GcPrologueCallbacks gc_prologue_callbacks_; |
678 GcEpilogueCallbacks gc_epilogue_callbacks_; | 669 GcEpilogueCallbacks gc_epilogue_callbacks_; |
679 intptr_t defer_finalization_count_; | 670 intptr_t defer_finalization_count_; |
680 | 671 |
681 // Deoptimization support. | 672 // Deoptimization support. |
682 intptr_t* deopt_cpu_registers_copy_; | 673 intptr_t* deopt_cpu_registers_copy_; |
683 fpu_register_t* deopt_fpu_registers_copy_; | 674 fpu_register_t* deopt_fpu_registers_copy_; |
684 intptr_t* deopt_frame_copy_; | 675 intptr_t* deopt_frame_copy_; |
685 intptr_t deopt_frame_copy_size_; | 676 intptr_t deopt_frame_copy_size_; |
686 DeferredSlot* deferred_boxes_; | 677 DeferredSlot* deferred_boxes_; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 void Cleanup(); | 867 void Cleanup(); |
877 | 868 |
878 private: | 869 private: |
879 Isolate* isolate_; | 870 Isolate* isolate_; |
880 char* script_url_; | 871 char* script_url_; |
881 char* library_url_; | 872 char* library_url_; |
882 char* function_name_; | 873 char* function_name_; |
883 char* exception_callback_name_; | 874 char* exception_callback_name_; |
884 }; | 875 }; |
885 | 876 |
886 | |
887 class IsolateRunStateManager : public StackResource { | |
888 public: | |
889 explicit IsolateRunStateManager() | |
890 : StackResource(Isolate::Current()), | |
891 saved_state_(Isolate::kIsolateWaiting) { | |
892 saved_state_ = reinterpret_cast<Isolate*>(isolate())->running_state(); | |
893 } | |
894 | |
895 virtual ~IsolateRunStateManager() { | |
896 reinterpret_cast<Isolate*>(isolate())->set_running_state(saved_state_); | |
897 } | |
898 | |
899 void SetRunState(Isolate::IsolateRunState run_state) { | |
900 reinterpret_cast<Isolate*>(isolate())->set_running_state(run_state); | |
901 } | |
902 | |
903 private: | |
904 Isolate::IsolateRunState saved_state_; | |
905 | |
906 DISALLOW_COPY_AND_ASSIGN(IsolateRunStateManager); | |
907 }; | |
908 | |
909 } // namespace dart | 877 } // namespace dart |
910 | 878 |
911 #endif // VM_ISOLATE_H_ | 879 #endif // VM_ISOLATE_H_ |
OLD | NEW |