Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: runtime/vm/profiler_linux.cc

Issue 85333006: Profiler fixes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/profiler_android.cc ('k') | runtime/vm/profiler_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 mcontext_t mcontext = context->uc_mcontext; 45 mcontext_t mcontext = context->uc_mcontext;
46 Isolate* isolate = Isolate::Current(); 46 Isolate* isolate = Isolate::Current();
47 if (isolate == NULL) { 47 if (isolate == NULL) {
48 return; 48 return;
49 } 49 }
50 // Thread owns no profiler locks at this point. 50 // Thread owns no profiler locks at this point.
51 { 51 {
52 // Thread owns isolate profiler data mutex. 52 // Thread owns isolate profiler data mutex.
53 ScopedMutex profiler_data_lock(isolate->profiler_data_mutex()); 53 ScopedMutex profiler_data_lock(isolate->profiler_data_mutex());
54 IsolateProfilerData* profiler_data = isolate->profiler_data(); 54 IsolateProfilerData* profiler_data = isolate->profiler_data();
55 if (profiler_data == NULL) { 55 if ((profiler_data == NULL) || !profiler_data->CanExpire() ||
56 return; 56 (profiler_data->sample_buffer() == NULL)) {
57 }
58 if (!profiler_data->CanExpire()) {
59 // Descheduled. 57 // Descheduled.
60 return; 58 return;
61 } 59 }
62 60 if (profiler_data->thread_id() == Thread::GetCurrentThreadId()) {
63 uintptr_t stack_lower = 0; 61 // Still scheduled on this thread.
64 uintptr_t stack_upper = 0; 62 uintptr_t stack_lower = 0;
65 isolate->GetStackBounds(&stack_lower, &stack_upper); 63 uintptr_t stack_upper = 0;
66 uintptr_t PC = SignalHandler::GetProgramCounter(mcontext); 64 isolate->GetStackBounds(&stack_lower, &stack_upper);
67 uintptr_t FP = SignalHandler::GetFramePointer(mcontext); 65 uintptr_t PC = SignalHandler::GetProgramCounter(mcontext);
68 uintptr_t SP = SignalHandler::GetStackPointer(mcontext); 66 uintptr_t FP = SignalHandler::GetFramePointer(mcontext);
69 int64_t sample_time = OS::GetCurrentTimeMicros(); 67 uintptr_t SP = SignalHandler::GetStackPointer(mcontext);
70 profiler_data->SampledAt(sample_time); 68 int64_t sample_time = OS::GetCurrentTimeMicros();
71 CollectSample(profiler_data, PC, FP, SP, stack_lower, stack_upper); 69 profiler_data->SampledAt(sample_time);
70 CollectSample(profiler_data, PC, FP, SP, stack_lower, stack_upper);
71 }
72 } 72 }
73 // Thread owns no profiler locks at this point. 73 // Thread owns no profiler locks at this point.
74 // This call will acquire both ProfilerManager::monitor and the 74 // This call will acquire both ProfilerManager::monitor and the
75 // isolate's profiler data mutex. 75 // isolate's profiler data mutex.
76 ProfilerManager::ScheduleIsolate(isolate, true); 76 ProfilerManager::ScheduleIsolate(isolate, true);
77 } 77 }
78 78
79 79
80 int64_t ProfilerManager::SampleAndRescheduleIsolates(int64_t current_time) { 80 int64_t ProfilerManager::SampleAndRescheduleIsolates(int64_t current_time) {
81 if (isolates_size_ == 0) { 81 if (isolates_size_ == 0) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 int64_t current_time = OS::GetCurrentTimeMicros(); 134 int64_t current_time = OS::GetCurrentTimeMicros();
135 int64_t next_sample = SampleAndRescheduleIsolates(current_time); 135 int64_t next_sample = SampleAndRescheduleIsolates(current_time);
136 lock.WaitMicros(next_sample); 136 lock.WaitMicros(next_sample);
137 } 137 }
138 } 138 }
139 139
140 140
141 } // namespace dart 141 } // namespace dart
142 142
143 #endif // defined(TARGET_OS_LINUX) 143 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/vm/profiler_android.cc ('k') | runtime/vm/profiler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698