| 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 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 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2195 return parent_->NumChildren(); | 2189 return parent_->NumChildren(); |
| 2196 } | 2190 } |
| 2197 | 2191 |
| 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 thread interrupts while processing the buffer. |
| 2206 Profiler::EndExecution(isolate); | 2200 DisableThreadInterruptsScope dtis(thread); |
| 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 | |
| 2225 // Enable profile interrupts. | |
| 2226 Profiler::BeginExecution(isolate); | |
| 2227 } | 2215 } |
| 2228 | 2216 |
| 2229 | 2217 |
| 2230 class NoAllocationSampleFilter : public SampleFilter { | 2218 class NoAllocationSampleFilter : public SampleFilter { |
| 2231 public: | 2219 public: |
| 2232 explicit NoAllocationSampleFilter(Isolate* isolate) | 2220 explicit NoAllocationSampleFilter(Isolate* isolate) |
| 2233 : SampleFilter(isolate) { | 2221 : SampleFilter(isolate) { |
| 2234 } | 2222 } |
| 2235 | 2223 |
| 2236 bool FilterSample(Sample* sample) { | 2224 bool FilterSample(Sample* sample) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2271 Profile::TagOrder tag_order, | 2259 Profile::TagOrder tag_order, |
| 2272 const Class& cls) { | 2260 const Class& cls) { |
| 2273 Thread* thread = Thread::Current(); | 2261 Thread* thread = Thread::Current(); |
| 2274 Isolate* isolate = thread->isolate(); | 2262 Isolate* isolate = thread->isolate(); |
| 2275 ClassAllocationSampleFilter filter(isolate, cls); | 2263 ClassAllocationSampleFilter filter(isolate, cls); |
| 2276 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter); | 2264 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter); |
| 2277 } | 2265 } |
| 2278 | 2266 |
| 2279 | 2267 |
| 2280 void ProfilerService::ClearSamples() { | 2268 void ProfilerService::ClearSamples() { |
| 2281 Isolate* isolate = Isolate::Current(); | 2269 SampleBuffer* sample_buffer = Profiler::sample_buffer(); |
| 2282 | 2270 if (sample_buffer == NULL) { |
| 2283 // Disable profile interrupts while processing the buffer. | |
| 2284 Profiler::EndExecution(isolate); | |
| 2285 | |
| 2286 MutexLocker profiler_data_lock(isolate->profiler_data_mutex()); | |
| 2287 IsolateProfilerData* profiler_data = isolate->profiler_data(); | |
| 2288 if (profiler_data == NULL) { | |
| 2289 return; | 2271 return; |
| 2290 } | 2272 } |
| 2291 SampleBuffer* sample_buffer = profiler_data->sample_buffer(); | 2273 |
| 2292 ASSERT(sample_buffer != NULL); | 2274 Thread* thread = Thread::Current(); |
| 2275 Isolate* isolate = thread->isolate(); |
| 2276 |
| 2277 // Disable thread interrupts while processing the buffer. |
| 2278 DisableThreadInterruptsScope dtis(thread); |
| 2293 | 2279 |
| 2294 ClearProfileVisitor clear_profile(isolate); | 2280 ClearProfileVisitor clear_profile(isolate); |
| 2295 sample_buffer->VisitSamples(&clear_profile); | 2281 sample_buffer->VisitSamples(&clear_profile); |
| 2296 | |
| 2297 // Enable profile interrupts. | |
| 2298 Profiler::BeginExecution(isolate); | |
| 2299 } | 2282 } |
| 2300 | 2283 |
| 2301 } // namespace dart | 2284 } // namespace dart |
| OLD | NEW |