| Index: runtime/vm/profiler_service.cc
|
| diff --git a/runtime/vm/profiler_service.cc b/runtime/vm/profiler_service.cc
|
| index fac0bf4b25fa05d07b0226a5dfd8206f8a58f31a..7ae43a530a20c82b6764b7996b7d39e433ee995e 100644
|
| --- a/runtime/vm/profiler_service.cc
|
| +++ b/runtime/vm/profiler_service.cc
|
| @@ -1964,21 +1964,10 @@ bool ProfileTrieWalker::NextSibling() {
|
| }
|
|
|
|
|
| -class NoAllocationSampleFilter : public SampleFilter {
|
| - public:
|
| - explicit NoAllocationSampleFilter(Isolate* isolate)
|
| - : SampleFilter(isolate) {
|
| - }
|
| -
|
| - bool FilterSample(Sample* sample) {
|
| - return !sample->is_allocation_sample();
|
| - }
|
| -};
|
| -
|
| -
|
| -void ProfilerService::PrintJSON(JSONStream* stream,
|
| - Profile::TagOrder tag_order) {
|
| - Isolate* isolate = Isolate::Current();
|
| +void ProfilerService::PrintJSONImpl(Isolate* isolate,
|
| + JSONStream* stream,
|
| + Profile::TagOrder tag_order,
|
| + SampleFilter* filter) {
|
| // Disable profile interrupts while processing the buffer.
|
| Profiler::EndExecution(isolate);
|
|
|
| @@ -1995,8 +1984,7 @@ void ProfilerService::PrintJSON(JSONStream* stream,
|
| StackZone zone(isolate);
|
| HANDLESCOPE(isolate);
|
| Profile profile(isolate);
|
| - NoAllocationSampleFilter filter(isolate);
|
| - profile.Build(&filter, tag_order);
|
| + profile.Build(filter, tag_order);
|
| profile.PrintJSON(stream);
|
| }
|
|
|
| @@ -2005,6 +1993,53 @@ void ProfilerService::PrintJSON(JSONStream* stream,
|
| }
|
|
|
|
|
| +class NoAllocationSampleFilter : public SampleFilter {
|
| + public:
|
| + explicit NoAllocationSampleFilter(Isolate* isolate)
|
| + : SampleFilter(isolate) {
|
| + }
|
| +
|
| + bool FilterSample(Sample* sample) {
|
| + return !sample->is_allocation_sample();
|
| + }
|
| +};
|
| +
|
| +
|
| +void ProfilerService::PrintJSON(JSONStream* stream,
|
| + Profile::TagOrder tag_order) {
|
| + Isolate* isolate = Isolate::Current();
|
| + NoAllocationSampleFilter filter(isolate);
|
| + PrintJSONImpl(isolate, stream, tag_order, &filter);
|
| +}
|
| +
|
| +
|
| +class ClassAllocationSampleFilter : public SampleFilter {
|
| + public:
|
| + ClassAllocationSampleFilter(Isolate* isolate, const Class& cls)
|
| + : SampleFilter(isolate),
|
| + cls_(Class::Handle(cls.raw())) {
|
| + ASSERT(!cls_.IsNull());
|
| + }
|
| +
|
| + bool FilterSample(Sample* sample) {
|
| + return sample->is_allocation_sample() &&
|
| + (sample->allocation_cid() == cls_.id());
|
| + }
|
| +
|
| + private:
|
| + const Class& cls_;
|
| +};
|
| +
|
| +
|
| +void ProfilerService::PrintAllocationJSON(JSONStream* stream,
|
| + Profile::TagOrder tag_order,
|
| + const Class& cls) {
|
| + Isolate* isolate = Isolate::Current();
|
| + ClassAllocationSampleFilter filter(isolate, cls);
|
| + PrintJSONImpl(isolate, stream, tag_order, &filter);
|
| +}
|
| +
|
| +
|
| void ProfilerService::ClearSamples() {
|
| Isolate* isolate = Isolate::Current();
|
|
|
|
|