Index: src/spaces.cc |
diff --git a/src/spaces.cc b/src/spaces.cc |
index 84b0f1bcb49c8191521ad1497aa2d3e67aac8ea3..b82d06c49f21f8d34f4c3a8ae93858cb85cfc1a8 100644 |
--- a/src/spaces.cc |
+++ b/src/spaces.cc |
@@ -1263,11 +1263,16 @@ bool SemiSpace::ShrinkTo(int new_capacity) { |
Address old_start = space_end - capacity_; |
size_t delta = capacity_ - new_capacity; |
ASSERT(IsAligned(delta, OS::AllocateAlignment())); |
- if (!heap()->isolate()->memory_allocator()->UncommitBlock(old_start, delta)) { |
+ if (is_committed() && |
+ !heap()->isolate()->memory_allocator()->UncommitBlock(old_start, delta)) { |
return false; |
} |
capacity_ = new_capacity; |
+ if (!is_committed()) { |
Michael Starzinger
2012/01/04 14:38:28
Can we invert the condition and place the block be
Sven Panne
2012/01/04 14:46:54
Drive-by comment: I *do* like guard clauses, they
|
+ return true; |
+ } |
+ |
int pages_after = capacity_ / Page::kPageSize; |
NewSpacePage* new_last_page = |
NewSpacePage::FromAddress(space_end - pages_after * Page::kPageSize); |