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

Unified Diff: src/spaces.cc

Issue 7983001: Fix new space shrinking to compute correct capacity. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Vyacheslav Egorov. 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
« no previous file with comments | « src/spaces.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index 9aacf9603e42ada46f2c1953d1453695dfdeb3f8..c46faf883023087f577196b7ad75f341ba86b389 100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -924,10 +924,12 @@ void NewSpace::Flip() {
void NewSpace::Grow() {
+ // Double the semispace size but only up to maximum capacity.
ASSERT(Capacity() < MaximumCapacity());
- if (to_space_.Grow()) {
+ int new_capacity = Min(MaximumCapacity(), 2 * static_cast<int>(Capacity()));
+ if (to_space_.GrowTo(new_capacity)) {
// Only grow from space if we managed to grow to-space.
- if (!from_space_.Grow()) {
+ if (!from_space_.GrowTo(new_capacity)) {
// If we managed to grow to-space but couldn't grow from-space,
// attempt to shrink to-space.
if (!to_space_.ShrinkTo(from_space_.Capacity())) {
@@ -943,8 +945,7 @@ void NewSpace::Grow() {
void NewSpace::Shrink() {
int new_capacity = Max(InitialCapacity(), 2 * SizeAsInt());
- int rounded_new_capacity =
- RoundUp(new_capacity, static_cast<int>(OS::AllocateAlignment()));
+ int rounded_new_capacity = RoundUp(new_capacity, Page::kPageSize);
if (rounded_new_capacity < Capacity() &&
to_space_.ShrinkTo(rounded_new_capacity)) {
// Only shrink from-space if we managed to shrink to-space.
@@ -1144,15 +1145,6 @@ bool SemiSpace::Uncommit() {
}
-bool SemiSpace::Grow() {
- // Double the semispace size but only up to maximum capacity.
- ASSERT(static_cast<size_t>(Page::kPageSize) > OS::AllocateAlignment());
- int new_capacity = Min(maximum_capacity_,
- RoundUp(capacity_ * 2, static_cast<int>(Page::kPageSize)));
- return GrowTo(new_capacity);
-}
-
-
bool SemiSpace::GrowTo(int new_capacity) {
ASSERT((new_capacity & Page::kPageAlignmentMask) == 0);
ASSERT(new_capacity <= maximum_capacity_);
@@ -1209,7 +1201,7 @@ bool SemiSpace::ShrinkTo(int new_capacity) {
NewSpacePage::FromAddress(space_end - pages_after * Page::kPageSize);
new_last_page->set_next_page(anchor());
anchor()->set_prev_page(new_last_page);
- ASSERT(current_page_ == first_page());
+ ASSERT((current_page_ <= first_page()) && (current_page_ >= new_last_page));
return true;
}
« no previous file with comments | « src/spaces.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698