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

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

Issue 1779333004: Add profile data to getSourceReport (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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) 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/log.h" 8 #include "vm/log.h"
9 #include "vm/native_symbol.h" 9 #include "vm/native_symbol.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return; 150 return;
151 } 151 }
152 inclusive_serial_ = inclusive_serial; 152 inclusive_serial_ = inclusive_serial;
153 inclusive_ticks_++; 153 inclusive_ticks_++;
154 TickSourcePosition(token_position, false); 154 TickSourcePosition(token_position, false);
155 } 155 }
156 156
157 157
158 void ProfileFunction::TickSourcePosition(TokenPosition token_position, 158 void ProfileFunction::TickSourcePosition(TokenPosition token_position,
159 bool exclusive) { 159 bool exclusive) {
160 for (intptr_t i = 0; i < source_position_ticks_.length(); i++) { 160 intptr_t i = 0;
161 for (; i < source_position_ticks_.length(); i++) {
161 ProfileFunctionSourcePosition& position = source_position_ticks_[i]; 162 ProfileFunctionSourcePosition& position = source_position_ticks_[i];
162 if (position.token_pos() == token_position) { 163 if (position.token_pos().value() == token_position.value()) {
164 if (FLAG_trace_profiler) {
165 OS::Print("Ticking source position %s %s\n",
166 exclusive ? "exclusive" : "inclusive",
167 token_position.ToCString());
168 }
163 // Found existing position, tick it. 169 // Found existing position, tick it.
164 position.Tick(exclusive); 170 position.Tick(exclusive);
165 return; 171 return;
166 } 172 }
173 if (position.token_pos().value() > token_position.value()) {
174 break;
175 }
167 } 176 }
168 // Add new one. 177
178 // Add new one, sorted by token position value.
169 ProfileFunctionSourcePosition pfsp(token_position); 179 ProfileFunctionSourcePosition pfsp(token_position);
180 if (FLAG_trace_profiler) {
181 OS::Print("Ticking source position %s %s\n",
182 exclusive ? "exclusive" : "inclusive",
183 token_position.ToCString());
184 }
170 pfsp.Tick(exclusive); 185 pfsp.Tick(exclusive);
171 source_position_ticks_.Add(pfsp); 186
187 if (i < source_position_ticks_.length()) {
188 source_position_ticks_.InsertAt(i, pfsp);
189 } else {
190 source_position_ticks_.Add(pfsp);
191 }
172 } 192 }
173 193
174 194
175 const char* ProfileFunction::KindToCString(Kind kind) { 195 const char* ProfileFunction::KindToCString(Kind kind) {
176 switch (kind) { 196 switch (kind) {
177 case kDartFunction: 197 case kDartFunction:
178 return "Dart"; 198 return "Dart";
179 case kNativeFunction: 199 case kNativeFunction:
180 return "Native"; 200 return "Native";
181 case kTagFunction: 201 case kTagFunction:
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 return IsExecutingFrame(sample, frame_index) || vm_tags_emitted(); 1600 return IsExecutingFrame(sample, frame_index) || vm_tags_emitted();
1581 } 1601 }
1582 1602
1583 ProfileFunctionTrieNode* ProcessFunction(ProfileFunctionTrieNode* current, 1603 ProfileFunctionTrieNode* ProcessFunction(ProfileFunctionTrieNode* current,
1584 intptr_t sample_index, 1604 intptr_t sample_index,
1585 ProcessedSample* sample, 1605 ProcessedSample* sample,
1586 intptr_t frame_index, 1606 intptr_t frame_index,
1587 ProfileFunction* function, 1607 ProfileFunction* function,
1588 TokenPosition token_position, 1608 TokenPosition token_position,
1589 intptr_t code_index) { 1609 intptr_t code_index) {
1590 if (FLAG_trace_profiler) {
1591 THR_Print("S[%" Pd "]F[%" Pd "] %s %s\n",
1592 sample_index,
1593 frame_index,
1594 function->Name(), token_position.ToCString());
1595 }
1596 if (tick_functions_) { 1610 if (tick_functions_) {
1611 if (FLAG_trace_profiler) {
1612 THR_Print("S[%" Pd "]F[%" Pd "] %s %s 0x%" Px "\n",
1613 sample_index,
1614 frame_index,
1615 function->Name(),
1616 token_position.ToCString(),
1617 sample->At(frame_index));
1618 }
1597 function->Tick(IsExecutingFrame(sample, frame_index), 1619 function->Tick(IsExecutingFrame(sample, frame_index),
1598 sample_index, 1620 sample_index,
1599 token_position); 1621 token_position);
1600 } 1622 }
1601 function->AddProfileCode(code_index); 1623 function->AddProfileCode(code_index);
1602 current = current->GetChild(function->table_index()); 1624 current = current->GetChild(function->table_index());
1603 if (ShouldTickNode(sample, frame_index)) { 1625 if (ShouldTickNode(sample, frame_index)) {
1604 current->Tick(); 1626 current->Tick();
1605 } 1627 }
1606 current->AddCodeObjectIndex(code_index); 1628 current->AddCodeObjectIndex(code_index);
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 2123
2102 void Profile::Build(Thread* thread, 2124 void Profile::Build(Thread* thread,
2103 SampleFilter* filter, 2125 SampleFilter* filter,
2104 TagOrder tag_order, 2126 TagOrder tag_order,
2105 intptr_t extra_tags) { 2127 intptr_t extra_tags) {
2106 ProfileBuilder builder(thread, filter, tag_order, extra_tags, this); 2128 ProfileBuilder builder(thread, filter, tag_order, extra_tags, this);
2107 builder.Build(); 2129 builder.Build();
2108 } 2130 }
2109 2131
2110 2132
2133 intptr_t Profile::NumFunctions() const {
2134 return functions_->length();
2135 }
siva 2016/03/11 15:03:42 Is this accessor here and not in the header file t
Cutch 2016/03/11 17:16:20 Yes, ProfileFunctionTable is only defined inside t
2136
2111 ProfileFunction* Profile::GetFunction(intptr_t index) { 2137 ProfileFunction* Profile::GetFunction(intptr_t index) {
2112 ASSERT(functions_ != NULL); 2138 ASSERT(functions_ != NULL);
2113 return functions_->At(index); 2139 return functions_->At(index);
2114 } 2140 }
2115 2141
2116 2142
2117 ProfileCode* Profile::GetCode(intptr_t index) { 2143 ProfileCode* Profile::GetCode(intptr_t index) {
2118 ASSERT(live_code_ != NULL); 2144 ASSERT(live_code_ != NULL);
2119 ASSERT(dead_code_ != NULL); 2145 ASSERT(dead_code_ != NULL);
2120 ASSERT(tag_code_ != NULL); 2146 ASSERT(tag_code_ != NULL);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 2243
2218 ProfileTrieNode* trie = sample->timeline_trie(); 2244 ProfileTrieNode* trie = sample->timeline_trie();
2219 ASSERT(trie->frame_id() != -1); 2245 ASSERT(trie->frame_id() != -1);
2220 event.AddPropertyF("sf", "%" Pd "-%" Pd, 2246 event.AddPropertyF("sf", "%" Pd "-%" Pd,
2221 isolate_id, trie->frame_id()); 2247 isolate_id, trie->frame_id());
2222 } 2248 }
2223 } 2249 }
2224 } 2250 }
2225 2251
2226 2252
2253 ProfileFunction* Profile::FindFunction(const Function& function) {
2254 const intptr_t index = functions_->LookupIndex(function);
2255 if (index < 0) {
2256 return NULL;
2257 }
2258 return functions_->At(index);
2259 }
2260
2261
2227 void Profile::PrintProfileJSON(JSONStream* stream) { 2262 void Profile::PrintProfileJSON(JSONStream* stream) {
2228 ScopeTimer sw("Profile::PrintProfileJSON", FLAG_trace_profiler); 2263 ScopeTimer sw("Profile::PrintProfileJSON", FLAG_trace_profiler);
2229 JSONObject obj(stream); 2264 JSONObject obj(stream);
2230 obj.AddProperty("type", "_CpuProfile"); 2265 obj.AddProperty("type", "_CpuProfile");
2231 PrintHeaderJSON(&obj); 2266 PrintHeaderJSON(&obj);
2232 { 2267 {
2233 JSONArray codes(&obj, "codes"); 2268 JSONArray codes(&obj, "codes");
2234 for (intptr_t i = 0; i < live_code_->length(); i++) { 2269 for (intptr_t i = 0; i < live_code_->length(); i++) {
2235 ProfileCode* code = live_code_->At(i); 2270 ProfileCode* code = live_code_->At(i);
2236 ASSERT(code != NULL); 2271 ASSERT(code != NULL);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2547 // Disable thread interrupts while processing the buffer. 2582 // Disable thread interrupts while processing the buffer.
2548 DisableThreadInterruptsScope dtis(thread); 2583 DisableThreadInterruptsScope dtis(thread);
2549 2584
2550 ClearProfileVisitor clear_profile(isolate); 2585 ClearProfileVisitor clear_profile(isolate);
2551 sample_buffer->VisitSamples(&clear_profile); 2586 sample_buffer->VisitSamples(&clear_profile);
2552 } 2587 }
2553 2588
2554 #endif // !PRODUCT 2589 #endif // !PRODUCT
2555 2590
2556 } // namespace dart 2591 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698