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

Unified Diff: runtime/vm/profiler_service.cc

Issue 1231603008: Expose allocation tracing over service protocol (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/profiler_service.h ('k') | runtime/vm/service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « runtime/vm/profiler_service.h ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698