| 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/native_symbol.h" | 8 #include "vm/native_symbol.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/os.h" | 10 #include "vm/os.h" |
| (...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 } | 1287 } |
| 1288 | 1288 |
| 1289 ProfileFunctionTrieNode* ProcessFrame( | 1289 ProfileFunctionTrieNode* ProcessFrame( |
| 1290 ProfileFunctionTrieNode* current, | 1290 ProfileFunctionTrieNode* current, |
| 1291 intptr_t sample_index, | 1291 intptr_t sample_index, |
| 1292 ProcessedSample* sample, | 1292 ProcessedSample* sample, |
| 1293 intptr_t frame_index) { | 1293 intptr_t frame_index) { |
| 1294 const uword pc = sample->At(frame_index); | 1294 const uword pc = sample->At(frame_index); |
| 1295 ProfileCode* profile_code = GetProfileCode(pc, | 1295 ProfileCode* profile_code = GetProfileCode(pc, |
| 1296 sample->timestamp()); | 1296 sample->timestamp()); |
| 1297 ProfileFunction* function = profile_code->function(); |
| 1298 ASSERT(function != NULL); |
| 1297 const intptr_t code_index = profile_code->code_table_index(); | 1299 const intptr_t code_index = profile_code->code_table_index(); |
| 1298 ASSERT(profile_code != NULL); | 1300 ASSERT(profile_code != NULL); |
| 1299 const Code& code = Code::ZoneHandle(profile_code->code()); | 1301 const Code& code = Code::ZoneHandle(profile_code->code()); |
| 1300 GrowableArray<Function*> inlined_functions; | 1302 GrowableArray<Function*> inlined_functions; |
| 1301 if (!code.IsNull()) { | 1303 if (!code.IsNull()) { |
| 1302 intptr_t offset = pc - code.EntryPoint(); | 1304 intptr_t offset = pc - code.EntryPoint(); |
| 1303 code.GetInlinedFunctionsAt(offset, &inlined_functions); | 1305 code.GetInlinedFunctionsAt(offset, &inlined_functions); |
| 1304 } | 1306 } |
| 1305 if (code.IsNull() || (inlined_functions.length() == 0)) { | 1307 if (code.IsNull() || (inlined_functions.length() == 0)) { |
| 1306 // No inlined functions. | 1308 // No inlined functions. |
| 1307 ProfileFunction* function = profile_code->function(); | |
| 1308 ASSERT(function != NULL); | |
| 1309 current = ProcessFunction(current, | 1309 current = ProcessFunction(current, |
| 1310 sample_index, | 1310 sample_index, |
| 1311 sample, | 1311 sample, |
| 1312 frame_index, | 1312 frame_index, |
| 1313 function, | 1313 function, |
| 1314 code_index); | 1314 code_index); |
| 1315 return current; | 1315 return current; |
| 1316 } | 1316 } |
| 1317 | 1317 |
| 1318 if (inclusive_tree_) { | 1318 if (inclusive_tree_) { |
| 1319 // Append the inliner. |
| 1320 current = ProcessFunction(current, |
| 1321 sample_index, |
| 1322 sample, |
| 1323 frame_index + inlined_functions.length(), |
| 1324 function, |
| 1325 code_index); |
| 1326 // Append the inlined children. |
| 1319 for (intptr_t i = inlined_functions.length() - 1; i >= 0; i--) { | 1327 for (intptr_t i = inlined_functions.length() - 1; i >= 0; i--) { |
| 1320 Function* inlined_function = inlined_functions[i]; | 1328 Function* inlined_function = inlined_functions[i]; |
| 1321 ASSERT(inlined_function != NULL); | 1329 ASSERT(inlined_function != NULL); |
| 1322 ASSERT(!inlined_function->IsNull()); | 1330 ASSERT(!inlined_function->IsNull()); |
| 1323 current = ProcessInlinedFunction(current, | 1331 current = ProcessInlinedFunction(current, |
| 1324 sample_index, | 1332 sample_index, |
| 1325 sample, | 1333 sample, |
| 1326 frame_index, | 1334 frame_index, |
| 1327 inlined_function, | 1335 inlined_function, |
| 1328 code_index); | 1336 code_index); |
| 1329 } | 1337 } |
| 1330 } else { | 1338 } else { |
| 1339 // Append the inlined children. |
| 1331 for (intptr_t i = 0; i < inlined_functions.length(); i++) { | 1340 for (intptr_t i = 0; i < inlined_functions.length(); i++) { |
| 1332 Function* inlined_function = inlined_functions[i]; | 1341 Function* inlined_function = inlined_functions[i]; |
| 1333 ASSERT(inlined_function != NULL); | 1342 ASSERT(inlined_function != NULL); |
| 1334 ASSERT(!inlined_function->IsNull()); | 1343 ASSERT(!inlined_function->IsNull()); |
| 1335 current = ProcessInlinedFunction(current, | 1344 current = ProcessInlinedFunction(current, |
| 1336 sample_index, | 1345 sample_index, |
| 1337 sample, | 1346 sample, |
| 1338 frame_index + i, | 1347 frame_index + i, |
| 1339 inlined_function, | 1348 inlined_function, |
| 1340 code_index); | 1349 code_index); |
| 1341 } | 1350 } |
| 1351 // Append the inliner. |
| 1352 current = ProcessFunction(current, |
| 1353 sample_index, |
| 1354 sample, |
| 1355 frame_index + inlined_functions.length(), |
| 1356 function, |
| 1357 code_index); |
| 1342 } | 1358 } |
| 1343 | 1359 |
| 1344 return current; | 1360 return current; |
| 1345 } | 1361 } |
| 1346 | 1362 |
| 1347 ProfileFunctionTrieNode* ProcessInlinedFunction( | 1363 ProfileFunctionTrieNode* ProcessInlinedFunction( |
| 1348 ProfileFunctionTrieNode* current, | 1364 ProfileFunctionTrieNode* current, |
| 1349 intptr_t sample_index, | 1365 intptr_t sample_index, |
| 1350 ProcessedSample* sample, | 1366 ProcessedSample* sample, |
| 1351 intptr_t frame_index, | 1367 intptr_t frame_index, |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 } | 2017 } |
| 2002 current_index++; | 2018 current_index++; |
| 2003 if (current_index >= parent_->NumChildren()) { | 2019 if (current_index >= parent_->NumChildren()) { |
| 2004 return false; | 2020 return false; |
| 2005 } | 2021 } |
| 2006 current_ = parent_->At(current_index); | 2022 current_ = parent_->At(current_index); |
| 2007 return true; | 2023 return true; |
| 2008 } | 2024 } |
| 2009 | 2025 |
| 2010 | 2026 |
| 2027 intptr_t ProfileTrieWalker::SiblingCount() { |
| 2028 ASSERT(parent_ != NULL); |
| 2029 return parent_->NumChildren(); |
| 2030 } |
| 2031 |
| 2032 |
| 2011 void ProfilerService::PrintJSONImpl(Isolate* isolate, | 2033 void ProfilerService::PrintJSONImpl(Isolate* isolate, |
| 2012 JSONStream* stream, | 2034 JSONStream* stream, |
| 2013 Profile::TagOrder tag_order, | 2035 Profile::TagOrder tag_order, |
| 2014 SampleFilter* filter) { | 2036 SampleFilter* filter) { |
| 2015 // Disable profile interrupts while processing the buffer. | 2037 // Disable profile interrupts while processing the buffer. |
| 2016 Profiler::EndExecution(isolate); | 2038 Profiler::EndExecution(isolate); |
| 2017 | 2039 |
| 2018 { | 2040 { |
| 2019 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); | 2041 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); |
| 2020 IsolateProfilerData* profiler_data = isolate->profiler_data(); | 2042 IsolateProfilerData* profiler_data = isolate->profiler_data(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2099 ASSERT(sample_buffer != NULL); | 2121 ASSERT(sample_buffer != NULL); |
| 2100 | 2122 |
| 2101 ClearProfileVisitor clear_profile(isolate); | 2123 ClearProfileVisitor clear_profile(isolate); |
| 2102 sample_buffer->VisitSamples(&clear_profile); | 2124 sample_buffer->VisitSamples(&clear_profile); |
| 2103 | 2125 |
| 2104 // Enable profile interrupts. | 2126 // Enable profile interrupts. |
| 2105 Profiler::BeginExecution(isolate); | 2127 Profiler::BeginExecution(isolate); |
| 2106 } | 2128 } |
| 2107 | 2129 |
| 2108 } // namespace dart | 2130 } // namespace dart |
| OLD | NEW |