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

Unified Diff: runtime/vm/profiler_service.cc

Issue 2966593002: Updated native memory allocation profiling to use its own sample buffer instead of sharing a sample… (Closed)
Patch Set: Created 3 years, 6 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
Index: runtime/vm/profiler_service.cc
diff --git a/runtime/vm/profiler_service.cc b/runtime/vm/profiler_service.cc
index 3b8a8cd05a036356a07e8be1691edfbaa0ffa329..0d5ae847113741c767d789fc821242413b2c7374 100644
--- a/runtime/vm/profiler_service.cc
+++ b/runtime/vm/profiler_service.cc
@@ -1217,12 +1217,14 @@ class ProfileBuilder : public ValueObject {
ProfileBuilder(Thread* thread,
SampleFilter* filter,
+ SampleBuffer* sample_buffer,
Profile::TagOrder tag_order,
intptr_t extra_tags,
Profile* profile)
: thread_(thread),
vm_isolate_(Dart::vm_isolate()),
filter_(filter),
+ sample_buffer_(sample_buffer),
tag_order_(tag_order),
extra_tags_(extra_tags),
profile_(profile),
@@ -1233,6 +1235,8 @@ class ProfileBuilder : public ValueObject {
inclusive_tree_(false),
samples_(NULL),
info_kind_(kNone) {
+ ASSERT((sample_buffer_ == Profiler::sample_buffer()) ||
+ (sample_buffer_ == Profiler::allocation_sample_buffer()));
ASSERT(profile_ != NULL);
}
@@ -1284,11 +1288,7 @@ class ProfileBuilder : public ValueObject {
bool FilterSamples() {
ScopeTimer sw("ProfileBuilder::FilterSamples", FLAG_trace_profiler);
- SampleBuffer* sample_buffer = Profiler::sample_buffer();
- if (sample_buffer == NULL) {
- return false;
- }
- samples_ = sample_buffer->BuildProcessedSampleBuffer(filter_);
+ samples_ = sample_buffer_->BuildProcessedSampleBuffer(filter_);
zra 2017/06/30 18:49:17 Retain the NULL check, or ASSERT non-null.
bkonyi 2017/07/05 18:20:52 Done.
profile_->samples_ = samples_;
profile_->sample_count_ = samples_->length();
return true;
@@ -2330,6 +2330,7 @@ class ProfileBuilder : public ValueObject {
Thread* thread_;
Isolate* vm_isolate_;
SampleFilter* filter_;
+ SampleBuffer* sample_buffer_;
Profile::TagOrder tag_order_;
intptr_t extra_tags_;
Profile* profile_;
@@ -2365,9 +2366,11 @@ Profile::Profile(Isolate* isolate)
void Profile::Build(Thread* thread,
SampleFilter* filter,
+ SampleBuffer* sample_buffer,
TagOrder tag_order,
intptr_t extra_tags) {
- ProfileBuilder builder(thread, filter, tag_order, extra_tags, this);
+ ProfileBuilder builder(thread, filter, sample_buffer, tag_order, extra_tags,
+ this);
builder.Build();
}
@@ -2748,12 +2751,12 @@ void ProfilerService::PrintJSONImpl(Thread* thread,
Profile::TagOrder tag_order,
intptr_t extra_tags,
SampleFilter* filter,
+ SampleBuffer* sample_buffer,
bool as_timeline) {
Isolate* isolate = thread->isolate();
// Disable thread interrupts while processing the buffer.
DisableThreadInterruptsScope dtis(thread);
- SampleBuffer* sample_buffer = Profiler::sample_buffer();
if (sample_buffer == NULL) {
stream->PrintError(kFeatureDisabled, NULL);
return;
@@ -2763,7 +2766,7 @@ void ProfilerService::PrintJSONImpl(Thread* thread,
StackZone zone(thread);
HANDLESCOPE(thread);
Profile profile(isolate);
- profile.Build(thread, filter, tag_order, extra_tags);
+ profile.Build(thread, filter, sample_buffer, tag_order, extra_tags);
if (as_timeline) {
profile.PrintTimelineJSON(stream);
} else {
@@ -2784,10 +2787,7 @@ class NoAllocationSampleFilter : public SampleFilter {
time_origin_micros,
time_extent_micros) {}
- bool FilterSample(Sample* sample) {
- return !sample->is_allocation_sample() &&
- !sample->is_native_allocation_sample();
- }
+ bool FilterSample(Sample* sample) { return !sample->is_allocation_sample(); }
};
@@ -2801,7 +2801,8 @@ void ProfilerService::PrintJSON(JSONStream* stream,
NoAllocationSampleFilter filter(isolate->main_port(), Thread::kMutatorTask,
time_origin_micros, time_extent_micros);
const bool as_timeline = false;
- PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter, as_timeline);
+ PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter,
+ Profiler::sample_buffer(), as_timeline);
}
@@ -2841,7 +2842,8 @@ void ProfilerService::PrintAllocationJSON(JSONStream* stream,
Thread::kMutatorTask, time_origin_micros,
time_extent_micros);
const bool as_timeline = false;
- PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline);
+ PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter,
+ Profiler::sample_buffer(), as_timeline);
}
@@ -2852,7 +2854,8 @@ void ProfilerService::PrintNativeAllocationJSON(JSONStream* stream,
Thread* thread = Thread::Current();
NativeAllocationSampleFilter filter(time_origin_micros, time_extent_micros);
const bool as_timeline = false;
- PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline);
+ PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter,
+ Profiler::allocation_sample_buffer(), as_timeline);
}
@@ -2868,7 +2871,8 @@ void ProfilerService::PrintTimelineJSON(JSONStream* stream,
NoAllocationSampleFilter filter(isolate->main_port(), thread_task_mask,
time_origin_micros, time_extent_micros);
const bool as_timeline = true;
- PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline);
+ PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter,
+ Profiler::sample_buffer(), as_timeline);
}

Powered by Google App Engine
This is Rietveld 408576698