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/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
10 #include "src/heap/slot-set.h" | 10 #include "src/heap/slot-set.h" |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 473 |
474 chunk->heap_ = heap; | 474 chunk->heap_ = heap; |
475 chunk->size_ = size; | 475 chunk->size_ = size; |
476 chunk->area_start_ = area_start; | 476 chunk->area_start_ = area_start; |
477 chunk->area_end_ = area_end; | 477 chunk->area_end_ = area_end; |
478 chunk->flags_ = 0; | 478 chunk->flags_ = 0; |
479 chunk->set_owner(owner); | 479 chunk->set_owner(owner); |
480 chunk->InitializeReservedMemory(); | 480 chunk->InitializeReservedMemory(); |
481 chunk->slots_buffer_ = nullptr; | 481 chunk->slots_buffer_ = nullptr; |
482 chunk->old_to_new_slots_ = nullptr; | 482 chunk->old_to_new_slots_ = nullptr; |
| 483 chunk->old_to_old_slots_ = nullptr; |
483 chunk->skip_list_ = nullptr; | 484 chunk->skip_list_ = nullptr; |
484 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; | 485 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; |
485 chunk->progress_bar_ = 0; | 486 chunk->progress_bar_ = 0; |
486 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); | 487 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); |
487 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); | 488 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); |
488 chunk->parallel_compaction_state().SetValue(kCompactingDone); | 489 chunk->parallel_compaction_state().SetValue(kCompactingDone); |
489 chunk->mutex_ = nullptr; | 490 chunk->mutex_ = nullptr; |
490 chunk->available_in_small_free_list_ = 0; | 491 chunk->available_in_small_free_list_ = 0; |
491 chunk->available_in_medium_free_list_ = 0; | 492 chunk->available_in_medium_free_list_ = 0; |
492 chunk->available_in_large_free_list_ = 0; | 493 chunk->available_in_large_free_list_ = 0; |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 // MemoryChunk implementation | 938 // MemoryChunk implementation |
938 | 939 |
939 void MemoryChunk::ReleaseAllocatedMemory() { | 940 void MemoryChunk::ReleaseAllocatedMemory() { |
940 delete slots_buffer_; | 941 delete slots_buffer_; |
941 slots_buffer_ = nullptr; | 942 slots_buffer_ = nullptr; |
942 delete skip_list_; | 943 delete skip_list_; |
943 skip_list_ = nullptr; | 944 skip_list_ = nullptr; |
944 delete mutex_; | 945 delete mutex_; |
945 mutex_ = nullptr; | 946 mutex_ = nullptr; |
946 ReleaseOldToNewSlots(); | 947 ReleaseOldToNewSlots(); |
| 948 ReleaseOldToOldSlots(); |
| 949 } |
| 950 |
| 951 static SlotSet* AllocateSlotSet(size_t size, Address page_start) { |
| 952 size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize; |
| 953 DCHECK(pages > 0); |
| 954 SlotSet* slot_set = new SlotSet[pages]; |
| 955 for (size_t i = 0; i < pages; i++) { |
| 956 slot_set[i].SetPageStart(page_start + i * Page::kPageSize); |
| 957 } |
| 958 return slot_set; |
947 } | 959 } |
948 | 960 |
949 void MemoryChunk::AllocateOldToNewSlots() { | 961 void MemoryChunk::AllocateOldToNewSlots() { |
950 size_t pages = (size_ + Page::kPageSize - 1) / Page::kPageSize; | |
951 DCHECK(owner() == heap_->lo_space() || pages == 1); | |
952 DCHECK(pages > 0); | |
953 DCHECK(nullptr == old_to_new_slots_); | 962 DCHECK(nullptr == old_to_new_slots_); |
954 old_to_new_slots_ = new SlotSet[pages]; | 963 old_to_new_slots_ = AllocateSlotSet(size_, address()); |
955 for (size_t i = 0; i < pages; i++) { | |
956 old_to_new_slots_[i].SetPageStart(address() + i * Page::kPageSize); | |
957 } | |
958 } | 964 } |
959 | 965 |
960 void MemoryChunk::ReleaseOldToNewSlots() { | 966 void MemoryChunk::ReleaseOldToNewSlots() { |
961 delete[] old_to_new_slots_; | 967 delete[] old_to_new_slots_; |
962 old_to_new_slots_ = nullptr; | 968 old_to_new_slots_ = nullptr; |
963 } | 969 } |
964 | 970 |
| 971 void MemoryChunk::AllocateOldToOldSlots() { |
| 972 DCHECK(nullptr == old_to_old_slots_); |
| 973 old_to_old_slots_ = AllocateSlotSet(size_, address()); |
| 974 } |
| 975 |
| 976 void MemoryChunk::ReleaseOldToOldSlots() { |
| 977 delete[] old_to_old_slots_; |
| 978 old_to_old_slots_ = nullptr; |
| 979 } |
965 | 980 |
966 // ----------------------------------------------------------------------------- | 981 // ----------------------------------------------------------------------------- |
967 // PagedSpace implementation | 982 // PagedSpace implementation |
968 | 983 |
969 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == | 984 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == |
970 ObjectSpace::kObjectSpaceNewSpace); | 985 ObjectSpace::kObjectSpaceNewSpace); |
971 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == | 986 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == |
972 ObjectSpace::kObjectSpaceOldSpace); | 987 ObjectSpace::kObjectSpaceOldSpace); |
973 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == | 988 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == |
974 ObjectSpace::kObjectSpaceCodeSpace); | 989 ObjectSpace::kObjectSpaceCodeSpace); |
(...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3245 object->ShortPrint(); | 3260 object->ShortPrint(); |
3246 PrintF("\n"); | 3261 PrintF("\n"); |
3247 } | 3262 } |
3248 printf(" --------------------------------------\n"); | 3263 printf(" --------------------------------------\n"); |
3249 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3264 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3250 } | 3265 } |
3251 | 3266 |
3252 #endif // DEBUG | 3267 #endif // DEBUG |
3253 } // namespace internal | 3268 } // namespace internal |
3254 } // namespace v8 | 3269 } // namespace v8 |
OLD | NEW |