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); |
} |