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

Side by Side Diff: runtime/vm/profiler_win.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_macos.cc ('k') | no next file » | 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_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 16
17 static void CollectSample(IsolateProfilerData* profiler_data, 17 static void CollectSample(IsolateProfilerData* profiler_data,
18 uintptr_t pc, 18 uintptr_t pc,
19 uintptr_t fp, 19 uintptr_t fp,
20 uintptr_t stack_lower, 20 uintptr_t stack_lower,
21 uintptr_t stack_upper) { 21 uintptr_t stack_upper) {
22 uintptr_t sp = stack_lower; 22 uintptr_t sp = stack_lower;
23 ASSERT(profiler_data != NULL);
23 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); 24 SampleBuffer* sample_buffer = profiler_data->sample_buffer();
25 ASSERT(sample_buffer != NULL);
24 Sample* sample = sample_buffer->ReserveSample(); 26 Sample* sample = sample_buffer->ReserveSample();
25 ASSERT(sample != NULL); 27 ASSERT(sample != NULL);
26 sample->timestamp = OS::GetCurrentTimeMicros(); 28 sample->timestamp = OS::GetCurrentTimeMicros();
27 // TODO(johnmccutchan): Make real use of vm_tags and runtime_tags. 29 // TODO(johnmccutchan): Make real use of vm_tags and runtime_tags.
28 // Issue # 14777 30 // Issue # 14777
29 sample->vm_tags = Sample::kExecuting; 31 sample->vm_tags = Sample::kExecuting;
30 sample->runtime_tags = 0; 32 sample->runtime_tags = 0;
31 int64_t cpu_usage; 33 int64_t cpu_usage;
32 Thread::GetThreadCpuUsage(profiler_data->thread_id(), &cpu_usage); 34 Thread::GetThreadCpuUsage(profiler_data->thread_id(), &cpu_usage);
33 sample->cpu_usage = profiler_data->ComputeDeltaAndSetCpuUsage(cpu_usage); 35 sample->cpu_usage = profiler_data->ComputeDeltaAndSetCpuUsage(cpu_usage);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 int64_t ProfilerManager::SampleAndRescheduleIsolates(int64_t current_time) { 96 int64_t ProfilerManager::SampleAndRescheduleIsolates(int64_t current_time) {
95 if (isolates_size_ == 0) { 97 if (isolates_size_ == 0) {
96 return 0; 98 return 0;
97 } 99 }
98 static const int64_t max_time = 0x7fffffffffffffffLL; 100 static const int64_t max_time = 0x7fffffffffffffffLL;
99 int64_t lowest = max_time; 101 int64_t lowest = max_time;
100 for (intptr_t i = 0; i < isolates_size_; i++) { 102 for (intptr_t i = 0; i < isolates_size_; i++) {
101 Isolate* isolate = isolates_[i]; 103 Isolate* isolate = isolates_[i];
102 ScopedMutex isolate_lock(isolate->profiler_data_mutex()); 104 ScopedMutex isolate_lock(isolate->profiler_data_mutex());
103 IsolateProfilerData* profiler_data = isolate->profiler_data(); 105 IsolateProfilerData* profiler_data = isolate->profiler_data();
104 ASSERT(profiler_data != NULL); 106 if ((profiler_data == NULL) || !profiler_data->CanExpire() ||
107 (profiler_data->sample_buffer() == NULL)) {
108 // Descheduled.
109 continue;
110 }
105 if (profiler_data->ShouldSample(current_time)) { 111 if (profiler_data->ShouldSample(current_time)) {
106 SuspendAndSample(isolate, profiler_data); 112 SuspendAndSample(isolate, profiler_data);
107 Reschedule(profiler_data); 113 Reschedule(profiler_data);
108 } 114 }
109 if (profiler_data->CanExpire()) { 115 if (profiler_data->CanExpire()) {
110 int64_t isolate_time_left = 116 int64_t isolate_time_left =
111 profiler_data->TimeUntilExpiration(current_time); 117 profiler_data->TimeUntilExpiration(current_time);
112 if (isolate_time_left < 0) { 118 if (isolate_time_left < 0) {
113 continue; 119 continue;
114 } 120 }
(...skipping 21 matching lines...) Expand all
136 while (!shutdown_) { 142 while (!shutdown_) {
137 int64_t current_time = OS::GetCurrentTimeMicros(); 143 int64_t current_time = OS::GetCurrentTimeMicros();
138 int64_t next_sample = SampleAndRescheduleIsolates(current_time); 144 int64_t next_sample = SampleAndRescheduleIsolates(current_time);
139 lock.WaitMicros(next_sample); 145 lock.WaitMicros(next_sample);
140 } 146 }
141 } 147 }
142 148
143 } // namespace dart 149 } // namespace dart
144 150
145 #endif // defined(TARGET_OS_WINDOWS) 151 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/vm/profiler_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698