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 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2297 profile.PrintTimelineJSON(stream); | 2297 profile.PrintTimelineJSON(stream); |
2298 } else { | 2298 } else { |
2299 profile.PrintProfileJSON(stream); | 2299 profile.PrintProfileJSON(stream); |
2300 } | 2300 } |
2301 } | 2301 } |
2302 } | 2302 } |
2303 | 2303 |
2304 | 2304 |
2305 class NoAllocationSampleFilter : public SampleFilter { | 2305 class NoAllocationSampleFilter : public SampleFilter { |
2306 public: | 2306 public: |
2307 explicit NoAllocationSampleFilter(Isolate* isolate) | 2307 NoAllocationSampleFilter(Isolate* isolate, |
2308 : SampleFilter(isolate) { | 2308 int64_t time_origin_micros, |
| 2309 int64_t time_extent_micros) |
| 2310 : SampleFilter(isolate, |
| 2311 time_origin_micros, |
| 2312 time_extent_micros) { |
2309 } | 2313 } |
2310 | 2314 |
2311 bool FilterSample(Sample* sample) { | 2315 bool FilterSample(Sample* sample) { |
2312 return !sample->is_allocation_sample(); | 2316 return !sample->is_allocation_sample(); |
2313 } | 2317 } |
2314 }; | 2318 }; |
2315 | 2319 |
2316 | 2320 |
2317 void ProfilerService::PrintJSON(JSONStream* stream, | 2321 void ProfilerService::PrintJSON(JSONStream* stream, |
2318 Profile::TagOrder tag_order, | 2322 Profile::TagOrder tag_order, |
2319 intptr_t extra_tags) { | 2323 intptr_t extra_tags, |
| 2324 int64_t time_origin_micros, |
| 2325 int64_t time_extent_micros) { |
2320 Thread* thread = Thread::Current(); | 2326 Thread* thread = Thread::Current(); |
2321 Isolate* isolate = thread->isolate(); | 2327 Isolate* isolate = thread->isolate(); |
2322 NoAllocationSampleFilter filter(isolate); | 2328 NoAllocationSampleFilter filter(isolate, |
| 2329 time_origin_micros, |
| 2330 time_extent_micros); |
2323 const bool as_timeline = false; | 2331 const bool as_timeline = false; |
2324 PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter, as_timeline); | 2332 PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter, as_timeline); |
2325 } | 2333 } |
2326 | 2334 |
2327 | 2335 |
2328 class ClassAllocationSampleFilter : public SampleFilter { | 2336 class ClassAllocationSampleFilter : public SampleFilter { |
2329 public: | 2337 public: |
2330 ClassAllocationSampleFilter(Isolate* isolate, const Class& cls) | 2338 ClassAllocationSampleFilter(Isolate* isolate, |
2331 : SampleFilter(isolate), | 2339 const Class& cls, |
| 2340 int64_t time_origin_micros, |
| 2341 int64_t time_extent_micros) |
| 2342 : SampleFilter(isolate, |
| 2343 time_origin_micros, |
| 2344 time_extent_micros), |
2332 cls_(Class::Handle(cls.raw())) { | 2345 cls_(Class::Handle(cls.raw())) { |
2333 ASSERT(!cls_.IsNull()); | 2346 ASSERT(!cls_.IsNull()); |
2334 } | 2347 } |
2335 | 2348 |
2336 bool FilterSample(Sample* sample) { | 2349 bool FilterSample(Sample* sample) { |
2337 return sample->is_allocation_sample() && | 2350 return sample->is_allocation_sample() && |
2338 (sample->allocation_cid() == cls_.id()); | 2351 (sample->allocation_cid() == cls_.id()); |
2339 } | 2352 } |
2340 | 2353 |
2341 private: | 2354 private: |
2342 const Class& cls_; | 2355 const Class& cls_; |
2343 }; | 2356 }; |
2344 | 2357 |
2345 | 2358 |
2346 void ProfilerService::PrintAllocationJSON(JSONStream* stream, | 2359 void ProfilerService::PrintAllocationJSON(JSONStream* stream, |
2347 Profile::TagOrder tag_order, | 2360 Profile::TagOrder tag_order, |
2348 const Class& cls) { | 2361 const Class& cls, |
| 2362 int64_t time_origin_micros, |
| 2363 int64_t time_extent_micros) { |
2349 Thread* thread = Thread::Current(); | 2364 Thread* thread = Thread::Current(); |
2350 Isolate* isolate = thread->isolate(); | 2365 Isolate* isolate = thread->isolate(); |
2351 ClassAllocationSampleFilter filter(isolate, cls); | 2366 ClassAllocationSampleFilter filter(isolate, |
| 2367 cls, |
| 2368 time_origin_micros, |
| 2369 time_extent_micros); |
2352 const bool as_timeline = false; | 2370 const bool as_timeline = false; |
2353 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); | 2371 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); |
2354 } | 2372 } |
2355 | 2373 |
2356 | 2374 |
2357 void ProfilerService::PrintTimelineJSON(JSONStream* stream, | 2375 void ProfilerService::PrintTimelineJSON(JSONStream* stream, |
2358 Profile::TagOrder tag_order) { | 2376 Profile::TagOrder tag_order, |
| 2377 int64_t time_origin_micros, |
| 2378 int64_t time_extent_micros) { |
2359 Thread* thread = Thread::Current(); | 2379 Thread* thread = Thread::Current(); |
2360 Isolate* isolate = thread->isolate(); | 2380 Isolate* isolate = thread->isolate(); |
2361 NoAllocationSampleFilter filter(isolate); | 2381 NoAllocationSampleFilter filter(isolate, |
| 2382 time_origin_micros, |
| 2383 time_extent_micros); |
2362 const bool as_timeline = true; | 2384 const bool as_timeline = true; |
2363 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); | 2385 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); |
2364 } | 2386 } |
2365 | 2387 |
2366 | 2388 |
2367 void ProfilerService::ClearSamples() { | 2389 void ProfilerService::ClearSamples() { |
2368 SampleBuffer* sample_buffer = Profiler::sample_buffer(); | 2390 SampleBuffer* sample_buffer = Profiler::sample_buffer(); |
2369 if (sample_buffer == NULL) { | 2391 if (sample_buffer == NULL) { |
2370 return; | 2392 return; |
2371 } | 2393 } |
2372 | 2394 |
2373 Thread* thread = Thread::Current(); | 2395 Thread* thread = Thread::Current(); |
2374 Isolate* isolate = thread->isolate(); | 2396 Isolate* isolate = thread->isolate(); |
2375 | 2397 |
2376 // Disable thread interrupts while processing the buffer. | 2398 // Disable thread interrupts while processing the buffer. |
2377 DisableThreadInterruptsScope dtis(thread); | 2399 DisableThreadInterruptsScope dtis(thread); |
2378 | 2400 |
2379 ClearProfileVisitor clear_profile(isolate); | 2401 ClearProfileVisitor clear_profile(isolate); |
2380 sample_buffer->VisitSamples(&clear_profile); | 2402 sample_buffer->VisitSamples(&clear_profile); |
2381 } | 2403 } |
2382 | 2404 |
2383 } // namespace dart | 2405 } // namespace dart |
OLD | NEW |