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

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

Issue 1412733008: Switch profiler from isolates to threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 "vm/profiler_service.h" 5 #include "vm/profiler_service.h"
6 6
7 #include "vm/growable_array.h" 7 #include "vm/growable_array.h"
8 #include "vm/native_symbol.h" 8 #include "vm/native_symbol.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 RegisterProfileCodeTag(VMTag::kNoneCodeTagId); 1044 RegisterProfileCodeTag(VMTag::kNoneCodeTagId);
1045 RegisterProfileCodeTag(VMTag::kOptimizedCodeTagId); 1045 RegisterProfileCodeTag(VMTag::kOptimizedCodeTagId);
1046 RegisterProfileCodeTag(VMTag::kUnoptimizedCodeTagId); 1046 RegisterProfileCodeTag(VMTag::kUnoptimizedCodeTagId);
1047 RegisterProfileCodeTag(VMTag::kNativeCodeTagId); 1047 RegisterProfileCodeTag(VMTag::kNativeCodeTagId);
1048 RegisterProfileCodeTag(VMTag::kInlineStartCodeTagId); 1048 RegisterProfileCodeTag(VMTag::kInlineStartCodeTagId);
1049 RegisterProfileCodeTag(VMTag::kInlineEndCodeTagId); 1049 RegisterProfileCodeTag(VMTag::kInlineEndCodeTagId);
1050 } 1050 }
1051 1051
1052 void FilterSamples() { 1052 void FilterSamples() {
1053 ScopeTimer sw("ProfileBuilder::FilterSamples", FLAG_trace_profiler); 1053 ScopeTimer sw("ProfileBuilder::FilterSamples", FLAG_trace_profiler);
1054 Isolate* isolate = thread_->isolate(); 1054 SampleBuffer* sample_buffer = Profiler::sample_buffer();
1055 MutexLocker profiler_data_lock(isolate->profiler_data_mutex());
1056 IsolateProfilerData* profiler_data = isolate->profiler_data();
1057 if (profiler_data == NULL) {
1058 return;
1059 }
1060 SampleBuffer* sample_buffer = profiler_data->sample_buffer();
1061 if (sample_buffer == NULL) { 1055 if (sample_buffer == NULL) {
1062 return; 1056 return;
1063 } 1057 }
1064 samples_ = sample_buffer->BuildProcessedSampleBuffer(filter_); 1058 samples_ = sample_buffer->BuildProcessedSampleBuffer(filter_);
1065 profile_->sample_count_ = samples_->length(); 1059 profile_->sample_count_ = samples_->length();
1066 } 1060 }
1067 1061
1068 void UpdateMinMaxTimes(int64_t timestamp) { 1062 void UpdateMinMaxTimes(int64_t timestamp) {
1069 profile_->min_time_ = 1063 profile_->min_time_ =
1070 timestamp < profile_->min_time_ ? timestamp : profile_->min_time_; 1064 timestamp < profile_->min_time_ ? timestamp : profile_->min_time_;
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 2192
2199 void ProfilerService::PrintJSONImpl(Thread* thread, 2193 void ProfilerService::PrintJSONImpl(Thread* thread,
2200 JSONStream* stream, 2194 JSONStream* stream,
2201 Profile::TagOrder tag_order, 2195 Profile::TagOrder tag_order,
2202 intptr_t extra_tags, 2196 intptr_t extra_tags,
2203 SampleFilter* filter) { 2197 SampleFilter* filter) {
2204 Isolate* isolate = thread->isolate(); 2198 Isolate* isolate = thread->isolate();
2205 // Disable profile interrupts while processing the buffer. 2199 // Disable profile interrupts while processing the buffer.
2206 Profiler::EndExecution(isolate); 2200 Profiler::EndExecution(isolate);
2207 2201
2208 { 2202 SampleBuffer* sample_buffer = Profiler::sample_buffer();
2209 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); 2203 if (sample_buffer == NULL) {
2210 IsolateProfilerData* profiler_data = isolate->profiler_data(); 2204 stream->PrintError(kFeatureDisabled, NULL);
2211 if (profiler_data == NULL) { 2205 return;
2212 stream->PrintError(kFeatureDisabled, NULL);
2213 return;
2214 }
2215 } 2206 }
2216 2207
2217 { 2208 {
2218 StackZone zone(thread); 2209 StackZone zone(thread);
2219 HANDLESCOPE(thread); 2210 HANDLESCOPE(thread);
2220 Profile profile(isolate); 2211 Profile profile(isolate);
2221 profile.Build(thread, filter, tag_order, extra_tags); 2212 profile.Build(thread, filter, tag_order, extra_tags);
2222 profile.PrintJSON(stream); 2213 profile.PrintJSON(stream);
2223 } 2214 }
2224 2215
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter); 2267 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter);
2277 } 2268 }
2278 2269
2279 2270
2280 void ProfilerService::ClearSamples() { 2271 void ProfilerService::ClearSamples() {
2281 Isolate* isolate = Isolate::Current(); 2272 Isolate* isolate = Isolate::Current();
2282 2273
2283 // Disable profile interrupts while processing the buffer. 2274 // Disable profile interrupts while processing the buffer.
2284 Profiler::EndExecution(isolate); 2275 Profiler::EndExecution(isolate);
2285 2276
2286 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); 2277 SampleBuffer* sample_buffer = Profiler::sample_buffer();
2287 IsolateProfilerData* profiler_data = isolate->profiler_data(); 2278 if (sample_buffer == NULL) {
2288 if (profiler_data == NULL) {
2289 return; 2279 return;
2290 } 2280 }
2291 SampleBuffer* sample_buffer = profiler_data->sample_buffer();
2292 ASSERT(sample_buffer != NULL);
2293 2281
2294 ClearProfileVisitor clear_profile(isolate); 2282 ClearProfileVisitor clear_profile(isolate);
2295 sample_buffer->VisitSamples(&clear_profile); 2283 sample_buffer->VisitSamples(&clear_profile);
2296 2284
2297 // Enable profile interrupts. 2285 // Enable profile interrupts.
2298 Profiler::BeginExecution(isolate); 2286 Profiler::BeginExecution(isolate);
2299 } 2287 }
2300 2288
2301 } // namespace dart 2289 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698