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

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: 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..a1bc3b9d80886afdb878685d28d0aec62391d4dd 100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -924,10 +924,14 @@ void NewSpace::Flip() {
void NewSpace::Grow() {
+ // Double the semispace size but only up to maximum capacity.
ASSERT(Capacity() < MaximumCapacity());
- if (to_space_.Grow()) {
+ ASSERT(static_cast<size_t>(Page::kPageSize) > OS::AllocateAlignment());
Vyacheslav Egorov (Chromium) 2011/09/20 14:26:40 I don't think we really need this assert here. The
Michael Starzinger 2011/09/20 15:29:03 Done.
+ int new_capacity = Min(MaximumCapacity(), 2 * static_cast<int>(Capacity()));
Vyacheslav Egorov (Chromium) 2011/09/20 14:26:40 We should ensure that MaxCapacity & Capacity is _a
Michael Starzinger 2011/09/20 15:29:03 Done. I just checked that it is only modified in a
+ int rounded_new_capacity = RoundUp(new_capacity, Page::kPageSize);
+ if (to_space_.GrowTo(rounded_new_capacity)) {
// Only grow from space if we managed to grow to-space.
- if (!from_space_.Grow()) {
+ if (!from_space_.GrowTo(rounded_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())) {
@@ -942,9 +946,9 @@ void NewSpace::Grow() {
void NewSpace::Shrink() {
+ ASSERT(static_cast<size_t>(Page::kPageSize) > OS::AllocateAlignment());
Vyacheslav Egorov (Chromium) 2011/09/20 14:26:40 I don't think we really need this assert here. The
Michael Starzinger 2011/09/20 15:29:03 Done.
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 +1148,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_);
« 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