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

Unified Diff: src/heap/heap.cc

Issue 1159513003: Even without --trace-gc dump the last few GC messages on OOM (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 74f4ac1412bebf28f023dbca26da68fc70eced9a..60f7749e79f9e4b3957f9cf1241547135775701f 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -144,6 +144,8 @@ Heap::Heap()
new_space_allocation_counter_(0),
gcs_since_last_deopt_(0),
allocation_sites_scratchpad_length_(0),
+ ring_buffer_full_(false),
+ ring_buffer_end_(0),
promotion_queue_(this),
configured_(false),
external_string_table_(this),
@@ -5260,6 +5262,30 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size,
}
+void Heap::AddToRingBuffer(const char* string) {
+ size_t first_part =
+ Min(strlen(string), kTraceRingBufferSize - ring_buffer_end_);
+ memcpy(trace_ring_buffer_ + ring_buffer_end_, string, first_part);
+ ring_buffer_end_ += first_part;
+ if (first_part < strlen(string)) {
+ ring_buffer_full_ = true;
+ size_t second_part = strlen(string) - first_part;
+ memcpy(trace_ring_buffer_, string + first_part, second_part);
+ ring_buffer_end_ = second_part;
+ }
+}
+
+
+void Heap::GetFromRingBuffer(char* buffer) {
+ size_t copied = 0;
+ if (ring_buffer_full_) {
+ copied = kTraceRingBufferSize - ring_buffer_end_;
+ memcpy(buffer, trace_ring_buffer_ + ring_buffer_end_, copied);
+ }
+ memcpy(buffer + copied, trace_ring_buffer_, ring_buffer_end_);
+}
+
+
bool Heap::ConfigureHeapDefault() { return ConfigureHeap(0, 0, 0, 0); }
@@ -5292,6 +5318,8 @@ void Heap::RecordStats(HeapStats* stats, bool take_snapshot) {
stats->size_per_type[type] += obj->Size();
}
}
+ if (stats->last_few_messages != NULL)
+ GetFromRingBuffer(stats->last_few_messages);
}
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698