| 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 <cstdio> | 5 #include <cstdio> |
| 6 | 6 |
| 7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
| 8 | 8 |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/json_stream.h" | 10 #include "vm/json_stream.h" |
| 11 #include "vm/native_symbol.h" | 11 #include "vm/native_symbol.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/os.h" | 13 #include "vm/os.h" |
| 14 #include "vm/profiler.h" | 14 #include "vm/profiler.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 // Notes on locking and signal handling: | 18 // Notes on locking and signal handling: |
| 19 | 19 // |
| 20 // The ProfilerManager has a single monitor (monitor_). This monitor guards | 20 // The ProfilerManager has a single monitor (monitor_). This monitor guards |
| 21 // access to the schedule list of isolates (isolates_, isolates_size_, etc). | 21 // access to the schedule list of isolates (isolates_, isolates_size_, etc). |
| 22 // | 22 // |
| 23 // Each isolate has a mutex (profiler_data_mutex_) which protects access | 23 // Each isolate has a mutex (profiler_data_mutex_) which protects access |
| 24 // to the isolate's profiler data. | 24 // to the isolate's profiler data. |
| 25 // | 25 // |
| 26 // Locks can be taken in this order: | 26 // Locks can be taken in this order: |
| 27 // 1. ProfilerManager::monitor_ | 27 // 1. ProfilerManager::monitor_ |
| 28 // 2. isolate->profiler_data_mutex_ | 28 // 2. isolate->profiler_data_mutex_ |
| 29 // In other words, it is not acceptable to take ProfilerManager::monitor_ | 29 // In other words, it is not acceptable to take ProfilerManager::monitor_ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 50 // is sent the SIGPROF, it is removed from the scheduled isolate list. | 50 // is sent the SIGPROF, it is removed from the scheduled isolate list. |
| 51 // Inside the signal handler, after the sample is taken, the isolate is | 51 // Inside the signal handler, after the sample is taken, the isolate is |
| 52 // added to the scheduled isolate list again. The side effect of this is | 52 // added to the scheduled isolate list again. The side effect of this is |
| 53 // that the signal handler must be able to acquire the isolate profiler data | 53 // that the signal handler must be able to acquire the isolate profiler data |
| 54 // mutex and the profile manager monitor. When an isolate running thread | 54 // mutex and the profile manager monitor. When an isolate running thread |
| 55 // (potential signal target) calls into an entry point which acquires | 55 // (potential signal target) calls into an entry point which acquires |
| 56 // ProfileManager::monitor_ signal delivery must be blocked. An example is | 56 // ProfileManager::monitor_ signal delivery must be blocked. An example is |
| 57 // Isolate::SetCurrent which blocks signal delivery while removing the old | 57 // Isolate::SetCurrent which blocks signal delivery while removing the old |
| 58 // current isolate from the scheduled list and adding the new current isolate | 58 // current isolate from the scheduled list and adding the new current isolate |
| 59 // to the scheduled list. | 59 // to the scheduled list. |
| 60 // |
| 61 |
| 62 // Notes on stack frame walking: |
| 63 // |
| 64 // The sampling profiler will collect up to Sample::kNumStackFrames stack frames |
| 65 // The stack frame walking code uses the frame pointer to traverse the stack. |
| 66 // If the VM is compiled without frame pointers (which is the default on |
| 67 // recent GCC versions with optimizing enabled) the stack walking code will |
| 68 // fail (sometimes leading to a crash). |
| 69 // |
| 60 | 70 |
| 61 | 71 |
| 62 DEFINE_FLAG(bool, profile, false, "Enable Sampling Profiler"); | 72 DEFINE_FLAG(bool, profile, true, "Enable Sampling Profiler"); |
| 63 | 73 |
| 64 bool ProfilerManager::initialized_ = false; | 74 bool ProfilerManager::initialized_ = false; |
| 65 bool ProfilerManager::shutdown_ = false; | 75 bool ProfilerManager::shutdown_ = false; |
| 66 Monitor* ProfilerManager::monitor_ = NULL; | 76 Monitor* ProfilerManager::monitor_ = NULL; |
| 67 Isolate** ProfilerManager::isolates_ = NULL; | 77 Isolate** ProfilerManager::isolates_ = NULL; |
| 68 intptr_t ProfilerManager::isolates_capacity_ = 0; | 78 intptr_t ProfilerManager::isolates_capacity_ = 0; |
| 69 intptr_t ProfilerManager::isolates_size_ = 0; | 79 intptr_t ProfilerManager::isolates_size_ = 0; |
| 70 | 80 |
| 71 | 81 |
| 72 void ProfilerManager::InitOnce() { | 82 void ProfilerManager::InitOnce() { |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 return false; | 573 return false; |
| 564 } | 574 } |
| 565 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp); | 575 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp); |
| 566 cursor += sizeof(fp); | 576 cursor += sizeof(fp); |
| 567 bool r = cursor >= stack_lower_ && cursor <= stack_upper_; | 577 bool r = cursor >= stack_lower_ && cursor <= stack_upper_; |
| 568 return r; | 578 return r; |
| 569 } | 579 } |
| 570 | 580 |
| 571 | 581 |
| 572 } // namespace dart | 582 } // namespace dart |
| OLD | NEW |