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 "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/base/platform/semaphore.h" | 9 #include "src/base/platform/semaphore.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 chunk->InitializeReservedMemory(); | 504 chunk->InitializeReservedMemory(); |
505 chunk->old_to_new_slots_ = nullptr; | 505 chunk->old_to_new_slots_ = nullptr; |
506 chunk->old_to_old_slots_ = nullptr; | 506 chunk->old_to_old_slots_ = nullptr; |
507 chunk->typed_old_to_new_slots_ = nullptr; | 507 chunk->typed_old_to_new_slots_ = nullptr; |
508 chunk->typed_old_to_old_slots_ = nullptr; | 508 chunk->typed_old_to_old_slots_ = nullptr; |
509 chunk->skip_list_ = nullptr; | 509 chunk->skip_list_ = nullptr; |
510 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; | 510 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; |
511 chunk->progress_bar_ = 0; | 511 chunk->progress_bar_ = 0; |
512 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); | 512 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); |
513 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); | 513 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); |
514 chunk->mutex_ = new base::Mutex(); | 514 chunk->mutex_ = nullptr; |
515 chunk->available_in_free_list_ = 0; | 515 chunk->available_in_free_list_ = 0; |
516 chunk->wasted_memory_ = 0; | 516 chunk->wasted_memory_ = 0; |
517 chunk->ResetLiveBytes(); | 517 chunk->ResetLiveBytes(); |
518 Bitmap::Clear(chunk); | 518 Bitmap::Clear(chunk); |
519 chunk->set_next_chunk(nullptr); | 519 chunk->set_next_chunk(nullptr); |
520 chunk->set_prev_chunk(nullptr); | 520 chunk->set_prev_chunk(nullptr); |
521 chunk->local_tracker_.SetValue(nullptr); | |
522 | 521 |
523 DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset); | 522 DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset); |
524 DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset); | 523 DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset); |
525 | 524 |
526 if (executable == EXECUTABLE) { | 525 if (executable == EXECUTABLE) { |
527 chunk->SetFlag(IS_EXECUTABLE); | 526 chunk->SetFlag(IS_EXECUTABLE); |
528 } | 527 } |
529 | 528 |
530 if (reservation != nullptr) { | 529 if (reservation != nullptr) { |
531 chunk->reservation_.TakeControl(reservation); | 530 chunk->reservation_.TakeControl(reservation); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 skip_list_ = nullptr; | 977 skip_list_ = nullptr; |
979 } | 978 } |
980 if (mutex_ != nullptr) { | 979 if (mutex_ != nullptr) { |
981 delete mutex_; | 980 delete mutex_; |
982 mutex_ = nullptr; | 981 mutex_ = nullptr; |
983 } | 982 } |
984 if (old_to_new_slots_ != nullptr) ReleaseOldToNewSlots(); | 983 if (old_to_new_slots_ != nullptr) ReleaseOldToNewSlots(); |
985 if (old_to_old_slots_ != nullptr) ReleaseOldToOldSlots(); | 984 if (old_to_old_slots_ != nullptr) ReleaseOldToOldSlots(); |
986 if (typed_old_to_new_slots_ != nullptr) ReleaseTypedOldToNewSlots(); | 985 if (typed_old_to_new_slots_ != nullptr) ReleaseTypedOldToNewSlots(); |
987 if (typed_old_to_old_slots_ != nullptr) ReleaseTypedOldToOldSlots(); | 986 if (typed_old_to_old_slots_ != nullptr) ReleaseTypedOldToOldSlots(); |
988 | |
989 if (local_tracker_.Value() != nullptr) ReleaseLocalTracker(); | |
990 } | 987 } |
991 | 988 |
992 static SlotSet* AllocateSlotSet(size_t size, Address page_start) { | 989 static SlotSet* AllocateSlotSet(size_t size, Address page_start) { |
993 size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize; | 990 size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize; |
994 DCHECK(pages > 0); | 991 DCHECK(pages > 0); |
995 SlotSet* slot_set = new SlotSet[pages]; | 992 SlotSet* slot_set = new SlotSet[pages]; |
996 for (size_t i = 0; i < pages; i++) { | 993 for (size_t i = 0; i < pages; i++) { |
997 slot_set[i].SetPageStart(page_start + i * Page::kPageSize); | 994 slot_set[i].SetPageStart(page_start + i * Page::kPageSize); |
998 } | 995 } |
999 return slot_set; | 996 return slot_set; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 | 1028 |
1032 void MemoryChunk::AllocateTypedOldToOldSlots() { | 1029 void MemoryChunk::AllocateTypedOldToOldSlots() { |
1033 DCHECK(nullptr == typed_old_to_old_slots_); | 1030 DCHECK(nullptr == typed_old_to_old_slots_); |
1034 typed_old_to_old_slots_ = new TypedSlotSet(address()); | 1031 typed_old_to_old_slots_ = new TypedSlotSet(address()); |
1035 } | 1032 } |
1036 | 1033 |
1037 void MemoryChunk::ReleaseTypedOldToOldSlots() { | 1034 void MemoryChunk::ReleaseTypedOldToOldSlots() { |
1038 delete typed_old_to_old_slots_; | 1035 delete typed_old_to_old_slots_; |
1039 typed_old_to_old_slots_ = nullptr; | 1036 typed_old_to_old_slots_ = nullptr; |
1040 } | 1037 } |
1041 | |
1042 void MemoryChunk::ReleaseLocalTracker() { | |
1043 delete local_tracker_.Value(); | |
1044 local_tracker_.SetValue(nullptr); | |
1045 } | |
1046 | |
1047 // ----------------------------------------------------------------------------- | 1038 // ----------------------------------------------------------------------------- |
1048 // PagedSpace implementation | 1039 // PagedSpace implementation |
1049 | 1040 |
1050 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == | 1041 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == |
1051 ObjectSpace::kObjectSpaceNewSpace); | 1042 ObjectSpace::kObjectSpaceNewSpace); |
1052 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == | 1043 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == |
1053 ObjectSpace::kObjectSpaceOldSpace); | 1044 ObjectSpace::kObjectSpaceOldSpace); |
1054 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == | 1045 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == |
1055 ObjectSpace::kObjectSpaceCodeSpace); | 1046 ObjectSpace::kObjectSpaceCodeSpace); |
1056 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == | 1047 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == |
(...skipping 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3211 object->ShortPrint(); | 3202 object->ShortPrint(); |
3212 PrintF("\n"); | 3203 PrintF("\n"); |
3213 } | 3204 } |
3214 printf(" --------------------------------------\n"); | 3205 printf(" --------------------------------------\n"); |
3215 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3206 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3216 } | 3207 } |
3217 | 3208 |
3218 #endif // DEBUG | 3209 #endif // DEBUG |
3219 } // namespace internal | 3210 } // namespace internal |
3220 } // namespace v8 | 3211 } // namespace v8 |
OLD | NEW |