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

Unified Diff: src/spaces.cc

Issue 555072: Merge ObjectIterator::has_next and ObjectIterator::next methods.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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/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 3683)
+++ src/spaces.cc (working copy)
@@ -82,8 +82,8 @@
}
-bool HeapObjectIterator::HasNextInNextPage() {
- if (cur_addr_ == end_addr_) return false;
+HeapObject* HeapObjectIterator::FromNextPage() {
+ if (cur_addr_ == end_addr_) return NULL;
Page* cur_page = Page::FromAllocationTop(cur_addr_);
cur_page = cur_page->next_page();
@@ -92,12 +92,12 @@
cur_addr_ = cur_page->ObjectAreaStart();
cur_limit_ = (cur_page == end_page_) ? end_addr_ : cur_page->AllocationTop();
- if (cur_addr_ == end_addr_) return false;
+ if (cur_addr_ == end_addr_) return NULL;
ASSERT(cur_addr_ < cur_limit_);
#ifdef DEBUG
Verify();
#endif
- return true;
+ return FromCurrentPage();
}
@@ -1437,7 +1437,8 @@
void NewSpace::CollectStatistics() {
ClearHistograms();
SemiSpaceIterator it(this);
- while (it.has_next()) RecordAllocation(it.next());
+ for (HeapObject* obj = it.next(); obj != NULL; obj = it.next())
+ RecordAllocation(obj);
}
@@ -2054,8 +2055,7 @@
// - by code comment
void PagedSpace::CollectCodeStatistics() {
HeapObjectIterator obj_it(this);
- while (obj_it.has_next()) {
- HeapObject* obj = obj_it.next();
+ for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) {
if (obj->IsCode()) {
Code* code = Code::cast(obj);
code_kind_statistics[code->kind()] += code->Size();
@@ -2157,7 +2157,8 @@
ClearHistograms();
HeapObjectIterator obj_it(this);
- while (obj_it.has_next()) { CollectHistogramInfo(obj_it.next()); }
+ for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next())
+ CollectHistogramInfo(obj);
ReportHistogram(true);
}
@@ -2393,7 +2394,8 @@
ClearHistograms();
HeapObjectIterator obj_it(this);
- while (obj_it.has_next()) { CollectHistogramInfo(obj_it.next()); }
+ for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next())
+ CollectHistogramInfo(obj);
ReportHistogram(false);
}
@@ -2462,7 +2464,8 @@
HeapObject* LargeObjectIterator::next() {
- ASSERT(has_next());
+ if (current_ == NULL) return NULL;
+
HeapObject* object = current_->GetObject();
current_ = current_->next();
return object;
@@ -2639,8 +2642,7 @@
ASSERT(Page::is_rset_in_use());
LargeObjectIterator it(this);
- while (it.has_next()) {
- HeapObject* object = it.next();
+ for (HeapObject* object = it.next(); object != NULL; object = it.next()) {
// We only have code, sequential strings, or fixed arrays in large
// object space, and only fixed arrays need remembered set support.
if (object->IsFixedArray()) {
@@ -2668,11 +2670,10 @@
30);
LargeObjectIterator it(this);
- while (it.has_next()) {
+ for (HeapObject* object = it.next(); object != NULL; object = it.next()) {
// We only have code, sequential strings, or fixed arrays in large
// object space, and only fixed arrays can possibly contain pointers to
// the young generation.
- HeapObject* object = it.next();
if (object->IsFixedArray()) {
// Iterate the normal page remembered set range.
Page* page = Page::FromAddress(object->address());
@@ -2798,8 +2799,8 @@
void LargeObjectSpace::Print() {
LargeObjectIterator it(this);
- while (it.has_next()) {
- it.next()->Print();
+ for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) {
+ obj->Print();
}
}
@@ -2809,9 +2810,9 @@
int num_objects = 0;
ClearHistograms();
LargeObjectIterator it(this);
- while (it.has_next()) {
+ for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) {
num_objects++;
- CollectHistogramInfo(it.next());
+ CollectHistogramInfo(obj);
}
PrintF(" number of objects %d\n", num_objects);
@@ -2821,8 +2822,7 @@
void LargeObjectSpace::CollectCodeStatistics() {
LargeObjectIterator obj_it(this);
- while (obj_it.has_next()) {
- HeapObject* obj = obj_it.next();
+ for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) {
if (obj->IsCode()) {
Code* code = Code::cast(obj);
code_kind_statistics[code->kind()] += code->Size();
@@ -2833,8 +2833,7 @@
void LargeObjectSpace::PrintRSet() {
LargeObjectIterator it(this);
- while (it.has_next()) {
- HeapObject* object = it.next();
+ for (HeapObject* object = it.next(); object != NULL; object = it.next()) {
if (object->IsFixedArray()) {
Page* page = Page::FromAddress(object->address());
« no previous file with comments | « src/spaces.h ('k') | src/spaces-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698