| 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/address_sanitizer.h" | 5 #include "platform/address_sanitizer.h" |
| 6 #include "platform/memory_sanitizer.h" | 6 #include "platform/memory_sanitizer.h" |
| 7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
| 8 | 8 |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/atomic.h" | 10 #include "vm/atomic.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace dart { | 24 namespace dart { |
| 25 | 25 |
| 26 | 26 |
| 27 #if defined(TARGET_OS_ANDROID) || defined(HOST_ARCH_ARM64) | 27 #if defined(TARGET_OS_ANDROID) || defined(HOST_ARCH_ARM64) |
| 28 DEFINE_FLAG(bool, profile, false, "Enable Sampling Profiler"); | 28 DEFINE_FLAG(bool, profile, false, "Enable Sampling Profiler"); |
| 29 #else | 29 #else |
| 30 DEFINE_FLAG(bool, profile, true, "Enable Sampling Profiler"); | 30 DEFINE_FLAG(bool, profile, true, "Enable Sampling Profiler"); |
| 31 #endif | 31 #endif |
| 32 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates."); | 32 DEFINE_FLAG(bool, trace_profiled_isolates, false, "Trace profiled isolates."); |
| 33 DEFINE_FLAG(bool, trace_profiler, false, "Trace profiler."); |
| 33 DEFINE_FLAG(charp, profile_dir, NULL, | 34 DEFINE_FLAG(charp, profile_dir, NULL, |
| 34 "Enable writing profile data into specified directory."); | 35 "Enable writing profile data into specified directory."); |
| 35 DEFINE_FLAG(int, profile_period, 1000, | 36 DEFINE_FLAG(int, profile_period, 1000, |
| 36 "Time between profiler samples in microseconds. Minimum 50."); | 37 "Time between profiler samples in microseconds. Minimum 50."); |
| 37 DEFINE_FLAG(int, profile_depth, 8, | 38 DEFINE_FLAG(int, profile_depth, 8, |
| 38 "Maximum number stack frames walked. Minimum 1. Maximum 255."); | 39 "Maximum number stack frames walked. Minimum 1. Maximum 255."); |
| 39 #if defined(PROFILE_NATIVE_CODE) || defined(USING_SIMULATOR) | 40 #if defined(PROFILE_NATIVE_CODE) || defined(USING_SIMULATOR) |
| 40 DEFINE_FLAG(bool, profile_vm, true, | 41 DEFINE_FLAG(bool, profile_vm, true, |
| 41 "Always collect native stack traces."); | 42 "Always collect native stack traces."); |
| 42 #else | 43 #else |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 return; | 171 return; |
| 171 } | 172 } |
| 172 ASSERT(initialized_); | 173 ASSERT(initialized_); |
| 173 ThreadInterrupter::Unregister(); | 174 ThreadInterrupter::Unregister(); |
| 174 } | 175 } |
| 175 | 176 |
| 176 | 177 |
| 177 class ScopeStopwatch : public ValueObject { | 178 class ScopeStopwatch : public ValueObject { |
| 178 public: | 179 public: |
| 179 explicit ScopeStopwatch(const char* name) : name_(name) { | 180 explicit ScopeStopwatch(const char* name) : name_(name) { |
| 180 start_ = FLAG_trace_profiled_isolates ? OS::GetCurrentTimeMillis() : 0; | 181 start_ = FLAG_trace_profiler ? OS::GetCurrentTimeMillis() : 0; |
| 181 } | 182 } |
| 182 | 183 |
| 183 int64_t GetElapsed() const { | 184 int64_t GetElapsed() const { |
| 184 int64_t end = OS::GetCurrentTimeMillis(); | 185 int64_t end = OS::GetCurrentTimeMillis(); |
| 185 ASSERT(end >= start_); | 186 ASSERT(end >= start_); |
| 186 return end - start_; | 187 return end - start_; |
| 187 } | 188 } |
| 188 | 189 |
| 189 ~ScopeStopwatch() { | 190 ~ScopeStopwatch() { |
| 190 if (FLAG_trace_profiled_isolates) { | 191 if (FLAG_trace_profiler) { |
| 191 int64_t elapsed = GetElapsed(); | 192 int64_t elapsed = GetElapsed(); |
| 192 OS::Print("%s took %" Pd64 " millis.\n", name_, elapsed); | 193 OS::Print("%s took %" Pd64 " millis.\n", name_, elapsed); |
| 193 } | 194 } |
| 194 } | 195 } |
| 195 | 196 |
| 196 private: | 197 private: |
| 197 const char* name_; | 198 const char* name_; |
| 198 int64_t start_; | 199 int64_t start_; |
| 199 }; | 200 }; |
| 200 | 201 |
| (...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 CodeRegionTable live_code_table; | 1444 CodeRegionTable live_code_table; |
| 1444 // Dead code holds Overwritten CodeRegions. | 1445 // Dead code holds Overwritten CodeRegions. |
| 1445 CodeRegionTable dead_code_table; | 1446 CodeRegionTable dead_code_table; |
| 1446 // Tag code holds Tag CodeRegions. | 1447 // Tag code holds Tag CodeRegions. |
| 1447 CodeRegionTable tag_code_table; | 1448 CodeRegionTable tag_code_table; |
| 1448 CodeRegionTableBuilder builder(isolate, | 1449 CodeRegionTableBuilder builder(isolate, |
| 1449 &live_code_table, | 1450 &live_code_table, |
| 1450 &dead_code_table, | 1451 &dead_code_table, |
| 1451 &tag_code_table); | 1452 &tag_code_table); |
| 1452 { | 1453 { |
| 1454 ScopeStopwatch sw("FixTopFrame"); |
| 1453 // Preprocess samples and fix the caller when the top PC is in a | 1455 // Preprocess samples and fix the caller when the top PC is in a |
| 1454 // stub or intrinsic without a frame. | 1456 // stub or intrinsic without a frame. |
| 1455 FixTopFrameVisitor fixTopFrame(isolate); | 1457 FixTopFrameVisitor fixTopFrame(isolate); |
| 1456 sample_buffer->VisitSamples(&fixTopFrame); | 1458 sample_buffer->VisitSamples(&fixTopFrame); |
| 1457 } | 1459 } |
| 1458 { | 1460 { |
| 1459 // Build CodeRegion tables. | 1461 // Build CodeRegion tables. |
| 1460 ScopeStopwatch sw("CodeRegionTableBuilder"); | 1462 ScopeStopwatch sw("CodeRegionTableBuilder"); |
| 1461 sample_buffer->VisitSamples(&builder); | 1463 sample_buffer->VisitSamples(&builder); |
| 1462 } | 1464 } |
| 1463 intptr_t samples = builder.visited(); | 1465 intptr_t samples = builder.visited(); |
| 1464 intptr_t frames = builder.frames(); | 1466 intptr_t frames = builder.frames(); |
| 1465 if (FLAG_trace_profiled_isolates) { | 1467 if (FLAG_trace_profiler) { |
| 1466 intptr_t total_live_code_objects = live_code_table.Length(); | 1468 intptr_t total_live_code_objects = live_code_table.Length(); |
| 1467 intptr_t total_dead_code_objects = dead_code_table.Length(); | 1469 intptr_t total_dead_code_objects = dead_code_table.Length(); |
| 1468 intptr_t total_tag_code_objects = tag_code_table.Length(); | 1470 intptr_t total_tag_code_objects = tag_code_table.Length(); |
| 1469 OS::Print("Processed %" Pd " frames\n", frames); | 1471 OS::Print("Processed %" Pd " frames\n", frames); |
| 1470 OS::Print("CodeTables: live=%" Pd " dead=%" Pd " tag=%" Pd "\n", | 1472 OS::Print("CodeTables: live=%" Pd " dead=%" Pd " tag=%" Pd "\n", |
| 1471 total_live_code_objects, | 1473 total_live_code_objects, |
| 1472 total_dead_code_objects, | 1474 total_dead_code_objects, |
| 1473 total_tag_code_objects); | 1475 total_tag_code_objects); |
| 1474 } | 1476 } |
| 1475 #if defined(DEBUG) | 1477 #if defined(DEBUG) |
| 1476 live_code_table.Verify(); | 1478 live_code_table.Verify(); |
| 1477 dead_code_table.Verify(); | 1479 dead_code_table.Verify(); |
| 1478 tag_code_table.Verify(); | 1480 tag_code_table.Verify(); |
| 1479 if (FLAG_trace_profiled_isolates) { | 1481 if (FLAG_trace_profiler) { |
| 1480 OS::Print("CodeRegionTables verified to be ordered and not overlap.\n"); | 1482 OS::Print("CodeRegionTables verified to be ordered and not overlap.\n"); |
| 1481 } | 1483 } |
| 1482 #endif | 1484 #endif |
| 1483 CodeRegionExclusiveTrieBuilder build_trie(isolate, | 1485 CodeRegionExclusiveTrieBuilder build_trie(isolate, |
| 1484 &live_code_table, | 1486 &live_code_table, |
| 1485 &dead_code_table, | 1487 &dead_code_table, |
| 1486 &tag_code_table); | 1488 &tag_code_table); |
| 1487 build_trie.set_tag_order(tag_order); | 1489 build_trie.set_tag_order(tag_order); |
| 1488 { | 1490 { |
| 1489 // Build CodeRegion trie. | 1491 // Build CodeRegion trie. |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 state.pc, | 2125 state.pc, |
| 2124 state.fp, | 2126 state.fp, |
| 2125 sp); | 2127 sp); |
| 2126 stackWalker.walk(); | 2128 stackWalker.walk(); |
| 2127 #endif | 2129 #endif |
| 2128 } | 2130 } |
| 2129 } | 2131 } |
| 2130 } | 2132 } |
| 2131 | 2133 |
| 2132 } // namespace dart | 2134 } // namespace dart |
| OLD | NEW |