| 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 RUNTIME_VM_ISOLATE_H_ | 5 #ifndef RUNTIME_VM_ISOLATE_H_ |
| 6 #define RUNTIME_VM_ISOLATE_H_ | 6 #define RUNTIME_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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 294 |
| 295 bool MakeRunnable(); | 295 bool MakeRunnable(); |
| 296 void Run(); | 296 void Run(); |
| 297 | 297 |
| 298 MessageHandler* message_handler() const { return message_handler_; } | 298 MessageHandler* message_handler() const { return message_handler_; } |
| 299 void set_message_handler(MessageHandler* value) { message_handler_ = value; } | 299 void set_message_handler(MessageHandler* value) { message_handler_ = value; } |
| 300 | 300 |
| 301 bool is_runnable() const { return is_runnable_; } | 301 bool is_runnable() const { return is_runnable_; } |
| 302 void set_is_runnable(bool value) { | 302 void set_is_runnable(bool value) { |
| 303 is_runnable_ = value; | 303 is_runnable_ = value; |
| 304 #if !defined(PRODUCT) |
| 304 if (is_runnable_) { | 305 if (is_runnable_) { |
| 305 set_last_resume_timestamp(); | 306 set_last_resume_timestamp(); |
| 306 } | 307 } |
| 308 #endif |
| 307 } | 309 } |
| 308 | 310 |
| 309 IsolateSpawnState* spawn_state() const { return spawn_state_; } | 311 IsolateSpawnState* spawn_state() const { return spawn_state_; } |
| 310 void set_spawn_state(IsolateSpawnState* value) { spawn_state_ = value; } | 312 void set_spawn_state(IsolateSpawnState* value) { spawn_state_ = value; } |
| 311 | 313 |
| 312 Mutex* mutex() const { return mutex_; } | 314 Mutex* mutex() const { return mutex_; } |
| 313 Mutex* symbols_mutex() const { return symbols_mutex_; } | 315 Mutex* symbols_mutex() const { return symbols_mutex_; } |
| 314 Mutex* type_canonicalization_mutex() const { | 316 Mutex* type_canonicalization_mutex() const { |
| 315 return type_canonicalization_mutex_; | 317 return type_canonicalization_mutex_; |
| 316 } | 318 } |
| 317 Mutex* constant_canonicalization_mutex() const { | 319 Mutex* constant_canonicalization_mutex() const { |
| 318 return constant_canonicalization_mutex_; | 320 return constant_canonicalization_mutex_; |
| 319 } | 321 } |
| 320 Mutex* megamorphic_lookup_mutex() const { return megamorphic_lookup_mutex_; } | 322 Mutex* megamorphic_lookup_mutex() const { return megamorphic_lookup_mutex_; } |
| 321 | 323 |
| 322 #if !defined(PRODUCT) | 324 #if !defined(PRODUCT) |
| 323 Debugger* debugger() const { | 325 Debugger* debugger() const { |
| 324 ASSERT(debugger_ != NULL); | 326 ASSERT(debugger_ != NULL); |
| 325 return debugger_; | 327 return debugger_; |
| 326 } | 328 } |
| 327 #endif | 329 #endif |
| 328 | 330 |
| 329 void set_single_step(bool value) { single_step_ = value; } | 331 void set_single_step(bool value) { single_step_ = value; } |
| 330 bool single_step() const { return single_step_; } | 332 bool single_step() const { return single_step_; } |
| 331 static intptr_t single_step_offset() { | 333 static intptr_t single_step_offset() { |
| 332 return OFFSET_OF(Isolate, single_step_); | 334 return OFFSET_OF(Isolate, single_step_); |
| 333 } | 335 } |
| 334 | 336 |
| 337 #if !defined(PRODUCT) |
| 335 // Lets the embedder know that a service message resulted in a resume request. | 338 // Lets the embedder know that a service message resulted in a resume request. |
| 336 void SetResumeRequest() { | 339 void SetResumeRequest() { |
| 337 resume_request_ = true; | 340 resume_request_ = true; |
| 338 set_last_resume_timestamp(); | 341 set_last_resume_timestamp(); |
| 339 } | 342 } |
| 340 | 343 |
| 341 void set_last_resume_timestamp() { | 344 void set_last_resume_timestamp() { |
| 342 last_resume_timestamp_ = OS::GetCurrentTimeMillis(); | 345 last_resume_timestamp_ = OS::GetCurrentTimeMillis(); |
| 343 } | 346 } |
| 344 | 347 |
| 345 int64_t last_resume_timestamp() const { return last_resume_timestamp_; } | 348 int64_t last_resume_timestamp() const { return last_resume_timestamp_; } |
| 346 | 349 |
| 347 // Returns whether the vm service has requested that the debugger | 350 // Returns whether the vm service has requested that the debugger |
| 348 // resume execution. | 351 // resume execution. |
| 349 bool GetAndClearResumeRequest() { | 352 bool GetAndClearResumeRequest() { |
| 350 bool resume_request = resume_request_; | 353 bool resume_request = resume_request_; |
| 351 resume_request_ = false; | 354 resume_request_ = false; |
| 352 return resume_request; | 355 return resume_request; |
| 353 } | 356 } |
| 357 #endif |
| 354 | 358 |
| 355 // Verify that the sender has the capability to pause or terminate the | 359 // Verify that the sender has the capability to pause or terminate the |
| 356 // isolate. | 360 // isolate. |
| 357 bool VerifyPauseCapability(const Object& capability) const; | 361 bool VerifyPauseCapability(const Object& capability) const; |
| 358 bool VerifyTerminateCapability(const Object& capability) const; | 362 bool VerifyTerminateCapability(const Object& capability) const; |
| 359 | 363 |
| 360 // Returns true if the capability was added or removed from this isolate's | 364 // Returns true if the capability was added or removed from this isolate's |
| 361 // list of pause events. | 365 // list of pause events. |
| 362 bool AddResumeCapability(const Capability& capability); | 366 bool AddResumeCapability(const Capability& capability); |
| 363 bool RemoveResumeCapability(const Capability& capability); | 367 bool RemoveResumeCapability(const Capability& capability); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 const Array& parameter_values, | 628 const Array& parameter_values, |
| 625 const Instance& reply_port, | 629 const Instance& reply_port, |
| 626 const Instance& id); | 630 const Instance& id); |
| 627 void RegisterServiceExtensionHandler(const String& name, | 631 void RegisterServiceExtensionHandler(const String& name, |
| 628 const Instance& closure); | 632 const Instance& closure); |
| 629 RawInstance* LookupServiceExtensionHandler(const String& name); | 633 RawInstance* LookupServiceExtensionHandler(const String& name); |
| 630 #endif | 634 #endif |
| 631 | 635 |
| 632 static void VisitIsolates(IsolateVisitor* visitor); | 636 static void VisitIsolates(IsolateVisitor* visitor); |
| 633 | 637 |
| 638 #if !defined(PRODUCT) |
| 634 // Handle service messages until we are told to resume execution. | 639 // Handle service messages until we are told to resume execution. |
| 635 void PauseEventHandler(); | 640 void PauseEventHandler(); |
| 641 #endif |
| 636 | 642 |
| 637 void AddClosureFunction(const Function& function) const; | 643 void AddClosureFunction(const Function& function) const; |
| 638 RawFunction* LookupClosureFunction(const Function& parent, | 644 RawFunction* LookupClosureFunction(const Function& parent, |
| 639 TokenPosition token_pos) const; | 645 TokenPosition token_pos) const; |
| 640 intptr_t FindClosureIndex(const Function& needle) const; | 646 intptr_t FindClosureIndex(const Function& needle) const; |
| 641 RawFunction* ClosureFunctionFromIndex(intptr_t idx) const; | 647 RawFunction* ClosureFunctionFromIndex(intptr_t idx) const; |
| 642 | 648 |
| 643 bool is_service_isolate() const { return is_service_isolate_; } | 649 bool is_service_isolate() const { return is_service_isolate_; } |
| 644 | 650 |
| 645 // Isolate-specific flag handling. | 651 // Isolate-specific flag handling. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 Dart_Port main_port_; | 765 Dart_Port main_port_; |
| 760 Dart_Port origin_id_; // Isolates created by spawnFunc have some origin id. | 766 Dart_Port origin_id_; // Isolates created by spawnFunc have some origin id. |
| 761 uint64_t pause_capability_; | 767 uint64_t pause_capability_; |
| 762 uint64_t terminate_capability_; | 768 uint64_t terminate_capability_; |
| 763 bool errors_fatal_; | 769 bool errors_fatal_; |
| 764 void* init_callback_data_; | 770 void* init_callback_data_; |
| 765 Dart_EnvironmentCallback environment_callback_; | 771 Dart_EnvironmentCallback environment_callback_; |
| 766 Dart_LibraryTagHandler library_tag_handler_; | 772 Dart_LibraryTagHandler library_tag_handler_; |
| 767 ApiState* api_state_; | 773 ApiState* api_state_; |
| 768 NOT_IN_PRODUCT(Debugger* debugger_); | 774 NOT_IN_PRODUCT(Debugger* debugger_); |
| 769 bool resume_request_; | 775 NOT_IN_PRODUCT(bool resume_request_); |
| 770 int64_t last_resume_timestamp_; | 776 NOT_IN_PRODUCT(int64_t last_resume_timestamp_); |
| 771 Random random_; | 777 Random random_; |
| 772 Simulator* simulator_; | 778 Simulator* simulator_; |
| 773 Mutex* mutex_; // Protects compiler stats. | 779 Mutex* mutex_; // Protects compiler stats. |
| 774 Mutex* symbols_mutex_; // Protects concurrent access to the symbol table. | 780 Mutex* symbols_mutex_; // Protects concurrent access to the symbol table. |
| 775 Mutex* type_canonicalization_mutex_; // Protects type canonicalization. | 781 Mutex* type_canonicalization_mutex_; // Protects type canonicalization. |
| 776 Mutex* constant_canonicalization_mutex_; // Protects const canonicalization. | 782 Mutex* constant_canonicalization_mutex_; // Protects const canonicalization. |
| 777 Mutex* megamorphic_lookup_mutex_; // Protects megamorphic table lookup. | 783 Mutex* megamorphic_lookup_mutex_; // Protects megamorphic table lookup. |
| 778 MessageHandler* message_handler_; | 784 MessageHandler* message_handler_; |
| 779 IsolateSpawnState* spawn_state_; | 785 IsolateSpawnState* spawn_state_; |
| 780 bool is_runnable_; | 786 bool is_runnable_; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 // Should we pause in the debug message loop after this request? | 880 // Should we pause in the debug message loop after this request? |
| 875 bool should_pause_post_service_request_; | 881 bool should_pause_post_service_request_; |
| 876 | 882 |
| 877 HandlerInfoCache handler_info_cache_; | 883 HandlerInfoCache handler_info_cache_; |
| 878 CatchEntryStateCache catch_entry_state_cache_; | 884 CatchEntryStateCache catch_entry_state_cache_; |
| 879 | 885 |
| 880 static Dart_IsolateCreateCallback create_callback_; | 886 static Dart_IsolateCreateCallback create_callback_; |
| 881 static Dart_IsolateShutdownCallback shutdown_callback_; | 887 static Dart_IsolateShutdownCallback shutdown_callback_; |
| 882 static Dart_IsolateCleanupCallback cleanup_callback_; | 888 static Dart_IsolateCleanupCallback cleanup_callback_; |
| 883 | 889 |
| 890 #if !defined(PRODUCT) |
| 884 static void WakePauseEventHandler(Dart_Isolate isolate); | 891 static void WakePauseEventHandler(Dart_Isolate isolate); |
| 892 #endif |
| 885 | 893 |
| 886 // Manage list of existing isolates. | 894 // Manage list of existing isolates. |
| 887 static bool AddIsolateToList(Isolate* isolate); | 895 static bool AddIsolateToList(Isolate* isolate); |
| 888 static void RemoveIsolateFromList(Isolate* isolate); | 896 static void RemoveIsolateFromList(Isolate* isolate); |
| 889 | 897 |
| 890 // This monitor protects isolates_list_head_, and creation_enabled_. | 898 // This monitor protects isolates_list_head_, and creation_enabled_. |
| 891 static Monitor* isolates_list_monitor_; | 899 static Monitor* isolates_list_monitor_; |
| 892 static Isolate* isolates_list_head_; | 900 static Isolate* isolates_list_head_; |
| 893 static bool creation_enabled_; | 901 static bool creation_enabled_; |
| 894 | 902 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 intptr_t* spawn_count_; | 1039 intptr_t* spawn_count_; |
| 1032 | 1040 |
| 1033 Dart_IsolateFlags isolate_flags_; | 1041 Dart_IsolateFlags isolate_flags_; |
| 1034 bool paused_; | 1042 bool paused_; |
| 1035 bool errors_are_fatal_; | 1043 bool errors_are_fatal_; |
| 1036 }; | 1044 }; |
| 1037 | 1045 |
| 1038 } // namespace dart | 1046 } // namespace dart |
| 1039 | 1047 |
| 1040 #endif // RUNTIME_VM_ISOLATE_H_ | 1048 #endif // RUNTIME_VM_ISOLATE_H_ |
| OLD | NEW |