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/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
7 | 7 |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/json_stream.h" | 9 #include "vm/json_stream.h" |
10 #include "vm/profiler.h" | 10 #include "vm/profiler.h" |
11 #include "vm/signal_handler.h" | 11 #include "vm/signal_handler.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 DECLARE_FLAG(bool, profile); | 15 DECLARE_FLAG(bool, profile); |
| 16 DECLARE_FLAG(bool, trace_profiled_isolates); |
16 | 17 |
17 static void CollectSample(IsolateProfilerData* profiler_data, | 18 static void CollectSample(IsolateProfilerData* profiler_data, |
18 uintptr_t pc, | 19 uintptr_t pc, |
19 uintptr_t fp, | 20 uintptr_t fp, |
20 uintptr_t sp, | 21 uintptr_t sp, |
21 uintptr_t stack_lower, | 22 uintptr_t stack_lower, |
22 uintptr_t stack_upper) { | 23 uintptr_t stack_upper) { |
23 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); | 24 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); |
24 Sample* sample = sample_buffer->ReserveSample(); | 25 Sample* sample = sample_buffer->ReserveSample(); |
25 ASSERT(sample != NULL); | 26 ASSERT(sample != NULL); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 ASSERT(lowest != max_time); | 123 ASSERT(lowest != max_time); |
123 ASSERT(lowest > 0); | 124 ASSERT(lowest > 0); |
124 return lowest; | 125 return lowest; |
125 } | 126 } |
126 | 127 |
127 | 128 |
128 void ProfilerManager::ThreadMain(uword parameters) { | 129 void ProfilerManager::ThreadMain(uword parameters) { |
129 ASSERT(initialized_); | 130 ASSERT(initialized_); |
130 ASSERT(FLAG_profile); | 131 ASSERT(FLAG_profile); |
131 SignalHandler::Install(ProfileSignalAction); | 132 SignalHandler::Install(ProfileSignalAction); |
| 133 if (FLAG_trace_profiled_isolates) { |
| 134 OS::Print("ProfilerManager Linux ready.\n"); |
| 135 } |
| 136 thread_running_ = true; |
| 137 { |
| 138 // Signal to main thread we are ready. |
| 139 ScopedMonitor startup_lock(start_stop_monitor_); |
| 140 startup_lock.Notify(); |
| 141 } |
132 ScopedMonitor lock(monitor_); | 142 ScopedMonitor lock(monitor_); |
133 while (!shutdown_) { | 143 while (!shutdown_) { |
134 int64_t current_time = OS::GetCurrentTimeMicros(); | 144 int64_t current_time = OS::GetCurrentTimeMicros(); |
135 int64_t next_sample = SampleAndRescheduleIsolates(current_time); | 145 int64_t next_sample = SampleAndRescheduleIsolates(current_time); |
136 lock.WaitMicros(next_sample); | 146 lock.WaitMicros(next_sample); |
137 } | 147 } |
| 148 if (FLAG_trace_profiled_isolates) { |
| 149 OS::Print("ProfilerManager Linux exiting.\n"); |
| 150 } |
| 151 thread_running_ = false; |
| 152 { |
| 153 // Signal to main thread we are exiting. |
| 154 ScopedMonitor shutdown_lock(start_stop_monitor_); |
| 155 shutdown_lock.Notify(); |
| 156 } |
138 } | 157 } |
139 | 158 |
140 | 159 |
141 } // namespace dart | 160 } // namespace dart |
142 | 161 |
143 #endif // defined(TARGET_OS_LINUX) | 162 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |