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

Unified Diff: src/heap/spaces.cc

Issue 1683653002: Add a generic remembered set class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/heap/spaces.h ('k') | src/heap/spaces-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index 525c56ff4e6787d5fa671ecb6d68a8fd002d8ace..d58eadc00412f15f1422552adc85ab903a78aea2 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -480,6 +480,7 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size,
chunk->InitializeReservedMemory();
chunk->slots_buffer_ = nullptr;
chunk->old_to_new_slots_ = nullptr;
+ chunk->old_to_old_slots_ = nullptr;
chunk->skip_list_ = nullptr;
chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity;
chunk->progress_bar_ = 0;
@@ -944,17 +945,22 @@ void MemoryChunk::ReleaseAllocatedMemory() {
delete mutex_;
mutex_ = nullptr;
ReleaseOldToNewSlots();
+ ReleaseOldToOldSlots();
}
-void MemoryChunk::AllocateOldToNewSlots() {
- size_t pages = (size_ + Page::kPageSize - 1) / Page::kPageSize;
- DCHECK(owner() == heap_->lo_space() || pages == 1);
+static SlotSet* AllocateSlotSet(size_t size, Address page_start) {
+ size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize;
DCHECK(pages > 0);
- DCHECK(nullptr == old_to_new_slots_);
- old_to_new_slots_ = new SlotSet[pages];
+ SlotSet* slot_set = new SlotSet[pages];
for (size_t i = 0; i < pages; i++) {
- old_to_new_slots_[i].SetPageStart(address() + i * Page::kPageSize);
+ slot_set[i].SetPageStart(page_start + i * Page::kPageSize);
}
+ return slot_set;
+}
+
+void MemoryChunk::AllocateOldToNewSlots() {
+ DCHECK(nullptr == old_to_new_slots_);
+ old_to_new_slots_ = AllocateSlotSet(size_, address());
}
void MemoryChunk::ReleaseOldToNewSlots() {
@@ -962,6 +968,15 @@ void MemoryChunk::ReleaseOldToNewSlots() {
old_to_new_slots_ = nullptr;
}
+void MemoryChunk::AllocateOldToOldSlots() {
+ DCHECK(nullptr == old_to_old_slots_);
+ old_to_old_slots_ = AllocateSlotSet(size_, address());
+}
+
+void MemoryChunk::ReleaseOldToOldSlots() {
+ delete[] old_to_old_slots_;
+ old_to_old_slots_ = nullptr;
+}
// -----------------------------------------------------------------------------
// PagedSpace implementation
« no previous file with comments | « src/heap/spaces.h ('k') | src/heap/spaces-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698