| 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 #include "vm/isolate.h" | 5 #include "vm/isolate.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/text_buffer.h" | 10 #include "platform/text_buffer.h" |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 current_tag_(UserTag::null()), | 752 current_tag_(UserTag::null()), |
| 753 default_tag_(UserTag::null()), | 753 default_tag_(UserTag::null()), |
| 754 ic_miss_code_(Code::null()), | 754 ic_miss_code_(Code::null()), |
| 755 object_store_(NULL), | 755 object_store_(NULL), |
| 756 class_table_(), | 756 class_table_(), |
| 757 single_step_(false), | 757 single_step_(false), |
| 758 isolate_flags_(0), | 758 isolate_flags_(0), |
| 759 background_compiler_disabled_depth_(0), | 759 background_compiler_disabled_depth_(0), |
| 760 background_compiler_(NULL), | 760 background_compiler_(NULL), |
| 761 #if !defined(PRODUCT) | 761 #if !defined(PRODUCT) |
| 762 debugger_name_(NULL), | |
| 763 debugger_(NULL), | 762 debugger_(NULL), |
| 764 last_resume_timestamp_(OS::GetCurrentTimeMillis()), | 763 last_resume_timestamp_(OS::GetCurrentTimeMillis()), |
| 765 last_allocationprofile_accumulator_reset_timestamp_(0), | 764 last_allocationprofile_accumulator_reset_timestamp_(0), |
| 766 last_allocationprofile_gc_timestamp_(0), | 765 last_allocationprofile_gc_timestamp_(0), |
| 767 vm_tag_counters_(), | 766 vm_tag_counters_(), |
| 768 pending_service_extension_calls_(GrowableObjectArray::null()), | 767 pending_service_extension_calls_(GrowableObjectArray::null()), |
| 769 registered_service_extension_handlers_(GrowableObjectArray::null()), | 768 registered_service_extension_handlers_(GrowableObjectArray::null()), |
| 770 metrics_list_head_(NULL), | 769 metrics_list_head_(NULL), |
| 771 pause_loop_monitor_(NULL), | 770 pause_loop_monitor_(NULL), |
| 772 #define ISOLATE_METRIC_CONSTRUCTORS(type, variable, name, unit) \ | 771 #define ISOLATE_METRIC_CONSTRUCTORS(type, variable, name, unit) \ |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 // how the vm_tag (kEmbedderTagId) can be set, these tags need to | 822 // how the vm_tag (kEmbedderTagId) can be set, these tags need to |
| 824 // move to the OSThread structure. | 823 // move to the OSThread structure. |
| 825 set_user_tag(UserTags::kDefaultUserTag); | 824 set_user_tag(UserTags::kDefaultUserTag); |
| 826 } | 825 } |
| 827 | 826 |
| 828 #undef REUSABLE_HANDLE_SCOPE_INIT | 827 #undef REUSABLE_HANDLE_SCOPE_INIT |
| 829 #undef REUSABLE_HANDLE_INITIALIZERS | 828 #undef REUSABLE_HANDLE_INITIALIZERS |
| 830 | 829 |
| 831 Isolate::~Isolate() { | 830 Isolate::~Isolate() { |
| 832 #if !defined(PRODUCT) | 831 #if !defined(PRODUCT) |
| 833 free(debugger_name_); | |
| 834 delete debugger_; | 832 delete debugger_; |
| 835 if (FLAG_support_service) { | 833 if (FLAG_support_service) { |
| 836 delete object_id_ring_; | 834 delete object_id_ring_; |
| 837 } | 835 } |
| 838 object_id_ring_ = NULL; | 836 object_id_ring_ = NULL; |
| 839 delete pause_loop_monitor_; | 837 delete pause_loop_monitor_; |
| 840 pause_loop_monitor_ = NULL; | 838 pause_loop_monitor_ = NULL; |
| 841 #endif // !defined(PRODUCT) | 839 #endif // !defined(PRODUCT) |
| 842 | 840 |
| 843 free(name_); | 841 free(name_); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 void Isolate::ScheduleMessageInterrupts() { | 972 void Isolate::ScheduleMessageInterrupts() { |
| 975 // We take the threads lock here to ensure that the mutator thread does not | 973 // We take the threads lock here to ensure that the mutator thread does not |
| 976 // exit the isolate while we are trying to schedule interrupts on it. | 974 // exit the isolate while we are trying to schedule interrupts on it. |
| 977 MonitorLocker ml(threads_lock()); | 975 MonitorLocker ml(threads_lock()); |
| 978 Thread* mthread = mutator_thread(); | 976 Thread* mthread = mutator_thread(); |
| 979 if (mthread != NULL) { | 977 if (mthread != NULL) { |
| 980 mthread->ScheduleInterrupts(Thread::kMessageInterrupt); | 978 mthread->ScheduleInterrupts(Thread::kMessageInterrupt); |
| 981 } | 979 } |
| 982 } | 980 } |
| 983 | 981 |
| 984 #if !defined(PRODUCT) | 982 void Isolate::set_name(const char* name) { |
| 985 void Isolate::set_debugger_name(const char* name) { | 983 free(name_); |
| 986 free(debugger_name_); | 984 name_ = strdup(name); |
| 987 debugger_name_ = strdup(name); | |
| 988 } | 985 } |
| 989 #endif // !defined(PRODUCT) | |
| 990 | 986 |
| 991 int64_t Isolate::UptimeMicros() const { | 987 int64_t Isolate::UptimeMicros() const { |
| 992 return OS::GetCurrentMonotonicMicros() - start_time_micros_; | 988 return OS::GetCurrentMonotonicMicros() - start_time_micros_; |
| 993 } | 989 } |
| 994 | 990 |
| 995 bool Isolate::IsPaused() const { | 991 bool Isolate::IsPaused() const { |
| 996 #if defined(PRODUCT) | 992 #if defined(PRODUCT) |
| 997 return false; | 993 return false; |
| 998 #else | 994 #else |
| 999 return (debugger_ != NULL) && (debugger_->PauseEvent() != NULL); | 995 return (debugger_ != NULL) && (debugger_->PauseEvent() != NULL); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1015 UNREACHABLE(); | 1011 UNREACHABLE(); |
| 1016 } | 1012 } |
| 1017 } | 1013 } |
| 1018 #endif | 1014 #endif |
| 1019 return Error::null(); | 1015 return Error::null(); |
| 1020 } | 1016 } |
| 1021 | 1017 |
| 1022 void Isolate::BuildName(const char* name_prefix) { | 1018 void Isolate::BuildName(const char* name_prefix) { |
| 1023 ASSERT(name_ == NULL); | 1019 ASSERT(name_ == NULL); |
| 1024 if (name_prefix == NULL) { | 1020 if (name_prefix == NULL) { |
| 1025 name_prefix = "isolate"; | 1021 name_ = OS::SCreate(NULL, "isolate-%" Pd64 "", main_port()); |
| 1022 } else { |
| 1023 name_ = strdup(name_prefix); |
| 1026 } | 1024 } |
| 1027 NOT_IN_PRODUCT(set_debugger_name(name_prefix)); | |
| 1028 if (ServiceIsolate::NameEquals(name_prefix)) { | |
| 1029 name_ = strdup(name_prefix); | |
| 1030 return; | |
| 1031 } | |
| 1032 name_ = OS::SCreate(NULL, "%s-%" Pd64 "", name_prefix, main_port()); | |
| 1033 } | 1025 } |
| 1034 | 1026 |
| 1035 void Isolate::DoneLoading() { | 1027 void Isolate::DoneLoading() { |
| 1036 GrowableObjectArray& libs = | 1028 GrowableObjectArray& libs = |
| 1037 GrowableObjectArray::Handle(current_zone(), object_store()->libraries()); | 1029 GrowableObjectArray::Handle(current_zone(), object_store()->libraries()); |
| 1038 Library& lib = Library::Handle(current_zone()); | 1030 Library& lib = Library::Handle(current_zone()); |
| 1039 intptr_t num_libs = libs.Length(); | 1031 intptr_t num_libs = libs.Length(); |
| 1040 for (intptr_t i = 0; i < num_libs; i++) { | 1032 for (intptr_t i = 0; i < num_libs; i++) { |
| 1041 lib ^= libs.At(i); | 1033 lib ^= libs.At(i); |
| 1042 // If this library was loaded with Dart_LoadLibrary, it was marked | 1034 // If this library was loaded with Dart_LoadLibrary, it was marked |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 | 1892 |
| 1901 void Isolate::PrintJSON(JSONStream* stream, bool ref) { | 1893 void Isolate::PrintJSON(JSONStream* stream, bool ref) { |
| 1902 if (!FLAG_support_service) { | 1894 if (!FLAG_support_service) { |
| 1903 return; | 1895 return; |
| 1904 } | 1896 } |
| 1905 JSONObject jsobj(stream); | 1897 JSONObject jsobj(stream); |
| 1906 jsobj.AddProperty("type", (ref ? "@Isolate" : "Isolate")); | 1898 jsobj.AddProperty("type", (ref ? "@Isolate" : "Isolate")); |
| 1907 jsobj.AddFixedServiceId(ISOLATE_SERVICE_ID_FORMAT_STRING, | 1899 jsobj.AddFixedServiceId(ISOLATE_SERVICE_ID_FORMAT_STRING, |
| 1908 static_cast<int64_t>(main_port())); | 1900 static_cast<int64_t>(main_port())); |
| 1909 | 1901 |
| 1910 jsobj.AddProperty("name", debugger_name()); | 1902 jsobj.AddProperty("name", name()); |
| 1911 jsobj.AddPropertyF("number", "%" Pd64 "", static_cast<int64_t>(main_port())); | 1903 jsobj.AddPropertyF("number", "%" Pd64 "", static_cast<int64_t>(main_port())); |
| 1912 if (ref) { | 1904 if (ref) { |
| 1913 return; | 1905 return; |
| 1914 } | 1906 } |
| 1915 jsobj.AddPropertyF("_originNumber", "%" Pd64 "", | 1907 jsobj.AddPropertyF("_originNumber", "%" Pd64 "", |
| 1916 static_cast<int64_t>(origin_id())); | 1908 static_cast<int64_t>(origin_id())); |
| 1917 int64_t uptime_millis = UptimeMicros() / kMicrosecondsPerMillisecond; | 1909 int64_t uptime_millis = UptimeMicros() / kMicrosecondsPerMillisecond; |
| 1918 int64_t start_time = OS::GetCurrentTimeMillis() - uptime_millis; | 1910 int64_t start_time = OS::GetCurrentTimeMillis() - uptime_millis; |
| 1919 jsobj.AddPropertyTimeMillis("startTime", start_time); | 1911 jsobj.AddPropertyTimeMillis("startTime", start_time); |
| 1920 { | 1912 { |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2839 void IsolateSpawnState::DecrementSpawnCount() { | 2831 void IsolateSpawnState::DecrementSpawnCount() { |
| 2840 ASSERT(spawn_count_monitor_ != NULL); | 2832 ASSERT(spawn_count_monitor_ != NULL); |
| 2841 ASSERT(spawn_count_ != NULL); | 2833 ASSERT(spawn_count_ != NULL); |
| 2842 MonitorLocker ml(spawn_count_monitor_); | 2834 MonitorLocker ml(spawn_count_monitor_); |
| 2843 ASSERT(*spawn_count_ > 0); | 2835 ASSERT(*spawn_count_ > 0); |
| 2844 *spawn_count_ = *spawn_count_ - 1; | 2836 *spawn_count_ = *spawn_count_ - 1; |
| 2845 ml.Notify(); | 2837 ml.Notify(); |
| 2846 } | 2838 } |
| 2847 | 2839 |
| 2848 } // namespace dart | 2840 } // namespace dart |
| OLD | NEW |