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

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

Issue 2554983002: Created methods to surface zone memory information for each isolate and thread in JSON. (Closed)
Patch Set: Created methods to surface zone memory information for each isolate and thread in JSON. Created 4 years 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/service.h" 5 #include "vm/service.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/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 3740 matching lines...) Expand 10 before | Expand all | Expand 10 after
3751 jsobj.AddProperty("minor", 3751 jsobj.AddProperty("minor",
3752 static_cast<intptr_t>(SERVICE_PROTOCOL_MINOR_VERSION)); 3752 static_cast<intptr_t>(SERVICE_PROTOCOL_MINOR_VERSION));
3753 jsobj.AddProperty("_privateMajor", static_cast<intptr_t>(0)); 3753 jsobj.AddProperty("_privateMajor", static_cast<intptr_t>(0));
3754 jsobj.AddProperty("_privateMinor", static_cast<intptr_t>(0)); 3754 jsobj.AddProperty("_privateMinor", static_cast<intptr_t>(0));
3755 return true; 3755 return true;
3756 } 3756 }
3757 3757
3758 3758
3759 class ServiceIsolateVisitor : public IsolateVisitor { 3759 class ServiceIsolateVisitor : public IsolateVisitor {
3760 public: 3760 public:
3761 explicit ServiceIsolateVisitor(JSONArray* jsarr) : jsarr_(jsarr) {} 3761 explicit ServiceIsolateVisitor(JSONArray* jsarr, bool ref = true)
zra 2016/12/08 18:54:13 Unless I'm missing something, this class only has
bkonyi 2016/12/08 20:58:32 You're right, it's only instantiated once. I've re
3762 : jsarr_(jsarr), ref_(ref) {}
3762 3763
3763 virtual ~ServiceIsolateVisitor() {} 3764 virtual ~ServiceIsolateVisitor() {}
3764 3765
3765 void VisitIsolate(Isolate* isolate) { 3766 void VisitIsolate(Isolate* isolate) {
3766 if ((isolate != Dart::vm_isolate()) && 3767 if ((isolate != Dart::vm_isolate()) &&
3767 !ServiceIsolate::IsServiceIsolateDescendant(isolate)) { 3768 !ServiceIsolate::IsServiceIsolateDescendant(isolate)) {
3768 jsarr_->AddValue(isolate); 3769 jsarr_->AddValue(isolate, ref_);
3769 } 3770 }
3770 } 3771 }
3771 3772
3772 private: 3773 private:
3773 JSONArray* jsarr_; 3774 JSONArray* jsarr_;
3775 bool ref_;
3774 }; 3776 };
3775 3777
3776 3778
3777 static const MethodParameter* get_vm_params[] = { 3779 static const MethodParameter* get_vm_params[] = {
3778 NO_ISOLATE_PARAMETER, NULL, 3780 NO_ISOLATE_PARAMETER, NULL,
3779 }; 3781 };
3780 3782
3781 3783
3782 void Service::PrintJSONForVM(JSONStream* js, bool ref) { 3784 void Service::PrintJSONForVM(JSONStream* js, bool ref) {
3783 JSONObject jsobj(js); 3785 JSONObject jsobj(js);
3784 jsobj.AddProperty("type", (ref ? "@VM" : "VM")); 3786 jsobj.AddProperty("type", (ref ? "@VM" : "VM"));
3785 jsobj.AddProperty("name", GetVMName()); 3787 jsobj.AddProperty("name", GetVMName());
3786 if (ref) { 3788 if (ref) {
3787 return; 3789 return;
3788 } 3790 }
3789 Isolate* vm_isolate = Dart::vm_isolate(); 3791 Isolate* vm_isolate = Dart::vm_isolate();
3790 jsobj.AddProperty("architectureBits", static_cast<intptr_t>(kBitsPerWord)); 3792 jsobj.AddProperty("architectureBits", static_cast<intptr_t>(kBitsPerWord));
3791 jsobj.AddProperty("targetCPU", CPU::Id()); 3793 jsobj.AddProperty("targetCPU", CPU::Id());
3792 jsobj.AddProperty("hostCPU", HostCPUFeatures::hardware()); 3794 jsobj.AddProperty("hostCPU", HostCPUFeatures::hardware());
3793 jsobj.AddProperty("version", Version::String()); 3795 jsobj.AddProperty("version", Version::String());
3794 jsobj.AddProperty("_profilerMode", FLAG_profile_vm ? "VM" : "Dart"); 3796 jsobj.AddProperty("_profilerMode", FLAG_profile_vm ? "VM" : "Dart");
3795 jsobj.AddProperty64("pid", OS::ProcessId()); 3797 jsobj.AddProperty64("pid", OS::ProcessId());
3796 jsobj.AddProperty64("_maxRSS", OS::MaxRSS()); 3798 jsobj.AddProperty64("_maxRSS", OS::MaxRSS());
3797 int64_t start_time_millis = 3799 int64_t start_time_millis =
3798 (vm_isolate->start_time() / kMicrosecondsPerMillisecond); 3800 (vm_isolate->start_time() / kMicrosecondsPerMillisecond);
3799 jsobj.AddPropertyTimeMillis("startTime", start_time_millis); 3801 jsobj.AddPropertyTimeMillis("startTime", start_time_millis);
3800 // Construct the isolate list. 3802 // Construct the isolate list.
3801 { 3803 {
3802 JSONArray jsarr(&jsobj, "isolates"); 3804 JSONArray jsarr(&jsobj, "isolates");
3803 ServiceIsolateVisitor visitor(&jsarr); 3805 ServiceIsolateVisitor visitor(&jsarr, ref);
3804 Isolate::VisitIsolates(&visitor); 3806 Isolate::VisitIsolates(&visitor);
3805 } 3807 }
3806 } 3808 }
3807 3809
3808 3810
3809 static bool GetVM(Thread* thread, JSONStream* js) { 3811 static bool GetVM(Thread* thread, JSONStream* js) {
3810 Service::PrintJSONForVM(js, false); 3812 Service::PrintJSONForVM(js, false);
3811 return true; 3813 return true;
3812 } 3814 }
3813 3815
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
4125 if (strcmp(method_name, method.name) == 0) { 4127 if (strcmp(method_name, method.name) == 0) {
4126 return &method; 4128 return &method;
4127 } 4129 }
4128 } 4130 }
4129 return NULL; 4131 return NULL;
4130 } 4132 }
4131 4133
4132 #endif // !PRODUCT 4134 #endif // !PRODUCT
4133 4135
4134 } // namespace dart 4136 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698