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

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, 2 months 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 MutexLocker profiler_data_lock(isolate_->profiler_data_mutex()); 1054 SampleBuffer* sample_buffer = Profiler::sample_buffer();
1055 IsolateProfilerData* profiler_data = isolate_->profiler_data();
1056 if (profiler_data == NULL) {
1057 return;
1058 }
1059 SampleBuffer* sample_buffer = profiler_data->sample_buffer();
1060 if (sample_buffer == NULL) { 1055 if (sample_buffer == NULL) {
1061 return; 1056 return;
1062 } 1057 }
1063 samples_ = sample_buffer->BuildProcessedSampleBuffer(filter_); 1058 samples_ = sample_buffer->BuildProcessedSampleBuffer(filter_);
1064 profile_->sample_count_ = samples_->length(); 1059 profile_->sample_count_ = samples_->length();
1065 } 1060 }
1066 1061
1067 void UpdateMinMaxTimes(int64_t timestamp) { 1062 void UpdateMinMaxTimes(int64_t timestamp) {
1068 profile_->min_time_ = 1063 profile_->min_time_ =
1069 timestamp < profile_->min_time_ ? timestamp : profile_->min_time_; 1064 timestamp < profile_->min_time_ ? timestamp : profile_->min_time_;
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 2191
2197 void ProfilerService::PrintJSONImpl(Thread* thread, 2192 void ProfilerService::PrintJSONImpl(Thread* thread,
2198 JSONStream* stream, 2193 JSONStream* stream,
2199 Profile::TagOrder tag_order, 2194 Profile::TagOrder tag_order,
2200 intptr_t extra_tags, 2195 intptr_t extra_tags,
2201 SampleFilter* filter) { 2196 SampleFilter* filter) {
2202 Isolate* isolate = thread->isolate(); 2197 Isolate* isolate = thread->isolate();
2203 // Disable profile interrupts while processing the buffer. 2198 // Disable profile interrupts while processing the buffer.
2204 Profiler::EndExecution(isolate); 2199 Profiler::EndExecution(isolate);
2205 2200
2206 { 2201 SampleBuffer* sample_buffer = Profiler::sample_buffer();
2207 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); 2202 if (sample_buffer == NULL) {
2208 IsolateProfilerData* profiler_data = isolate->profiler_data(); 2203 stream->PrintError(kFeatureDisabled, NULL);
2209 if (profiler_data == NULL) { 2204 return;
2210 stream->PrintError(kFeatureDisabled, NULL);
2211 return;
2212 }
2213 } 2205 }
2214 2206
2215 { 2207 {
2216 StackZone zone(thread); 2208 StackZone zone(thread);
2217 HANDLESCOPE(thread); 2209 HANDLESCOPE(thread);
2218 Profile profile(isolate); 2210 Profile profile(isolate);
2219 profile.Build(filter, tag_order, extra_tags); 2211 profile.Build(filter, tag_order, extra_tags);
2220 profile.PrintJSON(stream); 2212 profile.PrintJSON(stream);
2221 } 2213 }
2222 2214
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter); 2266 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter);
2275 } 2267 }
2276 2268
2277 2269
2278 void ProfilerService::ClearSamples() { 2270 void ProfilerService::ClearSamples() {
2279 Isolate* isolate = Isolate::Current(); 2271 Isolate* isolate = Isolate::Current();
2280 2272
2281 // Disable profile interrupts while processing the buffer. 2273 // Disable profile interrupts while processing the buffer.
2282 Profiler::EndExecution(isolate); 2274 Profiler::EndExecution(isolate);
2283 2275
2284 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); 2276 SampleBuffer* sample_buffer = Profiler::sample_buffer();
2285 IsolateProfilerData* profiler_data = isolate->profiler_data(); 2277 if (sample_buffer == NULL) {
2286 if (profiler_data == NULL) {
2287 return; 2278 return;
2288 } 2279 }
2289 SampleBuffer* sample_buffer = profiler_data->sample_buffer();
2290 ASSERT(sample_buffer != NULL);
2291 2280
2292 ClearProfileVisitor clear_profile(isolate); 2281 ClearProfileVisitor clear_profile(isolate);
2293 sample_buffer->VisitSamples(&clear_profile); 2282 sample_buffer->VisitSamples(&clear_profile);
2294 2283
2295 // Enable profile interrupts. 2284 // Enable profile interrupts.
2296 Profiler::BeginExecution(isolate); 2285 Profiler::BeginExecution(isolate);
2297 } 2286 }
2298 2287
2299 } // namespace dart 2288 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698