| 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 | 459 |
| 460 chunk->heap_ = heap; | 460 chunk->heap_ = heap; |
| 461 chunk->size_ = size; | 461 chunk->size_ = size; |
| 462 chunk->area_start_ = area_start; | 462 chunk->area_start_ = area_start; |
| 463 chunk->area_end_ = area_end; | 463 chunk->area_end_ = area_end; |
| 464 chunk->flags_ = 0; | 464 chunk->flags_ = 0; |
| 465 chunk->set_owner(owner); | 465 chunk->set_owner(owner); |
| 466 chunk->InitializeReservedMemory(); | 466 chunk->InitializeReservedMemory(); |
| 467 chunk->slots_buffer_ = nullptr; | 467 chunk->slots_buffer_ = nullptr; |
| 468 chunk->old_to_new_slots_ = nullptr; | 468 chunk->old_to_new_slots_ = nullptr; |
| 469 chunk->old_to_old_slots_ = nullptr; |
| 469 chunk->skip_list_ = nullptr; | 470 chunk->skip_list_ = nullptr; |
| 470 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; | 471 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; |
| 471 chunk->progress_bar_ = 0; | 472 chunk->progress_bar_ = 0; |
| 472 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); | 473 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); |
| 473 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); | 474 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); |
| 474 chunk->parallel_compaction_state().SetValue(kCompactingDone); | 475 chunk->parallel_compaction_state().SetValue(kCompactingDone); |
| 475 chunk->mutex_ = nullptr; | 476 chunk->mutex_ = nullptr; |
| 476 chunk->available_in_small_free_list_ = 0; | 477 chunk->available_in_small_free_list_ = 0; |
| 477 chunk->available_in_medium_free_list_ = 0; | 478 chunk->available_in_medium_free_list_ = 0; |
| 478 chunk->available_in_large_free_list_ = 0; | 479 chunk->available_in_large_free_list_ = 0; |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 } | 928 } |
| 928 chunk->IncrementLiveBytes(by); | 929 chunk->IncrementLiveBytes(by); |
| 929 } | 930 } |
| 930 | 931 |
| 931 | 932 |
| 932 void MemoryChunk::ReleaseAllocatedMemory() { | 933 void MemoryChunk::ReleaseAllocatedMemory() { |
| 933 delete slots_buffer_; | 934 delete slots_buffer_; |
| 934 delete skip_list_; | 935 delete skip_list_; |
| 935 delete mutex_; | 936 delete mutex_; |
| 936 ReleaseOldToNewSlots(); | 937 ReleaseOldToNewSlots(); |
| 938 ReleaseOldToOldSlots(); |
| 939 } |
| 940 |
| 941 static SlotSet* AllocateSlotSet(size_t size, Address page_start) { |
| 942 size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize; |
| 943 DCHECK(pages > 0); |
| 944 SlotSet* slot_set = new SlotSet[pages]; |
| 945 for (size_t i = 0; i < pages; i++) { |
| 946 slot_set[i].SetPageStart(page_start + i * Page::kPageSize); |
| 947 } |
| 948 return slot_set; |
| 937 } | 949 } |
| 938 | 950 |
| 939 void MemoryChunk::AllocateOldToNewSlots() { | 951 void MemoryChunk::AllocateOldToNewSlots() { |
| 940 size_t pages = (size_ + Page::kPageSize - 1) / Page::kPageSize; | |
| 941 DCHECK(owner() == heap_->lo_space() || pages == 1); | |
| 942 DCHECK(pages > 0); | |
| 943 DCHECK(nullptr == old_to_new_slots_); | 952 DCHECK(nullptr == old_to_new_slots_); |
| 944 old_to_new_slots_ = new SlotSet[pages]; | 953 old_to_new_slots_ = AllocateSlotSet(size_, address()); |
| 945 for (size_t i = 0; i < pages; i++) { | |
| 946 old_to_new_slots_[i].SetPageStart(address() + i * Page::kPageSize); | |
| 947 } | |
| 948 } | 954 } |
| 949 | 955 |
| 950 void MemoryChunk::ReleaseOldToNewSlots() { | 956 void MemoryChunk::ReleaseOldToNewSlots() { |
| 951 delete[] old_to_new_slots_; | 957 delete[] old_to_new_slots_; |
| 952 old_to_new_slots_ = nullptr; | 958 old_to_new_slots_ = nullptr; |
| 953 } | 959 } |
| 954 | 960 |
| 961 void MemoryChunk::AllocateOldToOldSlots() { |
| 962 DCHECK(nullptr == old_to_old_slots_); |
| 963 old_to_old_slots_ = AllocateSlotSet(size_, address()); |
| 964 } |
| 965 |
| 966 void MemoryChunk::ReleaseOldToOldSlots() { |
| 967 delete[] old_to_old_slots_; |
| 968 old_to_old_slots_ = nullptr; |
| 969 } |
| 955 | 970 |
| 956 // ----------------------------------------------------------------------------- | 971 // ----------------------------------------------------------------------------- |
| 957 // PagedSpace implementation | 972 // PagedSpace implementation |
| 958 | 973 |
| 959 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == | 974 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == |
| 960 ObjectSpace::kObjectSpaceNewSpace); | 975 ObjectSpace::kObjectSpaceNewSpace); |
| 961 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == | 976 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == |
| 962 ObjectSpace::kObjectSpaceOldSpace); | 977 ObjectSpace::kObjectSpaceOldSpace); |
| 963 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == | 978 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == |
| 964 ObjectSpace::kObjectSpaceCodeSpace); | 979 ObjectSpace::kObjectSpaceCodeSpace); |
| (...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3234 object->ShortPrint(); | 3249 object->ShortPrint(); |
| 3235 PrintF("\n"); | 3250 PrintF("\n"); |
| 3236 } | 3251 } |
| 3237 printf(" --------------------------------------\n"); | 3252 printf(" --------------------------------------\n"); |
| 3238 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3253 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3239 } | 3254 } |
| 3240 | 3255 |
| 3241 #endif // DEBUG | 3256 #endif // DEBUG |
| 3242 } // namespace internal | 3257 } // namespace internal |
| 3243 } // namespace v8 | 3258 } // namespace v8 |
| OLD | NEW |