OLD | NEW |
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 Loading... |
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 SampleBuffer* sample_buffer = Profiler::sample_buffer(); | 1054 Isolate* isolate = thread_->isolate(); |
| 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(); |
1055 if (sample_buffer == NULL) { | 1061 if (sample_buffer == NULL) { |
1056 return; | 1062 return; |
1057 } | 1063 } |
1058 samples_ = sample_buffer->BuildProcessedSampleBuffer(filter_); | 1064 samples_ = sample_buffer->BuildProcessedSampleBuffer(filter_); |
1059 profile_->sample_count_ = samples_->length(); | 1065 profile_->sample_count_ = samples_->length(); |
1060 } | 1066 } |
1061 | 1067 |
1062 void UpdateMinMaxTimes(int64_t timestamp) { | 1068 void UpdateMinMaxTimes(int64_t timestamp) { |
1063 profile_->min_time_ = | 1069 profile_->min_time_ = |
1064 timestamp < profile_->min_time_ ? timestamp : profile_->min_time_; | 1070 timestamp < profile_->min_time_ ? timestamp : profile_->min_time_; |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2206 return parent_->NumChildren(); | 2212 return parent_->NumChildren(); |
2207 } | 2213 } |
2208 | 2214 |
2209 | 2215 |
2210 void ProfilerService::PrintJSONImpl(Thread* thread, | 2216 void ProfilerService::PrintJSONImpl(Thread* thread, |
2211 JSONStream* stream, | 2217 JSONStream* stream, |
2212 Profile::TagOrder tag_order, | 2218 Profile::TagOrder tag_order, |
2213 intptr_t extra_tags, | 2219 intptr_t extra_tags, |
2214 SampleFilter* filter) { | 2220 SampleFilter* filter) { |
2215 Isolate* isolate = thread->isolate(); | 2221 Isolate* isolate = thread->isolate(); |
2216 // Disable thread interrupts while processing the buffer. | 2222 // Disable profile interrupts while processing the buffer. |
2217 DisableThreadInterruptsScope dtis(thread); | 2223 Profiler::EndExecution(isolate); |
2218 | 2224 |
2219 SampleBuffer* sample_buffer = Profiler::sample_buffer(); | 2225 { |
2220 if (sample_buffer == NULL) { | 2226 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); |
2221 stream->PrintError(kFeatureDisabled, NULL); | 2227 IsolateProfilerData* profiler_data = isolate->profiler_data(); |
2222 return; | 2228 if (profiler_data == NULL) { |
| 2229 stream->PrintError(kFeatureDisabled, NULL); |
| 2230 return; |
| 2231 } |
2223 } | 2232 } |
2224 | 2233 |
2225 { | 2234 { |
2226 StackZone zone(thread); | 2235 StackZone zone(thread); |
2227 HANDLESCOPE(thread); | 2236 HANDLESCOPE(thread); |
2228 Profile profile(isolate); | 2237 Profile profile(isolate); |
2229 profile.Build(thread, filter, tag_order, extra_tags); | 2238 profile.Build(thread, filter, tag_order, extra_tags); |
2230 profile.PrintJSON(stream); | 2239 profile.PrintJSON(stream); |
2231 } | 2240 } |
| 2241 |
| 2242 // Enable profile interrupts. |
| 2243 Profiler::BeginExecution(isolate); |
2232 } | 2244 } |
2233 | 2245 |
2234 | 2246 |
2235 class NoAllocationSampleFilter : public SampleFilter { | 2247 class NoAllocationSampleFilter : public SampleFilter { |
2236 public: | 2248 public: |
2237 explicit NoAllocationSampleFilter(Isolate* isolate) | 2249 explicit NoAllocationSampleFilter(Isolate* isolate) |
2238 : SampleFilter(isolate) { | 2250 : SampleFilter(isolate) { |
2239 } | 2251 } |
2240 | 2252 |
2241 bool FilterSample(Sample* sample) { | 2253 bool FilterSample(Sample* sample) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2276 Profile::TagOrder tag_order, | 2288 Profile::TagOrder tag_order, |
2277 const Class& cls) { | 2289 const Class& cls) { |
2278 Thread* thread = Thread::Current(); | 2290 Thread* thread = Thread::Current(); |
2279 Isolate* isolate = thread->isolate(); | 2291 Isolate* isolate = thread->isolate(); |
2280 ClassAllocationSampleFilter filter(isolate, cls); | 2292 ClassAllocationSampleFilter filter(isolate, cls); |
2281 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter); | 2293 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter); |
2282 } | 2294 } |
2283 | 2295 |
2284 | 2296 |
2285 void ProfilerService::ClearSamples() { | 2297 void ProfilerService::ClearSamples() { |
2286 SampleBuffer* sample_buffer = Profiler::sample_buffer(); | 2298 Isolate* isolate = Isolate::Current(); |
2287 if (sample_buffer == NULL) { | 2299 |
| 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) { |
2288 return; | 2306 return; |
2289 } | 2307 } |
2290 | 2308 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); |
2291 Thread* thread = Thread::Current(); | 2309 ASSERT(sample_buffer != NULL); |
2292 Isolate* isolate = thread->isolate(); | |
2293 | |
2294 // Disable thread interrupts while processing the buffer. | |
2295 DisableThreadInterruptsScope dtis(thread); | |
2296 | 2310 |
2297 ClearProfileVisitor clear_profile(isolate); | 2311 ClearProfileVisitor clear_profile(isolate); |
2298 sample_buffer->VisitSamples(&clear_profile); | 2312 sample_buffer->VisitSamples(&clear_profile); |
| 2313 |
| 2314 // Enable profile interrupts. |
| 2315 Profiler::BeginExecution(isolate); |
2299 } | 2316 } |
2300 | 2317 |
2301 } // namespace dart | 2318 } // namespace dart |
OLD | NEW |