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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/heap/spaces.h ('k') | src/heap/spaces-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/heap/spaces.h" 5 #include "src/heap/spaces.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 520
521 DCHECK(base == chunk->address()); 521 DCHECK(base == chunk->address());
522 522
523 chunk->heap_ = heap; 523 chunk->heap_ = heap;
524 chunk->size_ = size; 524 chunk->size_ = size;
525 chunk->area_start_ = area_start; 525 chunk->area_start_ = area_start;
526 chunk->area_end_ = area_end; 526 chunk->area_end_ = area_end;
527 chunk->flags_ = Flags(NO_FLAGS); 527 chunk->flags_ = Flags(NO_FLAGS);
528 chunk->set_owner(owner); 528 chunk->set_owner(owner);
529 chunk->InitializeReservedMemory(); 529 chunk->InitializeReservedMemory();
530 chunk->slot_set_[OLD_TO_NEW].SetValue(nullptr); 530 chunk->old_to_new_slots_.SetValue(nullptr);
531 chunk->slot_set_[OLD_TO_OLD].SetValue(nullptr); 531 chunk->old_to_old_slots_ = nullptr;
532 chunk->typed_slot_set_[OLD_TO_NEW].SetValue(nullptr); 532 chunk->typed_old_to_new_slots_.SetValue(nullptr);
533 chunk->typed_slot_set_[OLD_TO_OLD].SetValue(nullptr); 533 chunk->typed_old_to_old_slots_ = nullptr;
534 chunk->skip_list_ = nullptr; 534 chunk->skip_list_ = nullptr;
535 chunk->progress_bar_ = 0; 535 chunk->progress_bar_ = 0;
536 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); 536 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base));
537 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); 537 chunk->concurrent_sweeping_state().SetValue(kSweepingDone);
538 chunk->mutex_ = new base::Mutex(); 538 chunk->mutex_ = new base::Mutex();
539 chunk->available_in_free_list_ = 0; 539 chunk->available_in_free_list_ = 0;
540 chunk->wasted_memory_ = 0; 540 chunk->wasted_memory_ = 0;
541 chunk->ClearLiveness(); 541 chunk->ClearLiveness();
542 chunk->young_generation_bitmap_ = nullptr; 542 chunk->young_generation_bitmap_ = nullptr;
543 chunk->set_next_chunk(nullptr); 543 chunk->set_next_chunk(nullptr);
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 1107
1108 void MemoryChunk::ReleaseAllocatedMemory() { 1108 void MemoryChunk::ReleaseAllocatedMemory() {
1109 if (skip_list_ != nullptr) { 1109 if (skip_list_ != nullptr) {
1110 delete skip_list_; 1110 delete skip_list_;
1111 skip_list_ = nullptr; 1111 skip_list_ = nullptr;
1112 } 1112 }
1113 if (mutex_ != nullptr) { 1113 if (mutex_ != nullptr) {
1114 delete mutex_; 1114 delete mutex_;
1115 mutex_ = nullptr; 1115 mutex_ = nullptr;
1116 } 1116 }
1117 ReleaseSlotSet<OLD_TO_NEW>(); 1117 if (old_to_new_slots_.Value() != nullptr) ReleaseOldToNewSlots();
1118 ReleaseSlotSet<OLD_TO_OLD>(); 1118 if (old_to_old_slots_ != nullptr) ReleaseOldToOldSlots();
1119 ReleaseTypedSlotSet<OLD_TO_NEW>(); 1119 if (typed_old_to_new_slots_.Value() != nullptr) ReleaseTypedOldToNewSlots();
1120 ReleaseTypedSlotSet<OLD_TO_OLD>(); 1120 if (typed_old_to_old_slots_ != nullptr) ReleaseTypedOldToOldSlots();
1121 if (local_tracker_ != nullptr) ReleaseLocalTracker(); 1121 if (local_tracker_ != nullptr) ReleaseLocalTracker();
1122 if (young_generation_bitmap_ != nullptr) ReleaseYoungGenerationBitmap(); 1122 if (young_generation_bitmap_ != nullptr) ReleaseYoungGenerationBitmap();
1123 } 1123 }
1124 1124
1125 static SlotSet* AllocateAndInitializeSlotSet(size_t size, Address page_start) { 1125 static SlotSet* AllocateSlotSet(size_t size, Address page_start) {
1126 size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize; 1126 size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize;
1127 DCHECK(pages > 0); 1127 DCHECK(pages > 0);
1128 SlotSet* slot_set = new SlotSet[pages]; 1128 SlotSet* slot_set = new SlotSet[pages];
1129 for (size_t i = 0; i < pages; i++) { 1129 for (size_t i = 0; i < pages; i++) {
1130 slot_set[i].SetPageStart(page_start + i * Page::kPageSize); 1130 slot_set[i].SetPageStart(page_start + i * Page::kPageSize);
1131 } 1131 }
1132 return slot_set; 1132 return slot_set;
1133 } 1133 }
1134 1134
1135 template SlotSet* MemoryChunk::AllocateSlotSet<OLD_TO_NEW>(); 1135 void MemoryChunk::AllocateOldToNewSlots() {
1136 template SlotSet* MemoryChunk::AllocateSlotSet<OLD_TO_OLD>(); 1136 DCHECK(nullptr == old_to_new_slots_.Value());
1137 1137 old_to_new_slots_.SetValue(AllocateSlotSet(size_, address()));
1138 template <RememberedSetType type>
1139 SlotSet* MemoryChunk::AllocateSlotSet() {
1140 SlotSet* slot_set = AllocateAndInitializeSlotSet(size_, address());
1141 if (!slot_set_[type].TrySetValue(nullptr, slot_set)) {
1142 delete[] slot_set;
1143 slot_set = slot_set_[type].Value();
1144 DCHECK(slot_set);
1145 return slot_set;
1146 }
1147 return slot_set;
1148 } 1138 }
1149 1139
1150 template void MemoryChunk::ReleaseSlotSet<OLD_TO_NEW>(); 1140 void MemoryChunk::ReleaseOldToNewSlots() {
1151 template void MemoryChunk::ReleaseSlotSet<OLD_TO_OLD>(); 1141 SlotSet* old_to_new_slots = old_to_new_slots_.Value();
1152 1142 delete[] old_to_new_slots;
1153 template <RememberedSetType type> 1143 old_to_new_slots_.SetValue(nullptr);
1154 void MemoryChunk::ReleaseSlotSet() {
1155 SlotSet* slot_set = slot_set_[type].Value();
1156 if (slot_set) {
1157 delete[] slot_set;
1158 slot_set_[type].SetValue(nullptr);
1159 }
1160 } 1144 }
1161 1145
1162 template TypedSlotSet* MemoryChunk::AllocateTypedSlotSet<OLD_TO_NEW>(); 1146 void MemoryChunk::AllocateOldToOldSlots() {
1163 template TypedSlotSet* MemoryChunk::AllocateTypedSlotSet<OLD_TO_OLD>(); 1147 DCHECK(nullptr == old_to_old_slots_);
1164 1148 old_to_old_slots_ = AllocateSlotSet(size_, address());
1165 template <RememberedSetType type>
1166 TypedSlotSet* MemoryChunk::AllocateTypedSlotSet() {
1167 TypedSlotSet* slot_set = new TypedSlotSet(address());
1168 if (!typed_slot_set_[type].TrySetValue(nullptr, slot_set)) {
1169 delete slot_set;
1170 slot_set = typed_slot_set_[type].Value();
1171 DCHECK(slot_set);
1172 return slot_set;
1173 }
1174 return slot_set;
1175 } 1149 }
1176 1150
1177 template void MemoryChunk::ReleaseTypedSlotSet<OLD_TO_NEW>(); 1151 void MemoryChunk::ReleaseOldToOldSlots() {
1178 template void MemoryChunk::ReleaseTypedSlotSet<OLD_TO_OLD>(); 1152 delete[] old_to_old_slots_;
1153 old_to_old_slots_ = nullptr;
1154 }
1179 1155
1180 template <RememberedSetType type> 1156 void MemoryChunk::AllocateTypedOldToNewSlots() {
1181 void MemoryChunk::ReleaseTypedSlotSet() { 1157 DCHECK(nullptr == typed_old_to_new_slots_.Value());
1182 TypedSlotSet* typed_slot_set = typed_slot_set_[type].Value(); 1158 typed_old_to_new_slots_.SetValue(new TypedSlotSet(address()));
1183 if (typed_slot_set) { 1159 }
1184 delete typed_slot_set; 1160
1185 typed_slot_set_[type].SetValue(nullptr); 1161 void MemoryChunk::ReleaseTypedOldToNewSlots() {
1186 } 1162 TypedSlotSet* typed_old_to_new_slots = typed_old_to_new_slots_.Value();
1163 delete typed_old_to_new_slots;
1164 typed_old_to_new_slots_.SetValue(nullptr);
1165 }
1166
1167 void MemoryChunk::AllocateTypedOldToOldSlots() {
1168 DCHECK(nullptr == typed_old_to_old_slots_);
1169 typed_old_to_old_slots_ = new TypedSlotSet(address());
1170 }
1171
1172 void MemoryChunk::ReleaseTypedOldToOldSlots() {
1173 delete typed_old_to_old_slots_;
1174 typed_old_to_old_slots_ = nullptr;
1187 } 1175 }
1188 1176
1189 void MemoryChunk::AllocateLocalTracker() { 1177 void MemoryChunk::AllocateLocalTracker() {
1190 DCHECK_NULL(local_tracker_); 1178 DCHECK_NULL(local_tracker_);
1191 local_tracker_ = new LocalArrayBufferTracker(heap()); 1179 local_tracker_ = new LocalArrayBufferTracker(heap());
1192 } 1180 }
1193 1181
1194 void MemoryChunk::ReleaseLocalTracker() { 1182 void MemoryChunk::ReleaseLocalTracker() {
1195 DCHECK_NOT_NULL(local_tracker_); 1183 DCHECK_NOT_NULL(local_tracker_);
1196 delete local_tracker_; 1184 delete local_tracker_;
(...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after
3296 object->ShortPrint(); 3284 object->ShortPrint();
3297 PrintF("\n"); 3285 PrintF("\n");
3298 } 3286 }
3299 printf(" --------------------------------------\n"); 3287 printf(" --------------------------------------\n");
3300 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3288 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3301 } 3289 }
3302 3290
3303 #endif // DEBUG 3291 #endif // DEBUG
3304 } // namespace internal 3292 } // namespace internal
3305 } // namespace v8 3293 } // namespace v8
OLDNEW
« 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