Commit 66ca91b9 authored by ulan's avatar ulan Committed by Commit bot

Add historgram for number of GC needed to collect a detached context.

BUG=

Review URL: https://codereview.chromium.org/934773002

Cr-Commit-Position: refs/heads/master@{#26690}
parent cc1458a9
......@@ -360,6 +360,7 @@ class AggregatedHistogramTimerScope {
#define HISTOGRAM_RANGE_LIST(HR) \
/* Generic range histograms */ \
HR(detached_context_age_in_gc, V8.DetachedContextAgeInGC, 0, 20, 21) \
HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \
HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \
HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, \
......
......@@ -620,8 +620,11 @@ DEFINE_BOOL(trace_incremental_marking, false,
"trace progress of the incremental marking")
DEFINE_BOOL(track_gc_object_stats, false,
"track object counts and memory usage")
DEFINE_BOOL(track_detached_contexts, false,
DEFINE_BOOL(track_detached_contexts, true,
"track native contexts that are expected to be garbage collected")
DEFINE_BOOL(trace_detached_contexts, false,
"trace native contexts that are expected to be garbage collected")
DEFINE_IMPLICATION(trace_detached_contexts, track_detached_contexts)
#ifdef VERIFY_HEAP
DEFINE_BOOL(verify_heap, false, "verify heap pointers before and after GC")
#endif
......
......@@ -2598,21 +2598,25 @@ void Isolate::CheckDetachedContextsAfterGC() {
detached_contexts->set(new_length, Smi::FromInt(mark_sweeps + 1));
detached_contexts->set(new_length + 1, cell);
new_length += 2;
} else {
counters()->detached_context_age_in_gc()->AddSample(mark_sweeps);
}
}
PrintF("%d detached contexts are collected out of %d\n", length - new_length,
length);
for (int i = 0; i < new_length; i += 2) {
int mark_sweeps = Smi::cast(detached_contexts->get(i))->value();
WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1));
if (mark_sweeps > 3) {
PrintF("detached context 0x%p\n survived %d GCs (leak?)\n",
static_cast<void*>(cell->value()), mark_sweeps);
if (FLAG_trace_detached_contexts) {
PrintF("%d detached contexts are collected out of %d\n",
length - new_length, length);
for (int i = 0; i < new_length; i += 2) {
int mark_sweeps = Smi::cast(detached_contexts->get(i))->value();
WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1));
if (mark_sweeps > 3) {
PrintF("detached context 0x%p\n survived %d GCs (leak?)\n",
static_cast<void*>(cell->value()), mark_sweeps);
}
}
}
if (length == new_length) {
if (new_length == 0) {
heap()->set_detached_contexts(heap()->empty_fixed_array());
} else {
} else if (new_length < length) {
heap()->RightTrimFixedArray<Heap::FROM_GC>(*detached_contexts,
length - new_length);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment