summaryrefslogtreecommitdiff
path: root/deps/v8/src
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src')
-rw-r--r--deps/v8/src/heap/heap.cc2
-rw-r--r--deps/v8/src/heap/heap.h6
-rw-r--r--deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc26
-rw-r--r--deps/v8/src/inspector/v8-heap-profiler-agent-impl.h4
-rw-r--r--deps/v8/src/profiler/sampling-heap-profiler.cc13
5 files changed, 47 insertions, 4 deletions
diff --git a/deps/v8/src/heap/heap.cc b/deps/v8/src/heap/heap.cc
index 5a307ff9e1..d966d979c8 100644
--- a/deps/v8/src/heap/heap.cc
+++ b/deps/v8/src/heap/heap.cc
@@ -1819,6 +1819,8 @@ bool Heap::CollectGarbage(AllocationSpace space,
collector = SelectGarbageCollector(space, gc_reason, &collector_reason);
+ current_or_last_garbage_collector_ = collector;
+
if (collector == GarbageCollector::MARK_COMPACTOR &&
incremental_marking()->IsMinorMarking()) {
CollectGarbage(NEW_SPACE, GarbageCollectionReason::kFinalizeMinorMC);
diff --git a/deps/v8/src/heap/heap.h b/deps/v8/src/heap/heap.h
index daca783901..6e270f246d 100644
--- a/deps/v8/src/heap/heap.h
+++ b/deps/v8/src/heap/heap.h
@@ -1455,6 +1455,10 @@ class Heap {
bool is_current_gc_forced() const { return is_current_gc_forced_; }
+ GarbageCollector current_or_last_garbage_collector() const {
+ return current_or_last_garbage_collector_;
+ }
+
// Returns whether the currently in-progress GC should avoid increasing the
// ages on any objects that live for a set number of collections.
bool ShouldCurrentGCKeepAgesUnchanged() const {
@@ -2389,6 +2393,8 @@ class Heap {
bool is_current_gc_forced_ = false;
bool is_current_gc_for_heap_profiler_ = false;
+ GarbageCollector current_or_last_garbage_collector_ =
+ GarbageCollector::SCAVENGER;
ExternalStringTable external_string_table_;
diff --git a/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc b/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc
index 13dfd69bbe..4e8197fdec 100644
--- a/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc
+++ b/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc
@@ -29,6 +29,7 @@ static const char allocationTrackingEnabled[] = "allocationTrackingEnabled";
static const char samplingHeapProfilerEnabled[] = "samplingHeapProfilerEnabled";
static const char samplingHeapProfilerInterval[] =
"samplingHeapProfilerInterval";
+static const char samplingHeapProfilerFlags[] = "samplingHeapProfilerFlags";
} // namespace HeapProfilerAgentState
class HeapSnapshotProgress final : public v8::ActivityControl {
@@ -208,7 +209,16 @@ void V8HeapProfilerAgentImpl::restore() {
double samplingInterval = m_state->doubleProperty(
HeapProfilerAgentState::samplingHeapProfilerInterval, -1);
DCHECK_GE(samplingInterval, 0);
- startSampling(Maybe<double>(samplingInterval));
+ int flags = m_state->integerProperty(
+ HeapProfilerAgentState::samplingHeapProfilerFlags, 0);
+ startSampling(
+ Maybe<double>(samplingInterval),
+ Maybe<bool>(
+ flags &
+ v8::HeapProfiler::kSamplingIncludeObjectsCollectedByMajorGC),
+ Maybe<bool>(
+ flags &
+ v8::HeapProfiler::kSamplingIncludeObjectsCollectedByMinorGC));
}
}
@@ -387,7 +397,9 @@ void V8HeapProfilerAgentImpl::stopTrackingHeapObjectsInternal() {
}
Response V8HeapProfilerAgentImpl::startSampling(
- Maybe<double> samplingInterval) {
+ Maybe<double> samplingInterval,
+ Maybe<bool> includeObjectsCollectedByMajorGC,
+ Maybe<bool> includeObjectsCollectedByMinorGC) {
v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler();
if (!profiler) return Response::ServerError("Cannot access v8 heap profiler");
const unsigned defaultSamplingInterval = 1 << 15;
@@ -400,9 +412,17 @@ Response V8HeapProfilerAgentImpl::startSampling(
samplingIntervalValue);
m_state->setBoolean(HeapProfilerAgentState::samplingHeapProfilerEnabled,
true);
+ int flags = v8::HeapProfiler::kSamplingForceGC;
+ if (includeObjectsCollectedByMajorGC.fromMaybe(false)) {
+ flags |= v8::HeapProfiler::kSamplingIncludeObjectsCollectedByMajorGC;
+ }
+ if (includeObjectsCollectedByMinorGC.fromMaybe(false)) {
+ flags |= v8::HeapProfiler::kSamplingIncludeObjectsCollectedByMinorGC;
+ }
+ m_state->setInteger(HeapProfilerAgentState::samplingHeapProfilerFlags, flags);
profiler->StartSamplingHeapProfiler(
static_cast<uint64_t>(samplingIntervalValue), 128,
- v8::HeapProfiler::kSamplingForceGC);
+ static_cast<v8::HeapProfiler::SamplingFlags>(flags));
return Response::Success();
}
diff --git a/deps/v8/src/inspector/v8-heap-profiler-agent-impl.h b/deps/v8/src/inspector/v8-heap-profiler-agent-impl.h
index 0387a006b8..61c6b6af53 100644
--- a/deps/v8/src/inspector/v8-heap-profiler-agent-impl.h
+++ b/deps/v8/src/inspector/v8-heap-profiler-agent-impl.h
@@ -56,7 +56,9 @@ class V8HeapProfilerAgentImpl : public protocol::HeapProfiler::Backend {
Response getHeapObjectId(const String16& objectId,
String16* heapSnapshotObjectId) override;
- Response startSampling(Maybe<double> samplingInterval) override;
+ Response startSampling(Maybe<double> samplingInterval,
+ Maybe<bool> includeObjectsCollectedByMajorGC,
+ Maybe<bool> includeObjectsCollectedByMinorGC) override;
Response stopSampling(
std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile>*) override;
Response getSamplingProfile(
diff --git a/deps/v8/src/profiler/sampling-heap-profiler.cc b/deps/v8/src/profiler/sampling-heap-profiler.cc
index 45c72ec202..b38d235e98 100644
--- a/deps/v8/src/profiler/sampling-heap-profiler.cc
+++ b/deps/v8/src/profiler/sampling-heap-profiler.cc
@@ -95,6 +95,19 @@ void SamplingHeapProfiler::SampleObject(Address soon_object, size_t size) {
void SamplingHeapProfiler::OnWeakCallback(
const WeakCallbackInfo<Sample>& data) {
Sample* sample = data.GetParameter();
+ Heap* heap = reinterpret_cast<Isolate*>(data.GetIsolate())->heap();
+ bool is_minor_gc =
+ heap->current_or_last_garbage_collector() == GarbageCollector::SCAVENGER;
+ bool should_keep_sample =
+ is_minor_gc
+ ? (sample->profiler->flags_ &
+ v8::HeapProfiler::kSamplingIncludeObjectsCollectedByMinorGC)
+ : (sample->profiler->flags_ &
+ v8::HeapProfiler::kSamplingIncludeObjectsCollectedByMajorGC);
+ if (should_keep_sample) {
+ sample->global.Reset();
+ return;
+ }
AllocationNode* node = sample->owner;
DCHECK_GT(node->allocations_[sample->size], 0);
node->allocations_[sample->size]--;