Index: runtime/vm/profiler_service.cc |
diff --git a/runtime/vm/profiler_service.cc b/runtime/vm/profiler_service.cc |
index 8eaf6c147e959a055631de5c01efa9f48bfbb984..94060e584411f192e94d41167e29b0a3ae130855 100644 |
--- a/runtime/vm/profiler_service.cc |
+++ b/runtime/vm/profiler_service.cc |
@@ -157,18 +157,38 @@ void ProfileFunction::Tick(bool exclusive, |
void ProfileFunction::TickSourcePosition(TokenPosition token_position, |
bool exclusive) { |
- for (intptr_t i = 0; i < source_position_ticks_.length(); i++) { |
+ intptr_t i = 0; |
+ for (; i < source_position_ticks_.length(); i++) { |
ProfileFunctionSourcePosition& position = source_position_ticks_[i]; |
- if (position.token_pos() == token_position) { |
+ if (position.token_pos().value() == token_position.value()) { |
+ if (FLAG_trace_profiler) { |
+ OS::Print("Ticking source position %s %s\n", |
+ exclusive ? "exclusive" : "inclusive", |
+ token_position.ToCString()); |
+ } |
// Found existing position, tick it. |
position.Tick(exclusive); |
return; |
} |
+ if (position.token_pos().value() > token_position.value()) { |
+ break; |
+ } |
} |
- // Add new one. |
+ |
+ // Add new one, sorted by token position value. |
ProfileFunctionSourcePosition pfsp(token_position); |
+ if (FLAG_trace_profiler) { |
+ OS::Print("Ticking source position %s %s\n", |
+ exclusive ? "exclusive" : "inclusive", |
+ token_position.ToCString()); |
+ } |
pfsp.Tick(exclusive); |
- source_position_ticks_.Add(pfsp); |
+ |
+ if (i < source_position_ticks_.length()) { |
+ source_position_ticks_.InsertAt(i, pfsp); |
+ } else { |
+ source_position_ticks_.Add(pfsp); |
+ } |
} |
@@ -1587,13 +1607,15 @@ class ProfileBuilder : public ValueObject { |
ProfileFunction* function, |
TokenPosition token_position, |
intptr_t code_index) { |
- if (FLAG_trace_profiler) { |
- THR_Print("S[%" Pd "]F[%" Pd "] %s %s\n", |
- sample_index, |
- frame_index, |
- function->Name(), token_position.ToCString()); |
- } |
if (tick_functions_) { |
+ if (FLAG_trace_profiler) { |
+ THR_Print("S[%" Pd "]F[%" Pd "] %s %s 0x%" Px "\n", |
+ sample_index, |
+ frame_index, |
+ function->Name(), |
+ token_position.ToCString(), |
+ sample->At(frame_index)); |
+ } |
function->Tick(IsExecutingFrame(sample, frame_index), |
sample_index, |
token_position); |
@@ -2108,6 +2130,10 @@ void Profile::Build(Thread* thread, |
} |
+intptr_t Profile::NumFunctions() const { |
+ return functions_->length(); |
+} |
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
|
+ |
ProfileFunction* Profile::GetFunction(intptr_t index) { |
ASSERT(functions_ != NULL); |
return functions_->At(index); |
@@ -2224,6 +2250,15 @@ void Profile::PrintTimelineJSON(JSONStream* stream) { |
} |
+ProfileFunction* Profile::FindFunction(const Function& function) { |
+ const intptr_t index = functions_->LookupIndex(function); |
+ if (index < 0) { |
+ return NULL; |
+ } |
+ return functions_->At(index); |
+} |
+ |
+ |
void Profile::PrintProfileJSON(JSONStream* stream) { |
ScopeTimer sw("Profile::PrintProfileJSON", FLAG_trace_profiler); |
JSONObject obj(stream); |