| 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 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 | 1318 |
| 1319 CodeRegionTrieNode* exclusive_root_; | 1319 CodeRegionTrieNode* exclusive_root_; |
| 1320 CodeRegionTable* live_code_table_; | 1320 CodeRegionTable* live_code_table_; |
| 1321 CodeRegionTable* dead_code_table_; | 1321 CodeRegionTable* dead_code_table_; |
| 1322 CodeRegionTable* tag_code_table_; | 1322 CodeRegionTable* tag_code_table_; |
| 1323 intptr_t dead_code_table_offset_; | 1323 intptr_t dead_code_table_offset_; |
| 1324 intptr_t tag_code_table_offset_; | 1324 intptr_t tag_code_table_offset_; |
| 1325 }; | 1325 }; |
| 1326 | 1326 |
| 1327 | 1327 |
| 1328 void Profiler::PrintToJSONStream(Isolate* isolate, JSONStream* stream, | 1328 void Profiler::PrintJSON(Isolate* isolate, JSONStream* stream, |
| 1329 bool full, TagOrder tag_order) { | 1329 bool full, TagOrder tag_order) { |
| 1330 ASSERT(isolate == Isolate::Current()); | 1330 ASSERT(isolate == Isolate::Current()); |
| 1331 // Disable profile interrupts while processing the buffer. | 1331 // Disable profile interrupts while processing the buffer. |
| 1332 EndExecution(isolate); | 1332 EndExecution(isolate); |
| 1333 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); | 1333 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); |
| 1334 IsolateProfilerData* profiler_data = isolate->profiler_data(); | 1334 IsolateProfilerData* profiler_data = isolate->profiler_data(); |
| 1335 if (profiler_data == NULL) { | 1335 if (profiler_data == NULL) { |
| 1336 JSONObject error(stream); | 1336 JSONObject error(stream); |
| 1337 error.AddProperty("type", "Error"); | 1337 error.AddProperty("type", "Error"); |
| 1338 error.AddProperty("text", "Isolate does not have profiling enabled."); | 1338 error.AddProperty("text", "Isolate does not have profiling enabled."); |
| 1339 return; | 1339 return; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); | 1454 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); |
| 1455 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); | 1455 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); |
| 1456 if ((file_open == NULL) || (file_close == NULL) || (file_write == NULL)) { | 1456 if ((file_open == NULL) || (file_close == NULL) || (file_write == NULL)) { |
| 1457 // Embedder has not provided necessary callbacks. | 1457 // Embedder has not provided necessary callbacks. |
| 1458 return; | 1458 return; |
| 1459 } | 1459 } |
| 1460 // We will be looking up code objects within the isolate. | 1460 // We will be looking up code objects within the isolate. |
| 1461 ASSERT(Isolate::Current() == isolate); | 1461 ASSERT(Isolate::Current() == isolate); |
| 1462 JSONStream stream(10 * MB); | 1462 JSONStream stream(10 * MB); |
| 1463 intptr_t pid = OS::ProcessId(); | 1463 intptr_t pid = OS::ProcessId(); |
| 1464 PrintToJSONStream(isolate, &stream, true, Profiler::kNoTags); | 1464 PrintJSON(isolate, &stream, true, Profiler::kNoTags); |
| 1465 const char* format = "%s/dart-profile-%" Pd "-%" Pd ".json"; | 1465 const char* format = "%s/dart-profile-%" Pd "-%" Pd ".json"; |
| 1466 intptr_t len = OS::SNPrint(NULL, 0, format, | 1466 intptr_t len = OS::SNPrint(NULL, 0, format, |
| 1467 FLAG_profile_dir, pid, isolate->main_port()); | 1467 FLAG_profile_dir, pid, isolate->main_port()); |
| 1468 char* filename = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 1468 char* filename = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
| 1469 OS::SNPrint(filename, len + 1, format, | 1469 OS::SNPrint(filename, len + 1, format, |
| 1470 FLAG_profile_dir, pid, isolate->main_port()); | 1470 FLAG_profile_dir, pid, isolate->main_port()); |
| 1471 void* f = file_open(filename, true); | 1471 void* f = file_open(filename, true); |
| 1472 if (f == NULL) { | 1472 if (f == NULL) { |
| 1473 // Cannot write. | 1473 // Cannot write. |
| 1474 return; | 1474 return; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 ProfilerDartStackWalker stackWalker(sample); | 1721 ProfilerDartStackWalker stackWalker(sample); |
| 1722 stackWalker.walk(); | 1722 stackWalker.walk(); |
| 1723 } else { | 1723 } else { |
| 1724 // TODO(johnmccutchan): Support collecting only Dart frames with | 1724 // TODO(johnmccutchan): Support collecting only Dart frames with |
| 1725 // ProfilerNativeStackWalker. | 1725 // ProfilerNativeStackWalker. |
| 1726 } | 1726 } |
| 1727 } | 1727 } |
| 1728 } | 1728 } |
| 1729 | 1729 |
| 1730 } // namespace dart | 1730 } // namespace dart |
| OLD | NEW |