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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_ = nullptr; |
512 chunk->old_to_old_slots_ = nullptr; | 512 chunk->old_to_old_slots_ = nullptr; |
513 chunk->typed_old_to_new_slots_ = 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; |
522 chunk->wasted_memory_ = 0; | 522 chunk->wasted_memory_ = 0; |
523 chunk->ResetLiveBytes(); | 523 chunk->ResetLiveBytes(); |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_ != 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_ != 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); |
(...skipping 15 matching lines...) Expand all Loading... |
1106 DCHECK(nullptr == old_to_old_slots_); | 1106 DCHECK(nullptr == old_to_old_slots_); |
1107 old_to_old_slots_ = AllocateSlotSet(size_, address()); | 1107 old_to_old_slots_ = AllocateSlotSet(size_, address()); |
1108 } | 1108 } |
1109 | 1109 |
1110 void MemoryChunk::ReleaseOldToOldSlots() { | 1110 void MemoryChunk::ReleaseOldToOldSlots() { |
1111 delete[] old_to_old_slots_; | 1111 delete[] old_to_old_slots_; |
1112 old_to_old_slots_ = nullptr; | 1112 old_to_old_slots_ = nullptr; |
1113 } | 1113 } |
1114 | 1114 |
1115 void MemoryChunk::AllocateTypedOldToNewSlots() { | 1115 void MemoryChunk::AllocateTypedOldToNewSlots() { |
1116 DCHECK(nullptr == typed_old_to_new_slots_); | 1116 DCHECK(nullptr == typed_old_to_new_slots_.Value()); |
1117 typed_old_to_new_slots_ = new TypedSlotSet(address()); | 1117 typed_old_to_new_slots_.SetValue(new TypedSlotSet(address())); |
1118 } | 1118 } |
1119 | 1119 |
1120 void MemoryChunk::ReleaseTypedOldToNewSlots() { | 1120 void MemoryChunk::ReleaseTypedOldToNewSlots() { |
1121 delete typed_old_to_new_slots_; | 1121 TypedSlotSet* typed_old_to_new_slots = typed_old_to_new_slots_.Value(); |
1122 typed_old_to_new_slots_ = nullptr; | 1122 delete typed_old_to_new_slots; |
| 1123 typed_old_to_new_slots_.SetValue(nullptr); |
1123 } | 1124 } |
1124 | 1125 |
1125 void MemoryChunk::AllocateTypedOldToOldSlots() { | 1126 void MemoryChunk::AllocateTypedOldToOldSlots() { |
1126 DCHECK(nullptr == typed_old_to_old_slots_); | 1127 DCHECK(nullptr == typed_old_to_old_slots_); |
1127 typed_old_to_old_slots_ = new TypedSlotSet(address()); | 1128 typed_old_to_old_slots_ = new TypedSlotSet(address()); |
1128 } | 1129 } |
1129 | 1130 |
1130 void MemoryChunk::ReleaseTypedOldToOldSlots() { | 1131 void MemoryChunk::ReleaseTypedOldToOldSlots() { |
1131 delete typed_old_to_old_slots_; | 1132 delete typed_old_to_old_slots_; |
1132 typed_old_to_old_slots_ = nullptr; | 1133 typed_old_to_old_slots_ = nullptr; |
(...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3235 object->ShortPrint(); | 3236 object->ShortPrint(); |
3236 PrintF("\n"); | 3237 PrintF("\n"); |
3237 } | 3238 } |
3238 printf(" --------------------------------------\n"); | 3239 printf(" --------------------------------------\n"); |
3239 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3240 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3240 } | 3241 } |
3241 | 3242 |
3242 #endif // DEBUG | 3243 #endif // DEBUG |
3243 } // namespace internal | 3244 } // namespace internal |
3244 } // namespace v8 | 3245 } // namespace v8 |
OLD | NEW |