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

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
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index 05eb239f048cad98093781f36a39cfa1cf5fd97c..ae16bf0637bae0110efaa109202652500673893a 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -466,6 +466,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;
@@ -930,17 +931,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() {
@@ -948,6 +954,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

Powered by Google App Engine
This is Rietveld 408576698