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

Unified Diff: src/spaces-inl.h

Issue 7124006: Two-page newspace. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Address review comments. Created 9 years, 6 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.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/spaces-inl.h
diff --git a/src/spaces-inl.h b/src/spaces-inl.h
index b81bdb0493838a67f52df75a7f271ea5f2f18b00..a1f41d071daf3d17a79c20117dc0bb4ba3c0f9d1 100644
--- a/src/spaces-inl.h
+++ b/src/spaces-inl.h
@@ -60,6 +60,38 @@ Page* PageIterator::next() {
// -----------------------------------------------------------------------------
+// NewSpacePageIterator
+
+
+NewSpacePageIterator::NewSpacePageIterator(SemiSpace* space)
+ : prev_page_(&space->anchor_),
+ next_page_(prev_page_->next_page()),
+ last_page_(prev_page_->prev_page()) { }
+
+ NewSpacePageIterator::NewSpacePageIterator(Address start, Address limit)
+ : prev_page_(NewSpacePage::FromAddress(start)->prev_page()),
+ next_page_(NewSpacePage::FromAddress(start)),
+ last_page_(NewSpacePage::FromLimit(limit)) {
+#ifdef DEBUG
+ SemiSpace::ValidateRange(start, limit);
+#endif
+}
+
+
+bool NewSpacePageIterator::has_next() {
+ return prev_page_ != last_page_;
+}
+
+
+NewSpacePage* NewSpacePageIterator::next() {
+ ASSERT(has_next());
+ prev_page_ = next_page_;
+ next_page_ = next_page_->next_page();
+ return prev_page_;
+}
+
+
+// -----------------------------------------------------------------------------
// HeapObjectIterator
HeapObject* HeapObjectIterator::FromCurrentPage() {
while (cur_addr_ != cur_end_) {
@@ -249,9 +281,10 @@ MaybeObject* PagedSpace::AllocateRaw(int size_in_bytes) {
// NewSpace
MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes) {
- Address new_top = allocation_info_.top + size_in_bytes;
+ Address old_top = allocation_info_.top;
+ Address new_top = old_top + size_in_bytes;
if (new_top > allocation_info_.limit) {
- Address high = to_space_.high();
+ Address high = to_space_.page_high();
if (allocation_info_.limit < high) {
allocation_info_.limit = Min(
allocation_info_.limit + inline_alloction_limit_step_,
@@ -260,6 +293,12 @@ MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes) {
heap()->incremental_marking()->Step(bytes_allocated);
top_on_previous_step_ = new_top;
return AllocateRawInternal(size_in_bytes);
+ } else if (AddFreshPage()) {
+ // Switched to new page. Try allocating again.
+ int bytes_allocated = old_top - top_on_previous_step_;
+ heap()->incremental_marking()->Step(bytes_allocated);
+ top_on_previous_step_ = to_space_.page_low();
+ return AllocateRawInternal(size_in_bytes);
} else {
return Failure::RetryAfterGC();
}
« no previous file with comments | « src/spaces.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698