| 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_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 Isolate* isolate = Isolate::Current(); | 22 Isolate* isolate = Isolate::Current(); |
| 23 if (isolate == NULL) { | 23 if (isolate == NULL) { |
| 24 return; | 24 return; |
| 25 } | 25 } |
| 26 // Thread owns no profiler locks at this point. | 26 // Thread owns no profiler locks at this point. |
| 27 { | 27 { |
| 28 // Thread owns isolate profiler data mutex. | 28 // Thread owns isolate profiler data mutex. |
| 29 ScopedMutex profiler_data_lock(isolate->profiler_data_mutex()); | 29 ScopedMutex profiler_data_lock(isolate->profiler_data_mutex()); |
| 30 IsolateProfilerData* profiler_data = isolate->profiler_data(); | 30 IsolateProfilerData* profiler_data = isolate->profiler_data(); |
| 31 if (profiler_data == NULL) { | 31 if ((profiler_data == NULL) || !profiler_data->CanExpire() || |
| 32 (profiler_data->sample_buffer() == NULL)) { |
| 33 // Descheduled. |
| 32 return; | 34 return; |
| 33 } | 35 } |
| 34 if (!profiler_data->CanExpire()) { | 36 if (profiler_data->thread_id() == Thread::GetCurrentThreadId()) { |
| 35 // Descheduled. | 37 // Still scheduled on this thread. |
| 36 return; | 38 // TODO(johnmccutchan): Perform sample on Android. |
| 37 } | 39 } |
| 38 } | 40 } |
| 39 // Thread owns no profiler locks at this point. | 41 // Thread owns no profiler locks at this point. |
| 40 // This call will acquire both ProfilerManager::monitor and the | 42 // This call will acquire both ProfilerManager::monitor and the |
| 41 // isolate's profiler data mutex. | 43 // isolate's profiler data mutex. |
| 42 ProfilerManager::ScheduleIsolate(isolate, true); | 44 ProfilerManager::ScheduleIsolate(isolate, true); |
| 43 } | 45 } |
| 44 | 46 |
| 45 | 47 |
| 46 int64_t ProfilerManager::SampleAndRescheduleIsolates(int64_t current_time) { | 48 int64_t ProfilerManager::SampleAndRescheduleIsolates(int64_t current_time) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 int64_t current_time = OS::GetCurrentTimeMicros(); | 102 int64_t current_time = OS::GetCurrentTimeMicros(); |
| 101 int64_t next_sample = SampleAndRescheduleIsolates(current_time); | 103 int64_t next_sample = SampleAndRescheduleIsolates(current_time); |
| 102 lock.WaitMicros(next_sample); | 104 lock.WaitMicros(next_sample); |
| 103 } | 105 } |
| 104 } | 106 } |
| 105 | 107 |
| 106 | 108 |
| 107 } // namespace dart | 109 } // namespace dart |
| 108 | 110 |
| 109 #endif // defined(TARGET_OS_ANDROID) | 111 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |