Chromium Code Reviews| Index: src/heap/spaces.cc |
| diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc |
| index 4d726eee5af31efca0749cc4207c2935cca99d4c..941b0d16070cc833740f07cd780288f04a31401c 100644 |
| --- a/src/heap/spaces.cc |
| +++ b/src/heap/spaces.cc |
| @@ -1312,9 +1312,6 @@ bool NewSpace::SetUp(int reserved_semispace_capacity, |
| DCHECK(!from_space_.is_committed()); // No need to use memory yet. |
| start_ = chunk_base_; |
| - address_mask_ = ~(2 * reserved_semispace_capacity - 1); |
| - object_mask_ = address_mask_ | kHeapObjectTagMask; |
| - object_expected_ = reinterpret_cast<uintptr_t>(start_) | kHeapObjectTag; |
| ResetAllocationInfo(); |
| @@ -1675,9 +1672,6 @@ void SemiSpace::SetUp(Address start, int initial_capacity, |
| maximum_capacity_ = RoundDown(maximum_capacity, Page::kPageSize); |
| committed_ = false; |
| start_ = start; |
| - address_mask_ = ~(maximum_capacity_ - 1); |
| - object_mask_ = address_mask_ | kHeapObjectTagMask; |
| - object_expected_ = reinterpret_cast<uintptr_t>(start) | kHeapObjectTag; |
| age_mark_ = start_ + NewSpacePage::kObjectStartOffset; |
| } |
| @@ -1803,21 +1797,18 @@ bool SemiSpace::ShrinkTo(int new_capacity) { |
| return true; |
| } |
| - |
| -void SemiSpace::FlipPages(intptr_t flags, intptr_t mask) { |
| +void SemiSpace::FixPages(intptr_t flags, intptr_t mask) { |
|
Hannes Payer (out of office)
2016/02/08 16:05:40
FixPagesFlags?
Michael Lippautz
2016/02/08 18:00:38
Done.
|
| anchor_.set_owner(this); |
| // Fixup back-pointers to anchor. Address of anchor changes when we swap. |
| anchor_.prev_page()->set_next_page(&anchor_); |
| anchor_.next_page()->set_prev_page(&anchor_); |
| - bool becomes_to_space = (id_ == kFromSpace); |
| - id_ = becomes_to_space ? kToSpace : kFromSpace; |
| NewSpacePageIterator it(this); |
| while (it.has_next()) { |
| NewSpacePage* page = it.next(); |
| page->set_owner(this); |
| page->SetFlags(flags, mask); |
| - if (becomes_to_space) { |
| + if (id_ == kToSpace) { |
| page->ClearFlag(MemoryChunk::IN_FROM_SPACE); |
| page->SetFlag(MemoryChunk::IN_TO_SPACE); |
| page->ClearFlag(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK); |
| @@ -1844,19 +1835,20 @@ void SemiSpace::Swap(SemiSpace* from, SemiSpace* to) { |
| DCHECK_NE(from->anchor_.next_page(), &from->anchor_); |
| DCHECK_NE(to->anchor_.next_page(), &to->anchor_); |
| - // Swap bits. |
| - SemiSpace tmp = *from; |
|
Michael Lippautz
2016/02/05 12:44:40
Let's move this to explicit code (std::swap), to a
|
| - *from = *to; |
| - *to = tmp; |
| + intptr_t saved_to_space_flags = to->current_page()->GetFlags(); |
| - // Fixup back-pointers to the page list anchor now that its address |
| - // has changed. |
| - // Swap to/from-space bits on pages. |
| - // Copy GC flags from old active space (from-space) to new (to-space). |
| - intptr_t flags = from->current_page()->GetFlags(); |
| - to->FlipPages(flags, NewSpacePage::kCopyOnFlipFlagsMask); |
| + // We swap all properties but id_. |
| + std::swap(from->current_capacity_, to->current_capacity_); |
|
ulan
2016/02/09 13:36:50
Let's extract it into separate function and put it
Michael Lippautz
2016/02/09 14:50:28
As discussed offline: This is already Swap(), and
|
| + std::swap(from->maximum_capacity_, to->maximum_capacity_); |
| + std::swap(from->minimum_capacity_, to->minimum_capacity_); |
| + std::swap(from->start_, to->start_); |
| + std::swap(from->age_mark_, to->age_mark_); |
| + std::swap(from->committed_, to->committed_); |
| + std::swap(from->anchor_, to->anchor_); |
| + std::swap(from->current_page_, to->current_page_); |
| - from->FlipPages(0, 0); |
| + to->FixPages(saved_to_space_flags, NewSpacePage::kCopyOnFlipFlagsMask); |
| + from->FixPages(0, 0); |
| } |