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

Unified Diff: src/spaces.cc

Issue 8055029: Add experimental support for tracing the state of the VM heap to a file Base URL: http://v8.googlecode.com/svn/branches/experimental/heap-visualization/
Patch Set: Created 9 years, 3 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
« src/spaces.h ('K') | « src/spaces.h ('k') | src/spaces-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/spaces.cc
===================================================================
--- src/spaces.cc (revision 9457)
+++ src/spaces.cc (working copy)
@@ -444,6 +444,24 @@
if (owner == heap->old_data_space()) chunk->SetFlag(CONTAINS_ONLY_DATA);
+ if (owner != NULL) {
Vyacheslav Egorov (Chromium) 2011/09/28 15:21:11 Move out of the spaces.cc to some visualizer speci
+ for (HeapVisualizer* vis = heap->visualizer();
+ vis != NULL;
+ vis = vis->next()) {
+ int space_id = executable ? CODE_SPACE : owner->identity();
+ vis->Name(space_id,
+ reinterpret_cast<uintptr_t>(chunk->body()),
+ size - (chunk->body() - chunk->address()));
+ vis->Name(HeapVisualizer::kHeapOverheadPseudoSpaceIdentity,
+ reinterpret_cast<uintptr_t>(base),
+ (chunk->body() - chunk->address()));
+ if (owner == heap->lo_space()) {
+ // Large pages are all allocated all the time, no need to track.
+ vis->ConstantAllocation(reinterpret_cast<uintptr_t>(base), size, 0);
+ }
+ }
+ }
+
return chunk;
}
@@ -461,6 +479,13 @@
heap_->decrement_scan_on_scavenge_pages();
ClearFlag(SCAN_ON_SCAVENGE);
}
+ for (HeapVisualizer* vis = heap_->visualizer();
+ vis != NULL;
Vyacheslav Egorov (Chromium) 2011/09/28 15:21:11 ditto
+ vis = vis->next()) {
+ vis->ConstantAllocation(reinterpret_cast<uintptr_t>(address()),
+ size(),
+ 255);
+ }
next_chunk_->prev_chunk_ = prev_chunk_;
prev_chunk_->next_chunk_ = next_chunk_;
prev_chunk_ = NULL;
@@ -666,6 +691,7 @@
Executability executable)
: Space(heap, id, executable),
free_list_(this),
+ last_visualized_top_(NULL),
was_swept_conservatively_(false),
first_unswept_page_(Page::FromAddress(NULL)),
last_unswept_page_(Page::FromAddress(NULL)) {
@@ -673,8 +699,7 @@
* Page::kObjectAreaSize;
accounting_stats_.Clear();
- allocation_info_.top = NULL;
- allocation_info_.limit = NULL;
+ SetTop(NULL, NULL);
anchor_.InitializeAsAnchor(this);
}
@@ -910,7 +935,41 @@
}
+void NewSpace::VisualizeUnallocation(SemiSpace* semispace) {
+ for (NewSpacePage* page = semispace->first_page();
+ !page->is_anchor();
Vyacheslav Egorov (Chromium) 2011/09/28 15:21:11 ditto
+ page = page->next_page()) {
+ uint32_t address = reinterpret_cast<uintptr_t>(page->ObjectAreaStart());
+ uintptr_t end = reinterpret_cast<uintptr_t>(page->ObjectAreaEnd());
+ for (HeapVisualizer* vis = heap()->visualizer();
+ vis != NULL;
+ vis = vis->next()) {
+ vis->ConstantAllocation(address, end - address, 255);
+ }
+ }
+}
+
+
+void NewSpace::VisualizeTop() {
+ if (last_visualized_top_ != NULL) {
+ uintptr_t last = reinterpret_cast<uintptr_t>(last_visualized_top_);
+ uintptr_t next = reinterpret_cast<uintptr_t>(allocation_info_.top);
+ for (HeapVisualizer* vis = heap()->visualizer();
+ vis != NULL;
+ vis = vis->next()) {
+ int pix = vis->pixel_size_log_2();
+ if (next >> pix != last >> pix) {
+ vis->ConstantAllocation(
+ last, ((next >> pix) - (last >> pix)) << pix, 0);
+ }
+ }
+ }
+ last_visualized_top_ = allocation_info_.top;
+}
+
+
void NewSpace::Flip() {
+ VisualizeUnallocation(&to_space_);
SemiSpace::Swap(&from_space_, &to_space_);
}
@@ -961,6 +1020,8 @@
allocation_info_.top = to_space_.page_low();
allocation_info_.limit = to_space_.page_high();
+ last_visualized_top_ = allocation_info_.top;
+
// Lower limit during incremental marking.
if (heap()->incremental_marking()->IsMarking() &&
inline_allocation_limit_step() != 0) {
@@ -1002,6 +1063,7 @@
// Clear remainder of current page.
int remaining_in_page =
static_cast<int>(NewSpacePage::FromLimit(top)->body_limit() - top);
+ VisualizeTop();
heap()->CreateFillerObjectAt(top, remaining_in_page);
pages_used_++;
UpdateAllocationInfo();
@@ -1825,6 +1887,46 @@
}
+void PagedSpace::VisualizeTopChange(Address new_top) {
+ if (heap()->has_visualizer()) {
+ if (last_visualized_top_ == NULL) {
+ last_visualized_top_ = new_top;
+ return;
+ }
+ uintptr_t last = reinterpret_cast<uintptr_t>(last_visualized_top_);
+ uintptr_t next = reinterpret_cast<uintptr_t>(allocation_info_.top);
+ ASSERT(next >= last);
+ if (next > last) {
+ for (HeapVisualizer* vis = heap()->visualizer();
+ vis != NULL;
+ vis = vis->next()) {
+ int bits = vis->pixel_size_log_2();
+ uintptr_t last_pixel = last >> bits;
+ uintptr_t next_pixel = next >> bits;
+ if ((last_pixel << bits) != last) {
+ if (next_pixel == last_pixel) {
+ vis->ChangeAllocation(last, next - last);
+ continue;
+ }
+ last_pixel++;
+ vis->ChangeAllocation(last, (last_pixel << bits) - last);
+ last = last_pixel << bits;
+ }
+ if (next_pixel > last_pixel) {
+ vis->ConstantAllocation(last_pixel << bits,
+ (next_pixel - last_pixel) << bits,
+ 0);
+ }
+ if (last_pixel << bits != last) {
+ vis->ChangeAllocation(last, (last_pixel << bits) - last);
+ }
+ }
+ }
+ }
+ last_visualized_top_ = new_top;
+}
+
+
static intptr_t CountFreeListItemsInList(FreeListNode* n, Page* p) {
intptr_t sum = 0;
while (n != NULL) {
@@ -1858,6 +1960,19 @@
}
+// This can take a very long time because it is linear in the number of entries
+// on the free list, so it should not be called if FreeListLength returns
+// kVeryLongFreeList.
+intptr_t FreeList::SumFreeLists() {
+ intptr_t sum = SumFreeList(small_list_);
+ sum += SumFreeList(medium_list_);
+ sum += SumFreeList(large_list_);
+ sum += SumFreeList(huge_list_);
+ return sum;
+}
+#endif
+
+
static const int kVeryLongFreeList = 500;
@@ -1881,19 +1996,6 @@
}
-// This can take a very long time because it is linear in the number of entries
-// on the free list, so it should not be called if FreeListLength returns
-// kVeryLongFreeList.
-intptr_t FreeList::SumFreeLists() {
- intptr_t sum = SumFreeList(small_list_);
- sum += SumFreeList(medium_list_);
- sum += SumFreeList(large_list_);
- sum += SumFreeList(huge_list_);
- return sum;
-}
-#endif
-
-
// -----------------------------------------------------------------------------
// OldSpace implementation
@@ -2012,8 +2114,7 @@
static_cast<int>(allocation_info_.limit - allocation_info_.top);
heap()->CreateFillerObjectAt(allocation_info_.top, remaining);
- allocation_info_.top = NULL;
- allocation_info_.limit = NULL;
+ SetTop(NULL, NULL);
}
}
« src/spaces.h ('K') | « src/spaces.h ('k') | src/spaces-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698