Chromium Code Reviews| 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 "platform/utils.h" | 5 #include "platform/utils.h" |
| 6 | 6 |
| 7 #include "vm/allocation.h" | 7 #include "vm/allocation.h" |
| 8 #include "vm/atomic.h" | 8 #include "vm/atomic.h" |
| 9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 kCollectedCode, | 191 kCollectedCode, |
| 192 kNativeCode | 192 kNativeCode |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 CodeRegion(Kind kind, uword start, uword end) : | 195 CodeRegion(Kind kind, uword start, uword end) : |
| 196 kind_(kind), | 196 kind_(kind), |
| 197 start_(start), | 197 start_(start), |
| 198 end_(end), | 198 end_(end), |
| 199 inclusive_ticks_(0), | 199 inclusive_ticks_(0), |
| 200 exclusive_ticks_(0), | 200 exclusive_ticks_(0), |
| 201 inclusive_tick_serial_(0), | |
|
turnidge
2014/03/06 16:36:42
What is this used for?
| |
| 201 name_(NULL), | 202 name_(NULL), |
| 202 address_table_(new ZoneGrowableArray<AddressEntry>()), | 203 address_table_(new ZoneGrowableArray<AddressEntry>()), |
| 203 callers_table_(new ZoneGrowableArray<CallEntry>()), | 204 callers_table_(new ZoneGrowableArray<CallEntry>()), |
| 204 callees_table_(new ZoneGrowableArray<CallEntry>()) { | 205 callees_table_(new ZoneGrowableArray<CallEntry>()) { |
| 205 ASSERT(start_ < end_); | 206 ASSERT(start_ < end_); |
| 206 } | 207 } |
| 207 | 208 |
| 208 ~CodeRegion() { | 209 ~CodeRegion() { |
| 209 } | 210 } |
| 210 | 211 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 if (entry.pc == pc) { | 305 if (entry.pc == pc) { |
| 305 entry.tick(exclusive); | 306 entry.tick(exclusive); |
| 306 return; | 307 return; |
| 307 } | 308 } |
| 308 if (entry.pc > pc) { | 309 if (entry.pc > pc) { |
| 309 break; | 310 break; |
| 310 } | 311 } |
| 311 } | 312 } |
| 312 AddressEntry entry; | 313 AddressEntry entry; |
| 313 entry.pc = pc; | 314 entry.pc = pc; |
| 315 entry.exclusive_ticks = 0; | |
| 316 entry.inclusive_ticks = 0; | |
| 314 entry.tick(exclusive); | 317 entry.tick(exclusive); |
| 315 if (i < length) { | 318 if (i < length) { |
| 316 // Insert at i. | 319 // Insert at i. |
| 317 address_table_->InsertAt(i, entry); | 320 address_table_->InsertAt(i, entry); |
| 318 } else { | 321 } else { |
| 319 // Add to end. | 322 // Add to end. |
| 320 address_table_->Add(entry); | 323 address_table_->Add(entry); |
| 321 } | 324 } |
| 322 } | 325 } |
| 323 | 326 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 692 ZoneGrowableArray<CodeRegion*>* code_region_table_; | 695 ZoneGrowableArray<CodeRegion*>* code_region_table_; |
| 693 }; | 696 }; |
| 694 | 697 |
| 695 | 698 |
| 696 class CodeRegionTableBuilder : public SampleVisitor { | 699 class CodeRegionTableBuilder : public SampleVisitor { |
| 697 public: | 700 public: |
| 698 CodeRegionTableBuilder(Isolate* isolate, | 701 CodeRegionTableBuilder(Isolate* isolate, |
| 699 ProfilerCodeRegionTable* code_region_table) | 702 ProfilerCodeRegionTable* code_region_table) |
| 700 : SampleVisitor(isolate), code_region_table_(code_region_table) { | 703 : SampleVisitor(isolate), code_region_table_(code_region_table) { |
| 701 frames_ = 0; | 704 frames_ = 0; |
| 705 min_time_ = kMaxInt64; | |
| 706 max_time_ = 0; | |
| 702 } | 707 } |
| 703 | 708 |
| 704 void VisitSample(Sample* sample) { | 709 void VisitSample(Sample* sample) { |
| 710 int64_t timestamp = sample->timestamp(); | |
| 711 if (timestamp > max_time_) { | |
| 712 max_time_ = timestamp; | |
| 713 } | |
| 714 if (timestamp < min_time_) { | |
| 715 min_time_ = timestamp; | |
| 716 } | |
| 705 // Give the bottom frame an exclusive tick. | 717 // Give the bottom frame an exclusive tick. |
| 706 code_region_table_->AddTick(sample->At(0), true, -1); | 718 code_region_table_->AddTick(sample->At(0), true, -1); |
| 707 // Give all frames (including the bottom) an inclusive tick. | 719 // Give all frames (including the bottom) an inclusive tick. |
| 708 for (intptr_t i = 0; i < FLAG_profile_depth; i++) { | 720 for (intptr_t i = 0; i < FLAG_profile_depth; i++) { |
| 709 if (sample->At(i) == 0) { | 721 if (sample->At(i) == 0) { |
| 710 break; | 722 break; |
| 711 } | 723 } |
| 712 frames_++; | 724 frames_++; |
| 713 code_region_table_->AddTick(sample->At(i), false, visited()); | 725 code_region_table_->AddTick(sample->At(i), false, visited()); |
| 714 } | 726 } |
| 715 } | 727 } |
| 716 | 728 |
| 717 intptr_t frames() const { return frames_; } | 729 intptr_t frames() const { return frames_; } |
| 730 intptr_t TimeDeltaMicros() const { | |
| 731 return static_cast<intptr_t>(max_time_ - min_time_); | |
| 732 } | |
| 733 int64_t max_time() const { return max_time_; } | |
| 718 | 734 |
| 719 private: | 735 private: |
| 720 intptr_t frames_; | 736 intptr_t frames_; |
| 737 int64_t min_time_; | |
| 738 int64_t max_time_; | |
| 721 ProfilerCodeRegionTable* code_region_table_; | 739 ProfilerCodeRegionTable* code_region_table_; |
| 722 }; | 740 }; |
| 723 | 741 |
| 724 | 742 |
| 725 class CodeRegionTableCallersBuilder : public SampleVisitor { | 743 class CodeRegionTableCallersBuilder : public SampleVisitor { |
| 726 public: | 744 public: |
| 727 CodeRegionTableCallersBuilder(Isolate* isolate, | 745 CodeRegionTableCallersBuilder(Isolate* isolate, |
| 728 ProfilerCodeRegionTable* code_region_table) | 746 ProfilerCodeRegionTable* code_region_table) |
| 729 : SampleVisitor(isolate), code_region_table_(code_region_table) { | 747 : SampleVisitor(isolate), code_region_table_(code_region_table) { |
| 730 ASSERT(code_region_table_ != NULL); | 748 ASSERT(code_region_table_ != NULL); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 800 if (FLAG_trace_profiled_isolates) { | 818 if (FLAG_trace_profiled_isolates) { |
| 801 OS::Print("%" Pd " frames produced %" Pd " code objects.\n", | 819 OS::Print("%" Pd " frames produced %" Pd " code objects.\n", |
| 802 frames, code_region_table.Length()); | 820 frames, code_region_table.Length()); |
| 803 } | 821 } |
| 804 { | 822 { |
| 805 ScopeStopwatch sw("CodeTableStream"); | 823 ScopeStopwatch sw("CodeTableStream"); |
| 806 // Serialize to JSON. | 824 // Serialize to JSON. |
| 807 JSONObject obj(stream); | 825 JSONObject obj(stream); |
| 808 obj.AddProperty("type", "Profile"); | 826 obj.AddProperty("type", "Profile"); |
| 809 obj.AddProperty("samples", samples); | 827 obj.AddProperty("samples", samples); |
| 828 obj.AddProperty("time_delta_micros", builder.TimeDeltaMicros()); | |
| 810 JSONArray codes(&obj, "codes"); | 829 JSONArray codes(&obj, "codes"); |
| 811 for (intptr_t i = 0; i < code_region_table.Length(); i++) { | 830 for (intptr_t i = 0; i < code_region_table.Length(); i++) { |
| 812 CodeRegion* region = code_region_table.At(i); | 831 CodeRegion* region = code_region_table.At(i); |
| 813 ASSERT(region != NULL); | 832 ASSERT(region != NULL); |
| 814 region->PrintToJSONArray(isolate, &codes, full); | 833 region->PrintToJSONArray(isolate, &codes, full); |
| 815 } | 834 } |
| 816 } | 835 } |
| 817 } | 836 } |
| 818 } | 837 } |
| 819 // Enable profile interrupts. | 838 // Enable profile interrupts. |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1032 stack_lower = 0; | 1051 stack_lower = 0; |
| 1033 stack_upper = 0; | 1052 stack_upper = 0; |
| 1034 } | 1053 } |
| 1035 ProfilerSampleStackWalker stackWalker(sample, stack_lower, stack_upper, | 1054 ProfilerSampleStackWalker stackWalker(sample, stack_lower, stack_upper, |
| 1036 state.pc, state.fp, state.sp); | 1055 state.pc, state.fp, state.sp); |
| 1037 stackWalker.walk(isolate->heap()); | 1056 stackWalker.walk(isolate->heap()); |
| 1038 } | 1057 } |
| 1039 | 1058 |
| 1040 | 1059 |
| 1041 } // namespace dart | 1060 } // namespace dart |
| OLD | NEW |