| OLD | NEW |
| 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/native_symbol.h" | 10 #include "vm/native_symbol.h" |
| (...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 null_function_(Function::ZoneHandle()), | 1248 null_function_(Function::ZoneHandle()), |
| 1249 tick_functions_(false), | 1249 tick_functions_(false), |
| 1250 inclusive_tree_(false), | 1250 inclusive_tree_(false), |
| 1251 samples_(NULL), | 1251 samples_(NULL), |
| 1252 info_kind_(kNone) { | 1252 info_kind_(kNone) { |
| 1253 ASSERT(profile_ != NULL); | 1253 ASSERT(profile_ != NULL); |
| 1254 } | 1254 } |
| 1255 | 1255 |
| 1256 void Build() { | 1256 void Build() { |
| 1257 ScopeTimer sw("ProfileBuilder::Build", FLAG_trace_profiler); | 1257 ScopeTimer sw("ProfileBuilder::Build", FLAG_trace_profiler); |
| 1258 FilterSamples(); | 1258 if (!FilterSamples()) { |
| 1259 return; |
| 1260 } |
| 1259 | 1261 |
| 1260 Setup(); | 1262 Setup(); |
| 1261 BuildCodeTable(); | 1263 BuildCodeTable(); |
| 1262 FinalizeCodeIndexes(); | 1264 FinalizeCodeIndexes(); |
| 1263 BuildFunctionTable(); | 1265 BuildFunctionTable(); |
| 1264 | 1266 |
| 1265 BuildCodeTrie(Profile::kExclusiveCode); | 1267 BuildCodeTrie(Profile::kExclusiveCode); |
| 1266 BuildCodeTrie(Profile::kInclusiveCode); | 1268 BuildCodeTrie(Profile::kInclusiveCode); |
| 1267 | 1269 |
| 1268 BuildFunctionTrie(Profile::kExclusiveFunction); | 1270 BuildFunctionTrie(Profile::kExclusiveFunction); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1290 RegisterProfileCodeTag(VMTag::kRootTagId); | 1292 RegisterProfileCodeTag(VMTag::kRootTagId); |
| 1291 RegisterProfileCodeTag(VMTag::kTruncatedTagId); | 1293 RegisterProfileCodeTag(VMTag::kTruncatedTagId); |
| 1292 RegisterProfileCodeTag(VMTag::kNoneCodeTagId); | 1294 RegisterProfileCodeTag(VMTag::kNoneCodeTagId); |
| 1293 RegisterProfileCodeTag(VMTag::kOptimizedCodeTagId); | 1295 RegisterProfileCodeTag(VMTag::kOptimizedCodeTagId); |
| 1294 RegisterProfileCodeTag(VMTag::kUnoptimizedCodeTagId); | 1296 RegisterProfileCodeTag(VMTag::kUnoptimizedCodeTagId); |
| 1295 RegisterProfileCodeTag(VMTag::kNativeCodeTagId); | 1297 RegisterProfileCodeTag(VMTag::kNativeCodeTagId); |
| 1296 RegisterProfileCodeTag(VMTag::kInlineStartCodeTagId); | 1298 RegisterProfileCodeTag(VMTag::kInlineStartCodeTagId); |
| 1297 RegisterProfileCodeTag(VMTag::kInlineEndCodeTagId); | 1299 RegisterProfileCodeTag(VMTag::kInlineEndCodeTagId); |
| 1298 } | 1300 } |
| 1299 | 1301 |
| 1300 void FilterSamples() { | 1302 bool FilterSamples() { |
| 1301 ScopeTimer sw("ProfileBuilder::FilterSamples", FLAG_trace_profiler); | 1303 ScopeTimer sw("ProfileBuilder::FilterSamples", FLAG_trace_profiler); |
| 1302 SampleBuffer* sample_buffer = Profiler::sample_buffer(); | 1304 SampleBuffer* sample_buffer = Profiler::sample_buffer(); |
| 1303 if (sample_buffer == NULL) { | 1305 if (sample_buffer == NULL) { |
| 1304 return; | 1306 return false; |
| 1305 } | 1307 } |
| 1306 samples_ = sample_buffer->BuildProcessedSampleBuffer(filter_); | 1308 samples_ = sample_buffer->BuildProcessedSampleBuffer(filter_); |
| 1307 profile_->samples_ = samples_; | 1309 profile_->samples_ = samples_; |
| 1308 profile_->sample_count_ = samples_->length(); | 1310 profile_->sample_count_ = samples_->length(); |
| 1311 return true; |
| 1309 } | 1312 } |
| 1310 | 1313 |
| 1311 void UpdateMinMaxTimes(int64_t timestamp) { | 1314 void UpdateMinMaxTimes(int64_t timestamp) { |
| 1312 profile_->min_time_ = | 1315 profile_->min_time_ = |
| 1313 timestamp < profile_->min_time_ ? timestamp : profile_->min_time_; | 1316 timestamp < profile_->min_time_ ? timestamp : profile_->min_time_; |
| 1314 profile_->max_time_ = | 1317 profile_->max_time_ = |
| 1315 timestamp > profile_->max_time_ ? timestamp : profile_->max_time_; | 1318 timestamp > profile_->max_time_ ? timestamp : profile_->max_time_; |
| 1316 } | 1319 } |
| 1317 | 1320 |
| 1318 void SanitizeMinMaxTimes() { | 1321 void SanitizeMinMaxTimes() { |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2511 ProfileTrieNode* trie = sample->timeline_trie(); | 2514 ProfileTrieNode* trie = sample->timeline_trie(); |
| 2512 ASSERT(trie->frame_id() != -1); | 2515 ASSERT(trie->frame_id() != -1); |
| 2513 event.AddPropertyF("sf", "%" Pd "-%" Pd, | 2516 event.AddPropertyF("sf", "%" Pd "-%" Pd, |
| 2514 isolate_id, trie->frame_id()); | 2517 isolate_id, trie->frame_id()); |
| 2515 } | 2518 } |
| 2516 } | 2519 } |
| 2517 } | 2520 } |
| 2518 | 2521 |
| 2519 | 2522 |
| 2520 ProfileFunction* Profile::FindFunction(const Function& function) { | 2523 ProfileFunction* Profile::FindFunction(const Function& function) { |
| 2521 return functions_->Lookup(function); | 2524 return (functions_ != NULL) ? functions_->Lookup(function) : NULL; |
| 2522 } | 2525 } |
| 2523 | 2526 |
| 2524 | 2527 |
| 2525 void Profile::PrintProfileJSON(JSONStream* stream) { | 2528 void Profile::PrintProfileJSON(JSONStream* stream) { |
| 2526 ScopeTimer sw("Profile::PrintProfileJSON", FLAG_trace_profiler); | 2529 ScopeTimer sw("Profile::PrintProfileJSON", FLAG_trace_profiler); |
| 2527 JSONObject obj(stream); | 2530 JSONObject obj(stream); |
| 2528 obj.AddProperty("type", "_CpuProfile"); | 2531 obj.AddProperty("type", "_CpuProfile"); |
| 2529 PrintHeaderJSON(&obj); | 2532 PrintHeaderJSON(&obj); |
| 2530 { | 2533 { |
| 2531 JSONArray codes(&obj, "codes"); | 2534 JSONArray codes(&obj, "codes"); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2857 // Disable thread interrupts while processing the buffer. | 2860 // Disable thread interrupts while processing the buffer. |
| 2858 DisableThreadInterruptsScope dtis(thread); | 2861 DisableThreadInterruptsScope dtis(thread); |
| 2859 | 2862 |
| 2860 ClearProfileVisitor clear_profile(isolate); | 2863 ClearProfileVisitor clear_profile(isolate); |
| 2861 sample_buffer->VisitSamples(&clear_profile); | 2864 sample_buffer->VisitSamples(&clear_profile); |
| 2862 } | 2865 } |
| 2863 | 2866 |
| 2864 #endif // !PRODUCT | 2867 #endif // !PRODUCT |
| 2865 | 2868 |
| 2866 } // namespace dart | 2869 } // namespace dart |
| OLD | NEW |