Commit 1dd93d96 authored by ulan's avatar ulan Committed by Commit bot

Add flag to print stack-trace after n allocations.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#28161}
parent 00639c75
......@@ -603,6 +603,8 @@ DEFINE_BOOL(print_max_heap_committed, false,
"in name=value format on exit")
DEFINE_BOOL(trace_gc_verbose, false,
"print more details following each garbage collection")
DEFINE_INT(trace_allocation_stack_interval, -1,
"print stack trace after <n> free-list allocations")
DEFINE_BOOL(trace_fragmentation, false, "report fragmentation for old space")
DEFINE_BOOL(trace_fragmentation_verbose, false,
"report fragmentation for old space (detailed)")
......
......@@ -213,9 +213,9 @@ void Heap::OnAllocationEvent(HeapObject* object, int size_in_bytes) {
profiler->AllocationEvent(object->address(), size_in_bytes);
}
if (FLAG_verify_predictable) {
++allocations_count_;
if (FLAG_verify_predictable) {
UpdateAllocationsHash(object);
UpdateAllocationsHash(size_in_bytes);
......@@ -225,6 +225,12 @@ void Heap::OnAllocationEvent(HeapObject* object, int size_in_bytes) {
PrintAlloctionsHash();
}
}
if (FLAG_trace_allocation_stack_interval > 0) {
if (allocations_count_ % FLAG_trace_allocation_stack_interval == 0) {
isolate()->PrintStack(stdout, Isolate::kPrintStackConcise);
}
}
}
......
......@@ -667,14 +667,14 @@ Handle<JSArray> Isolate::CaptureCurrentStackTrace(
}
void Isolate::PrintStack(FILE* out) {
void Isolate::PrintStack(FILE* out, PrintStackMode mode) {
if (stack_trace_nesting_level_ == 0) {
stack_trace_nesting_level_++;
StringStream::ClearMentionedObjectCache(this);
HeapStringAllocator allocator;
StringStream accumulator(&allocator);
incomplete_message_ = &accumulator;
PrintStack(&accumulator);
PrintStack(&accumulator, mode);
accumulator.OutputToFile(out);
InitializeLoggingAndCounters();
accumulator.Log(this);
......@@ -701,7 +701,7 @@ static void PrintFrames(Isolate* isolate,
}
void Isolate::PrintStack(StringStream* accumulator) {
void Isolate::PrintStack(StringStream* accumulator, PrintStackMode mode) {
// The MentionedObjectCache is not GC-proof at the moment.
DisallowHeapAllocation no_gc;
DCHECK(StringStream::IsMentionedObjectCacheClear(this));
......@@ -712,12 +712,12 @@ void Isolate::PrintStack(StringStream* accumulator) {
accumulator->Add(
"\n==== JS stack trace =========================================\n\n");
PrintFrames(this, accumulator, StackFrame::OVERVIEW);
if (mode == kPrintStackVerbose) {
accumulator->Add(
"\n==== Details ================================================\n\n");
PrintFrames(this, accumulator, StackFrame::DETAILS);
accumulator->PrintMentionedObjectCache(this);
}
accumulator->Add("=====================\n\n");
}
......
......@@ -712,9 +712,11 @@ class Isolate {
int frame_limit,
StackTrace::StackTraceOptions options);
enum PrintStackMode { kPrintStackConcise, kPrintStackVerbose };
void PrintCurrentStackTrace(FILE* out);
void PrintStack(StringStream* accumulator);
void PrintStack(FILE* out);
void PrintStack(StringStream* accumulator,
PrintStackMode mode = kPrintStackVerbose);
void PrintStack(FILE* out, PrintStackMode mode = kPrintStackVerbose);
Handle<String> StackTraceString();
NO_INLINE(void PushStackTraceAndDie(unsigned int magic,
Object* object,
......
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