OLD | NEW |
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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 | 501 |
502 DCHECK(base == chunk->address()); | 502 DCHECK(base == chunk->address()); |
503 | 503 |
504 chunk->heap_ = heap; | 504 chunk->heap_ = heap; |
505 chunk->size_ = size; | 505 chunk->size_ = size; |
506 chunk->area_start_ = area_start; | 506 chunk->area_start_ = area_start; |
507 chunk->area_end_ = area_end; | 507 chunk->area_end_ = area_end; |
508 chunk->flags_ = Flags(NO_FLAGS); | 508 chunk->flags_ = Flags(NO_FLAGS); |
509 chunk->set_owner(owner); | 509 chunk->set_owner(owner); |
510 chunk->InitializeReservedMemory(); | 510 chunk->InitializeReservedMemory(); |
511 chunk->old_to_new_slots_ = nullptr; | 511 chunk->old_to_new_slots_.SetValue(nullptr); |
512 chunk->old_to_old_slots_ = nullptr; | 512 chunk->old_to_old_slots_ = nullptr; |
513 chunk->typed_old_to_new_slots_.SetValue(nullptr); | 513 chunk->typed_old_to_new_slots_.SetValue(nullptr); |
514 chunk->typed_old_to_old_slots_ = nullptr; | 514 chunk->typed_old_to_old_slots_ = nullptr; |
515 chunk->skip_list_ = nullptr; | 515 chunk->skip_list_ = nullptr; |
516 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; | 516 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; |
517 chunk->progress_bar_ = 0; | 517 chunk->progress_bar_ = 0; |
518 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); | 518 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); |
519 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); | 519 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); |
520 chunk->mutex_ = new base::Mutex(); | 520 chunk->mutex_ = new base::Mutex(); |
521 chunk->available_in_free_list_ = 0; | 521 chunk->available_in_free_list_ = 0; |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 | 1068 |
1069 void MemoryChunk::ReleaseAllocatedMemory() { | 1069 void MemoryChunk::ReleaseAllocatedMemory() { |
1070 if (skip_list_ != nullptr) { | 1070 if (skip_list_ != nullptr) { |
1071 delete skip_list_; | 1071 delete skip_list_; |
1072 skip_list_ = nullptr; | 1072 skip_list_ = nullptr; |
1073 } | 1073 } |
1074 if (mutex_ != nullptr) { | 1074 if (mutex_ != nullptr) { |
1075 delete mutex_; | 1075 delete mutex_; |
1076 mutex_ = nullptr; | 1076 mutex_ = nullptr; |
1077 } | 1077 } |
1078 if (old_to_new_slots_ != nullptr) ReleaseOldToNewSlots(); | 1078 if (old_to_new_slots_.Value() != nullptr) ReleaseOldToNewSlots(); |
1079 if (old_to_old_slots_ != nullptr) ReleaseOldToOldSlots(); | 1079 if (old_to_old_slots_ != nullptr) ReleaseOldToOldSlots(); |
1080 if (typed_old_to_new_slots_.Value() != nullptr) ReleaseTypedOldToNewSlots(); | 1080 if (typed_old_to_new_slots_.Value() != nullptr) ReleaseTypedOldToNewSlots(); |
1081 if (typed_old_to_old_slots_ != nullptr) ReleaseTypedOldToOldSlots(); | 1081 if (typed_old_to_old_slots_ != nullptr) ReleaseTypedOldToOldSlots(); |
1082 if (local_tracker_ != nullptr) ReleaseLocalTracker(); | 1082 if (local_tracker_ != nullptr) ReleaseLocalTracker(); |
1083 } | 1083 } |
1084 | 1084 |
1085 static SlotSet* AllocateSlotSet(size_t size, Address page_start) { | 1085 static SlotSet* AllocateSlotSet(size_t size, Address page_start) { |
1086 size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize; | 1086 size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize; |
1087 DCHECK(pages > 0); | 1087 DCHECK(pages > 0); |
1088 SlotSet* slot_set = new SlotSet[pages]; | 1088 SlotSet* slot_set = new SlotSet[pages]; |
1089 for (size_t i = 0; i < pages; i++) { | 1089 for (size_t i = 0; i < pages; i++) { |
1090 slot_set[i].SetPageStart(page_start + i * Page::kPageSize); | 1090 slot_set[i].SetPageStart(page_start + i * Page::kPageSize); |
1091 } | 1091 } |
1092 return slot_set; | 1092 return slot_set; |
1093 } | 1093 } |
1094 | 1094 |
1095 void MemoryChunk::AllocateOldToNewSlots() { | 1095 void MemoryChunk::AllocateOldToNewSlots() { |
1096 DCHECK(nullptr == old_to_new_slots_); | 1096 DCHECK(nullptr == old_to_new_slots_.Value()); |
1097 old_to_new_slots_ = AllocateSlotSet(size_, address()); | 1097 old_to_new_slots_.SetValue(AllocateSlotSet(size_, address())); |
1098 } | 1098 } |
1099 | 1099 |
1100 void MemoryChunk::ReleaseOldToNewSlots() { | 1100 void MemoryChunk::ReleaseOldToNewSlots() { |
1101 delete[] old_to_new_slots_; | 1101 SlotSet* old_to_new_slots = old_to_new_slots_.Value(); |
1102 old_to_new_slots_ = nullptr; | 1102 delete[] old_to_new_slots; |
| 1103 old_to_new_slots_.SetValue(nullptr); |
1103 } | 1104 } |
1104 | 1105 |
1105 void MemoryChunk::AllocateOldToOldSlots() { | 1106 void MemoryChunk::AllocateOldToOldSlots() { |
1106 DCHECK(nullptr == old_to_old_slots_); | 1107 DCHECK(nullptr == old_to_old_slots_); |
1107 old_to_old_slots_ = AllocateSlotSet(size_, address()); | 1108 old_to_old_slots_ = AllocateSlotSet(size_, address()); |
1108 } | 1109 } |
1109 | 1110 |
1110 void MemoryChunk::ReleaseOldToOldSlots() { | 1111 void MemoryChunk::ReleaseOldToOldSlots() { |
1111 delete[] old_to_old_slots_; | 1112 delete[] old_to_old_slots_; |
1112 old_to_old_slots_ = nullptr; | 1113 old_to_old_slots_ = nullptr; |
(...skipping 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3239 object->ShortPrint(); | 3240 object->ShortPrint(); |
3240 PrintF("\n"); | 3241 PrintF("\n"); |
3241 } | 3242 } |
3242 printf(" --------------------------------------\n"); | 3243 printf(" --------------------------------------\n"); |
3243 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3244 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3244 } | 3245 } |
3245 | 3246 |
3246 #endif // DEBUG | 3247 #endif // DEBUG |
3247 } // namespace internal | 3248 } // namespace internal |
3248 } // namespace v8 | 3249 } // namespace v8 |
OLD | NEW |