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

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

Issue 1423473004: Switch profiler from isolates to threads [second landing] (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
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/profiler_test.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) 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 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2212 return parent_->NumChildren(); 2206 return parent_->NumChildren();
2213 } 2207 }
2214 2208
2215 2209
2216 void ProfilerService::PrintJSONImpl(Thread* thread, 2210 void ProfilerService::PrintJSONImpl(Thread* thread,
2217 JSONStream* stream, 2211 JSONStream* stream,
2218 Profile::TagOrder tag_order, 2212 Profile::TagOrder tag_order,
2219 intptr_t extra_tags, 2213 intptr_t extra_tags,
2220 SampleFilter* filter) { 2214 SampleFilter* filter) {
2221 Isolate* isolate = thread->isolate(); 2215 Isolate* isolate = thread->isolate();
2222 // Disable profile interrupts while processing the buffer. 2216 // Disable thread interrupts while processing the buffer.
2223 Profiler::EndExecution(isolate); 2217 DisableThreadInterruptsScope dtis(thread);
2224 2218
2225 { 2219 SampleBuffer* sample_buffer = Profiler::sample_buffer();
2226 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); 2220 if (sample_buffer == NULL) {
2227 IsolateProfilerData* profiler_data = isolate->profiler_data(); 2221 stream->PrintError(kFeatureDisabled, NULL);
2228 if (profiler_data == NULL) { 2222 return;
2229 stream->PrintError(kFeatureDisabled, NULL);
2230 return;
2231 }
2232 } 2223 }
2233 2224
2234 { 2225 {
2235 StackZone zone(thread); 2226 StackZone zone(thread);
2236 HANDLESCOPE(thread); 2227 HANDLESCOPE(thread);
2237 Profile profile(isolate); 2228 Profile profile(isolate);
2238 profile.Build(thread, filter, tag_order, extra_tags); 2229 profile.Build(thread, filter, tag_order, extra_tags);
2239 profile.PrintJSON(stream); 2230 profile.PrintJSON(stream);
2240 } 2231 }
2241
2242 // Enable profile interrupts.
2243 Profiler::BeginExecution(isolate);
2244 } 2232 }
2245 2233
2246 2234
2247 class NoAllocationSampleFilter : public SampleFilter { 2235 class NoAllocationSampleFilter : public SampleFilter {
2248 public: 2236 public:
2249 explicit NoAllocationSampleFilter(Isolate* isolate) 2237 explicit NoAllocationSampleFilter(Isolate* isolate)
2250 : SampleFilter(isolate) { 2238 : SampleFilter(isolate) {
2251 } 2239 }
2252 2240
2253 bool FilterSample(Sample* sample) { 2241 bool FilterSample(Sample* sample) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2288 Profile::TagOrder tag_order, 2276 Profile::TagOrder tag_order,
2289 const Class& cls) { 2277 const Class& cls) {
2290 Thread* thread = Thread::Current(); 2278 Thread* thread = Thread::Current();
2291 Isolate* isolate = thread->isolate(); 2279 Isolate* isolate = thread->isolate();
2292 ClassAllocationSampleFilter filter(isolate, cls); 2280 ClassAllocationSampleFilter filter(isolate, cls);
2293 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter); 2281 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter);
2294 } 2282 }
2295 2283
2296 2284
2297 void ProfilerService::ClearSamples() { 2285 void ProfilerService::ClearSamples() {
2298 Isolate* isolate = Isolate::Current(); 2286 SampleBuffer* sample_buffer = Profiler::sample_buffer();
2299 2287 if (sample_buffer == NULL) {
2300 // Disable profile interrupts while processing the buffer.
2301 Profiler::EndExecution(isolate);
2302
2303 MutexLocker profiler_data_lock(isolate->profiler_data_mutex());
2304 IsolateProfilerData* profiler_data = isolate->profiler_data();
2305 if (profiler_data == NULL) {
2306 return; 2288 return;
2307 } 2289 }
2308 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); 2290
2309 ASSERT(sample_buffer != NULL); 2291 Thread* thread = Thread::Current();
2292 Isolate* isolate = thread->isolate();
2293
2294 // Disable thread interrupts while processing the buffer.
2295 DisableThreadInterruptsScope dtis(thread);
2310 2296
2311 ClearProfileVisitor clear_profile(isolate); 2297 ClearProfileVisitor clear_profile(isolate);
2312 sample_buffer->VisitSamples(&clear_profile); 2298 sample_buffer->VisitSamples(&clear_profile);
2313
2314 // Enable profile interrupts.
2315 Profiler::BeginExecution(isolate);
2316 } 2299 }
2317 2300
2318 } // namespace dart 2301 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/profiler_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698