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_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
7 | 7 |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/profiler.h" | 9 #include "vm/profiler.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 #define kThreadError -1 | 13 #define kThreadError -1 |
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 stack_lower, | 21 uintptr_t stack_lower, |
21 uintptr_t stack_upper) { | 22 uintptr_t stack_upper) { |
22 uintptr_t sp = stack_lower; | 23 uintptr_t sp = stack_lower; |
23 ASSERT(profiler_data != NULL); | 24 ASSERT(profiler_data != NULL); |
24 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); | 25 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); |
25 ASSERT(sample_buffer != NULL); | 26 ASSERT(sample_buffer != NULL); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 132 } |
132 ASSERT(lowest != max_time); | 133 ASSERT(lowest != max_time); |
133 ASSERT(lowest > 0); | 134 ASSERT(lowest > 0); |
134 return lowest; | 135 return lowest; |
135 } | 136 } |
136 | 137 |
137 | 138 |
138 void ProfilerManager::ThreadMain(uword parameters) { | 139 void ProfilerManager::ThreadMain(uword parameters) { |
139 ASSERT(initialized_); | 140 ASSERT(initialized_); |
140 ASSERT(FLAG_profile); | 141 ASSERT(FLAG_profile); |
| 142 if (FLAG_trace_profiled_isolates) { |
| 143 OS::Print("ProfilerManager Windows ready.\n"); |
| 144 } |
| 145 thread_running_ = true; |
| 146 { |
| 147 // Signal to main thread we are ready. |
| 148 ScopedMonitor startup_lock(start_stop_monitor_); |
| 149 startup_lock.Notify(); |
| 150 } |
141 ScopedMonitor lock(monitor_); | 151 ScopedMonitor lock(monitor_); |
142 while (!shutdown_) { | 152 while (!shutdown_) { |
143 int64_t current_time = OS::GetCurrentTimeMicros(); | 153 int64_t current_time = OS::GetCurrentTimeMicros(); |
144 int64_t next_sample = SampleAndRescheduleIsolates(current_time); | 154 int64_t next_sample = SampleAndRescheduleIsolates(current_time); |
145 lock.WaitMicros(next_sample); | 155 lock.WaitMicros(next_sample); |
146 } | 156 } |
| 157 if (FLAG_trace_profiled_isolates) { |
| 158 OS::Print("ProfilerManager Windows exiting.\n"); |
| 159 } |
| 160 thread_running_ = false; |
| 161 { |
| 162 // Signal to main thread we are exiting. |
| 163 ScopedMonitor shutdown_lock(start_stop_monitor_); |
| 164 shutdown_lock.Notify(); |
| 165 } |
147 } | 166 } |
148 | 167 |
149 } // namespace dart | 168 } // namespace dart |
150 | 169 |
151 #endif // defined(TARGET_OS_WINDOWS) | 170 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |