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

Unified Diff: src/profiler/sampling-heap-profiler.cc

Issue 1949693003: Sampling heap profiler: Force Full GC before retrieving the profile. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Making the GC optional Created 4 years, 8 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
« include/v8-profiler.h ('K') | « src/profiler/sampling-heap-profiler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/profiler/sampling-heap-profiler.cc
diff --git a/src/profiler/sampling-heap-profiler.cc b/src/profiler/sampling-heap-profiler.cc
index be691fdb515dbb32e1342b10b34221f6cb7f788d..8117a9d5babcb5c082bff17a34fc2139c13f9391 100644
--- a/src/profiler/sampling-heap-profiler.cc
+++ b/src/profiler/sampling-heap-profiler.cc
@@ -47,8 +47,9 @@ v8::AllocationProfile::Allocation SamplingHeapProfiler::ScaleSample(
return {size, static_cast<unsigned int>(count * scale + 0.5)};
}
-SamplingHeapProfiler::SamplingHeapProfiler(Heap* heap, StringsStorage* names,
- uint64_t rate, int stack_depth)
+SamplingHeapProfiler::SamplingHeapProfiler(
+ Heap* heap, StringsStorage* names, uint64_t rate, int stack_depth,
+ v8::HeapProfiler::SamplingFlags flags)
: isolate_(heap->isolate()),
heap_(heap),
new_space_observer_(new SamplingAllocationObserver(
@@ -61,7 +62,8 @@ SamplingHeapProfiler::SamplingHeapProfiler(Heap* heap, StringsStorage* names,
profile_root_(nullptr, "(root)", v8::UnboundScript::kNoScriptId, 0),
samples_(),
stack_depth_(stack_depth),
- rate_(rate) {
+ rate_(rate),
+ flags_(flags) {
CHECK_GT(rate_, 0);
heap->new_space()->AddAllocationObserver(new_space_observer_.get());
AllSpaces spaces(heap);
@@ -256,6 +258,10 @@ v8::AllocationProfile::Node* SamplingHeapProfiler::TranslateAllocationNode(
}
v8::AllocationProfile* SamplingHeapProfiler::GetAllocationProfile() {
+ if (flags_ & v8::HeapProfiler::kSamplingForceGC) {
+ isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags,
+ "SamplingHeapProfiler");
+ }
// To resolve positions to line/column numbers, we will need to look up
// scripts. Build a map to allow fast mapping from script id to script.
std::map<int, Handle<Script>> scripts;
« include/v8-profiler.h ('K') | « src/profiler/sampling-heap-profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698