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

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

Issue 2951803004: [vm-service] Encode ticks directly as integers, since they are expect to stay in JS integer range. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « runtime/observatory/lib/src/cpu_profile/cpu_profile.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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/profiler_service.h" 5 #include "vm/profiler_service.h"
6 6
7 #include "vm/growable_array.h" 7 #include "vm/growable_array.h"
8 #include "vm/hash_map.h" 8 #include "vm/hash_map.h"
9 #include "vm/log.h" 9 #include "vm/log.h"
10 #include "vm/malloc_hooks.h" 10 #include "vm/malloc_hooks.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 void ProfileFunction::PrintToJSONObject(JSONObject* func) { 222 void ProfileFunction::PrintToJSONObject(JSONObject* func) {
223 func->AddProperty("type", "@Function"); 223 func->AddProperty("type", "@Function");
224 func->AddProperty("name", name()); 224 func->AddProperty("name", name());
225 func->AddProperty("_kind", KindToCString(kind())); 225 func->AddProperty("_kind", KindToCString(kind()));
226 } 226 }
227 227
228 228
229 void ProfileFunction::PrintToJSONArray(JSONArray* functions) { 229 void ProfileFunction::PrintToJSONArray(JSONArray* functions) {
230 JSONObject obj(functions); 230 JSONObject obj(functions);
231 obj.AddProperty("kind", KindToCString(kind())); 231 obj.AddProperty("kind", KindToCString(kind()));
232 obj.AddPropertyF("inclusiveTicks", "%" Pd "", inclusive_ticks()); 232 obj.AddProperty("inclusiveTicks", inclusive_ticks());
233 obj.AddPropertyF("exclusiveTicks", "%" Pd "", exclusive_ticks()); 233 obj.AddProperty("exclusiveTicks", exclusive_ticks());
234 if (kind() == kDartFunction) { 234 if (kind() == kDartFunction) {
235 ASSERT(!function_.IsNull()); 235 ASSERT(!function_.IsNull());
236 obj.AddProperty("function", function_); 236 obj.AddProperty("function", function_);
237 } else { 237 } else {
238 JSONObject func(&obj, "function"); 238 JSONObject func(&obj, "function");
239 PrintToJSONObject(&func); 239 PrintToJSONObject(&func);
240 } 240 }
241 { 241 {
242 JSONArray codes(&obj, "codes"); 242 JSONArray codes(&obj, "codes");
243 for (intptr_t i = 0; i < profile_codes_.length(); i++) { 243 for (intptr_t i = 0; i < profile_codes_.length(); i++) {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 return "Tag"; 500 return "Tag";
501 } 501 }
502 UNREACHABLE(); 502 UNREACHABLE();
503 return NULL; 503 return NULL;
504 } 504 }
505 505
506 506
507 void ProfileCode::PrintToJSONArray(JSONArray* codes) { 507 void ProfileCode::PrintToJSONArray(JSONArray* codes) {
508 JSONObject obj(codes); 508 JSONObject obj(codes);
509 obj.AddProperty("kind", ProfileCode::KindToCString(kind())); 509 obj.AddProperty("kind", ProfileCode::KindToCString(kind()));
510 obj.AddPropertyF("inclusiveTicks", "%" Pd "", inclusive_ticks()); 510 obj.AddProperty("inclusiveTicks", inclusive_ticks());
511 obj.AddPropertyF("exclusiveTicks", "%" Pd "", exclusive_ticks()); 511 obj.AddProperty("exclusiveTicks", exclusive_ticks());
512 if (kind() == kDartCode) { 512 if (kind() == kDartCode) {
513 ASSERT(!code_.IsNull()); 513 ASSERT(!code_.IsNull());
514 obj.AddProperty("code", code_); 514 obj.AddProperty("code", code_);
515 } else if (kind() == kCollectedCode) { 515 } else if (kind() == kCollectedCode) {
516 PrintCollectedCode(&obj); 516 PrintCollectedCode(&obj);
517 } else if (kind() == kReusedCode) { 517 } else if (kind() == kReusedCode) {
518 PrintOverwrittenCode(&obj); 518 PrintOverwrittenCode(&obj);
519 } else if (kind() == kTagCode) { 519 } else if (kind() == kTagCode) {
520 PrintTagCode(&obj); 520 PrintTagCode(&obj);
521 } else { 521 } else {
522 ASSERT(kind() == kNativeCode); 522 ASSERT(kind() == kNativeCode);
523 PrintNativeCode(&obj); 523 PrintNativeCode(&obj);
524 } 524 }
525 { 525 {
526 JSONArray ticks(&obj, "ticks"); 526 JSONArray ticks(&obj, "ticks");
527 for (intptr_t i = 0; i < address_ticks_.length(); i++) { 527 for (intptr_t i = 0; i < address_ticks_.length(); i++) {
528 const ProfileCodeAddress& entry = address_ticks_[i]; 528 const ProfileCodeAddress& entry = address_ticks_[i];
529 ticks.AddValueF("%" Px "", entry.pc()); 529 ticks.AddValueF("%" Px "", entry.pc());
530 ticks.AddValueF("%" Pd "", entry.exclusive_ticks()); 530 ticks.AddValue(entry.exclusive_ticks());
531 ticks.AddValueF("%" Pd "", entry.inclusive_ticks()); 531 ticks.AddValue(entry.inclusive_ticks());
532 } 532 }
533 } 533 }
534 } 534 }
535 535
536 536
537 class ProfileFunctionTable : public ZoneAllocated { 537 class ProfileFunctionTable : public ZoneAllocated {
538 public: 538 public:
539 ProfileFunctionTable() 539 ProfileFunctionTable()
540 : null_function_(Function::ZoneHandle()), 540 : null_function_(Function::ZoneHandle()),
541 unknown_function_(NULL), 541 unknown_function_(NULL),
(...skipping 2342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2884 // Disable thread interrupts while processing the buffer. 2884 // Disable thread interrupts while processing the buffer.
2885 DisableThreadInterruptsScope dtis(thread); 2885 DisableThreadInterruptsScope dtis(thread);
2886 2886
2887 ClearProfileVisitor clear_profile(isolate); 2887 ClearProfileVisitor clear_profile(isolate);
2888 sample_buffer->VisitSamples(&clear_profile); 2888 sample_buffer->VisitSamples(&clear_profile);
2889 } 2889 }
2890 2890
2891 #endif // !PRODUCT 2891 #endif // !PRODUCT
2892 2892
2893 } // namespace dart 2893 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/cpu_profile/cpu_profile.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698