Chromium Code Reviews| Index: src/spaces.cc |
| diff --git a/src/spaces.cc b/src/spaces.cc |
| index 157458d4680d2064274f730026d76c5b9e269103..ed414fb38bb4fad5db499fee667e6e3cbb514598 100644 |
| --- a/src/spaces.cc |
| +++ b/src/spaces.cc |
| @@ -391,14 +391,20 @@ void Page::InitializeAsAnchor(PagedSpace* owner) { |
| } |
| -NewSpacePage* NewSpacePage::Initialize(Heap* heap, Address start) { |
| +NewSpacePage* NewSpacePage::Initialize(Heap* heap, |
| + Address start, |
| + SemiSpaceId semispace_id) { |
| MemoryChunk* chunk = MemoryChunk::Initialize(heap, |
| start, |
| Page::kPageSize, |
| NOT_EXECUTABLE, |
| heap->new_space()); |
| + chunk->set_next_chunk(NULL); |
| + chunk->set_prev_chunk(NULL); |
| chunk->initialize_scan_on_scavenge(true); |
| chunk->SetFlag(MemoryChunk::IN_NEW_SPACE); |
| + bool in_to_space = (semispace_id != kFromSpace); |
| + chunk->SetFlagTo(MemoryChunk::IN_TO_SPACE, in_to_space); |
| heap->incremental_marking()->SetNewSpacePageFlags(chunk); |
| return static_cast<NewSpacePage*>(chunk); |
| } |
| @@ -932,9 +938,18 @@ void NewSpace::Flip() { |
| from_space_ = to_space_; |
| to_space_ = tmp; |
| - NewSpacePage* old_active_page = from_space_.current_page(); |
| - NewSpacePage* new_active_page = to_space_.current_page(); |
| - new_active_page->CopyFlagsFrom(old_active_page); |
| + // Copy GC flags from old active space (from-space) to new (to-space). |
| + intptr_t flags = from_space_.current_page()->GetFlags(); |
| + // GC related flags. |
| + intptr_t mask = |
| + (1 << MemoryChunk::WAS_SWEPT_CONSERVATIVELY) | |
| + (1 << MemoryChunk::CONTAINS_ONLY_DATA) | |
| + (1 << MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING) | |
| + (1 << MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING) | |
| + (1 << MemoryChunk::SCAN_ON_SCAVENGE); |
|
Lasse Reichstein
2011/05/24 10:54:57
Vyacheslav, is this the correct flags to move? Or
Vyacheslav Egorov (Chromium)
2011/05/24 10:58:47
I think POINTERS_FROM_HERE_ARE_INTERESTING POINTE
Lasse Reichstein
2011/05/24 12:29:03
Reduced and added as constant in NewSpacePage.
|
| + to_space_.Flip(flags, mask); |
| + |
| + from_space_.Flip(0, 0); |
| } |
| @@ -1035,7 +1050,8 @@ bool SemiSpace::Commit() { |
| committed_ = true; |
| // TODO(gc): When more than one page is present, initialize and |
| // chain them all. |
| - current_page_ = NewSpacePage::Initialize(heap(), start_); |
| + SemiSpaceId semispace = is_to_space_ ? kToSpace : kFromSpace; |
| + current_page_ = NewSpacePage::Initialize(heap(), start_, semispace); |
| return true; |
| } |
| @@ -1134,6 +1150,22 @@ bool SemiSpace::ShrinkTo(int new_capacity) { |
| } |
| +void SemiSpace::Flip(intptr_t flags, intptr_t mask) { |
| + is_to_space_ = !is_to_space_; |
|
Erik Corry
2011/05/24 11:25:50
This can be written in terms of GetFlag and SetFla
Lasse Reichstein
2011/05/24 12:29:03
No, it works on the "flags" argument, not the "fla
|
| + intptr_t in_to_space_mask = (1 << MemoryChunk::IN_TO_SPACE); |
| + if (is_to_space_) { |
| + flags |= in_to_space_mask; |
| + } else { |
| + flags &= ~in_to_space_mask; |
| + } |
| + mask |= in_to_space_mask; |
| + NewSpacePage* page = NewSpacePage::FromAddress(start_); |
| + while (page != NULL) { |
| + page->SetFlags(flags, mask); |
| + page = page->next_page(); |
| + } |
| +} |
| + |
| #ifdef DEBUG |
| void SemiSpace::Print() { } |