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

Unified Diff: src/heap/spaces.cc

Issue 2773093002: Revert "[heap] Make SlotSet allocation thread-safe and refactor code." (Closed)
Patch Set: Created 3 years, 9 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 5202200bf75874621776337c2e89824a9382de6c..d322916a5dc0a9cbc2957f961f407f11976d32b2 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -527,10 +527,10 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size,
chunk->flags_ = Flags(NO_FLAGS);
chunk->set_owner(owner);
chunk->InitializeReservedMemory();
- chunk->slot_set_[OLD_TO_NEW].SetValue(nullptr);
- chunk->slot_set_[OLD_TO_OLD].SetValue(nullptr);
- chunk->typed_slot_set_[OLD_TO_NEW].SetValue(nullptr);
- chunk->typed_slot_set_[OLD_TO_OLD].SetValue(nullptr);
+ chunk->old_to_new_slots_.SetValue(nullptr);
+ chunk->old_to_old_slots_ = nullptr;
+ chunk->typed_old_to_new_slots_.SetValue(nullptr);
+ chunk->typed_old_to_old_slots_ = nullptr;
chunk->skip_list_ = nullptr;
chunk->progress_bar_ = 0;
chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base));
@@ -1114,15 +1114,15 @@ void MemoryChunk::ReleaseAllocatedMemory() {
delete mutex_;
mutex_ = nullptr;
}
- ReleaseSlotSet<OLD_TO_NEW>();
- ReleaseSlotSet<OLD_TO_OLD>();
- ReleaseTypedSlotSet<OLD_TO_NEW>();
- ReleaseTypedSlotSet<OLD_TO_OLD>();
+ if (old_to_new_slots_.Value() != nullptr) ReleaseOldToNewSlots();
+ if (old_to_old_slots_ != nullptr) ReleaseOldToOldSlots();
+ if (typed_old_to_new_slots_.Value() != nullptr) ReleaseTypedOldToNewSlots();
+ if (typed_old_to_old_slots_ != nullptr) ReleaseTypedOldToOldSlots();
if (local_tracker_ != nullptr) ReleaseLocalTracker();
if (young_generation_bitmap_ != nullptr) ReleaseYoungGenerationBitmap();
}
-static SlotSet* AllocateAndInitializeSlotSet(size_t size, Address page_start) {
+static SlotSet* AllocateSlotSet(size_t size, Address page_start) {
size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize;
DCHECK(pages > 0);
SlotSet* slot_set = new SlotSet[pages];
@@ -1132,58 +1132,46 @@ static SlotSet* AllocateAndInitializeSlotSet(size_t size, Address page_start) {
return slot_set;
}
-template SlotSet* MemoryChunk::AllocateSlotSet<OLD_TO_NEW>();
-template SlotSet* MemoryChunk::AllocateSlotSet<OLD_TO_OLD>();
+void MemoryChunk::AllocateOldToNewSlots() {
+ DCHECK(nullptr == old_to_new_slots_.Value());
+ old_to_new_slots_.SetValue(AllocateSlotSet(size_, address()));
+}
-template <RememberedSetType type>
-SlotSet* MemoryChunk::AllocateSlotSet() {
- SlotSet* slot_set = AllocateAndInitializeSlotSet(size_, address());
- if (!slot_set_[type].TrySetValue(nullptr, slot_set)) {
- delete[] slot_set;
- slot_set = slot_set_[type].Value();
- DCHECK(slot_set);
- return slot_set;
- }
- return slot_set;
+void MemoryChunk::ReleaseOldToNewSlots() {
+ SlotSet* old_to_new_slots = old_to_new_slots_.Value();
+ delete[] old_to_new_slots;
+ old_to_new_slots_.SetValue(nullptr);
}
-template void MemoryChunk::ReleaseSlotSet<OLD_TO_NEW>();
-template void MemoryChunk::ReleaseSlotSet<OLD_TO_OLD>();
+void MemoryChunk::AllocateOldToOldSlots() {
+ DCHECK(nullptr == old_to_old_slots_);
+ old_to_old_slots_ = AllocateSlotSet(size_, address());
+}
-template <RememberedSetType type>
-void MemoryChunk::ReleaseSlotSet() {
- SlotSet* slot_set = slot_set_[type].Value();
- if (slot_set) {
- delete[] slot_set;
- slot_set_[type].SetValue(nullptr);
- }
+void MemoryChunk::ReleaseOldToOldSlots() {
+ delete[] old_to_old_slots_;
+ old_to_old_slots_ = nullptr;
}
-template TypedSlotSet* MemoryChunk::AllocateTypedSlotSet<OLD_TO_NEW>();
-template TypedSlotSet* MemoryChunk::AllocateTypedSlotSet<OLD_TO_OLD>();
+void MemoryChunk::AllocateTypedOldToNewSlots() {
+ DCHECK(nullptr == typed_old_to_new_slots_.Value());
+ typed_old_to_new_slots_.SetValue(new TypedSlotSet(address()));
+}
-template <RememberedSetType type>
-TypedSlotSet* MemoryChunk::AllocateTypedSlotSet() {
- TypedSlotSet* slot_set = new TypedSlotSet(address());
- if (!typed_slot_set_[type].TrySetValue(nullptr, slot_set)) {
- delete slot_set;
- slot_set = typed_slot_set_[type].Value();
- DCHECK(slot_set);
- return slot_set;
- }
- return slot_set;
+void MemoryChunk::ReleaseTypedOldToNewSlots() {
+ TypedSlotSet* typed_old_to_new_slots = typed_old_to_new_slots_.Value();
+ delete typed_old_to_new_slots;
+ typed_old_to_new_slots_.SetValue(nullptr);
}
-template void MemoryChunk::ReleaseTypedSlotSet<OLD_TO_NEW>();
-template void MemoryChunk::ReleaseTypedSlotSet<OLD_TO_OLD>();
+void MemoryChunk::AllocateTypedOldToOldSlots() {
+ DCHECK(nullptr == typed_old_to_old_slots_);
+ typed_old_to_old_slots_ = new TypedSlotSet(address());
+}
-template <RememberedSetType type>
-void MemoryChunk::ReleaseTypedSlotSet() {
- TypedSlotSet* typed_slot_set = typed_slot_set_[type].Value();
- if (typed_slot_set) {
- delete typed_slot_set;
- typed_slot_set_[type].SetValue(nullptr);
- }
+void MemoryChunk::ReleaseTypedOldToOldSlots() {
+ delete typed_old_to_old_slots_;
+ typed_old_to_old_slots_ = nullptr;
}
void MemoryChunk::AllocateLocalTracker() {
« 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