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

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

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

Powered by Google App Engine
This is Rietveld 408576698