| 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" |
| 11 #include "src/heap/slots-buffer.h" | |
| 12 #include "src/macro-assembler.h" | 11 #include "src/macro-assembler.h" |
| 13 #include "src/msan.h" | 12 #include "src/msan.h" |
| 14 #include "src/snapshot/snapshot.h" | 13 #include "src/snapshot/snapshot.h" |
| 15 | 14 |
| 16 namespace v8 { | 15 namespace v8 { |
| 17 namespace internal { | 16 namespace internal { |
| 18 | 17 |
| 19 | 18 |
| 20 // ---------------------------------------------------------------------------- | 19 // ---------------------------------------------------------------------------- |
| 21 // HeapObjectIterator | 20 // HeapObjectIterator |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 | 470 |
| 472 DCHECK(base == chunk->address()); | 471 DCHECK(base == chunk->address()); |
| 473 | 472 |
| 474 chunk->heap_ = heap; | 473 chunk->heap_ = heap; |
| 475 chunk->size_ = size; | 474 chunk->size_ = size; |
| 476 chunk->area_start_ = area_start; | 475 chunk->area_start_ = area_start; |
| 477 chunk->area_end_ = area_end; | 476 chunk->area_end_ = area_end; |
| 478 chunk->flags_ = 0; | 477 chunk->flags_ = 0; |
| 479 chunk->set_owner(owner); | 478 chunk->set_owner(owner); |
| 480 chunk->InitializeReservedMemory(); | 479 chunk->InitializeReservedMemory(); |
| 481 chunk->slots_buffer_ = nullptr; | |
| 482 chunk->old_to_new_slots_ = nullptr; | 480 chunk->old_to_new_slots_ = nullptr; |
| 483 chunk->old_to_old_slots_ = nullptr; | 481 chunk->old_to_old_slots_ = nullptr; |
| 482 chunk->typed_old_to_old_slots_ = nullptr; |
| 484 chunk->skip_list_ = nullptr; | 483 chunk->skip_list_ = nullptr; |
| 485 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; | 484 chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity; |
| 486 chunk->progress_bar_ = 0; | 485 chunk->progress_bar_ = 0; |
| 487 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); | 486 chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); |
| 488 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); | 487 chunk->concurrent_sweeping_state().SetValue(kSweepingDone); |
| 489 chunk->parallel_compaction_state().SetValue(kCompactingDone); | 488 chunk->parallel_compaction_state().SetValue(kCompactingDone); |
| 490 chunk->mutex_ = nullptr; | 489 chunk->mutex_ = nullptr; |
| 491 chunk->available_in_free_list_ = 0; | 490 chunk->available_in_free_list_ = 0; |
| 492 chunk->wasted_memory_ = 0; | 491 chunk->wasted_memory_ = 0; |
| 493 chunk->ResetLiveBytes(); | 492 chunk->ResetLiveBytes(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 return Page::Initialize(isolate_->heap(), chunk, executable, owner); | 724 return Page::Initialize(isolate_->heap(), chunk, executable, owner); |
| 726 } | 725 } |
| 727 | 726 |
| 728 | 727 |
| 729 LargePage* MemoryAllocator::AllocateLargePage(intptr_t object_size, | 728 LargePage* MemoryAllocator::AllocateLargePage(intptr_t object_size, |
| 730 Space* owner, | 729 Space* owner, |
| 731 Executability executable) { | 730 Executability executable) { |
| 732 MemoryChunk* chunk = | 731 MemoryChunk* chunk = |
| 733 AllocateChunk(object_size, object_size, executable, owner); | 732 AllocateChunk(object_size, object_size, executable, owner); |
| 734 if (chunk == NULL) return NULL; | 733 if (chunk == NULL) return NULL; |
| 734 if (executable && chunk->size() > LargePage::kMaxCodePageSize) { |
| 735 STATIC_ASSERT(LargePage::kMaxCodePageSize <= TypedSlotSet::kMaxOffset); |
| 736 FATAL("Code page is too large."); |
| 737 } |
| 735 return LargePage::Initialize(isolate_->heap(), chunk); | 738 return LargePage::Initialize(isolate_->heap(), chunk); |
| 736 } | 739 } |
| 737 | 740 |
| 738 | 741 |
| 739 void MemoryAllocator::PreFreeMemory(MemoryChunk* chunk) { | 742 void MemoryAllocator::PreFreeMemory(MemoryChunk* chunk) { |
| 740 DCHECK(!chunk->IsFlagSet(MemoryChunk::PRE_FREED)); | 743 DCHECK(!chunk->IsFlagSet(MemoryChunk::PRE_FREED)); |
| 741 LOG(isolate_, DeleteEvent("MemoryChunk", chunk)); | 744 LOG(isolate_, DeleteEvent("MemoryChunk", chunk)); |
| 742 if (chunk->owner() != NULL) { | 745 if (chunk->owner() != NULL) { |
| 743 ObjectSpace space = | 746 ObjectSpace space = |
| 744 static_cast<ObjectSpace>(1 << chunk->owner()->identity()); | 747 static_cast<ObjectSpace>(1 << chunk->owner()->identity()); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 vm->Uncommit(header, header_size); | 928 vm->Uncommit(header, header_size); |
| 926 } | 929 } |
| 927 return false; | 930 return false; |
| 928 } | 931 } |
| 929 | 932 |
| 930 | 933 |
| 931 // ----------------------------------------------------------------------------- | 934 // ----------------------------------------------------------------------------- |
| 932 // MemoryChunk implementation | 935 // MemoryChunk implementation |
| 933 | 936 |
| 934 void MemoryChunk::ReleaseAllocatedMemory() { | 937 void MemoryChunk::ReleaseAllocatedMemory() { |
| 935 delete slots_buffer_; | |
| 936 slots_buffer_ = nullptr; | |
| 937 delete skip_list_; | 938 delete skip_list_; |
| 938 skip_list_ = nullptr; | 939 skip_list_ = nullptr; |
| 939 delete mutex_; | 940 delete mutex_; |
| 940 mutex_ = nullptr; | 941 mutex_ = nullptr; |
| 941 ReleaseOldToNewSlots(); | 942 ReleaseOldToNewSlots(); |
| 942 ReleaseOldToOldSlots(); | 943 ReleaseOldToOldSlots(); |
| 943 } | 944 } |
| 944 | 945 |
| 945 static SlotSet* AllocateSlotSet(size_t size, Address page_start) { | 946 static SlotSet* AllocateSlotSet(size_t size, Address page_start) { |
| 946 size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize; | 947 size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 965 void MemoryChunk::AllocateOldToOldSlots() { | 966 void MemoryChunk::AllocateOldToOldSlots() { |
| 966 DCHECK(nullptr == old_to_old_slots_); | 967 DCHECK(nullptr == old_to_old_slots_); |
| 967 old_to_old_slots_ = AllocateSlotSet(size_, address()); | 968 old_to_old_slots_ = AllocateSlotSet(size_, address()); |
| 968 } | 969 } |
| 969 | 970 |
| 970 void MemoryChunk::ReleaseOldToOldSlots() { | 971 void MemoryChunk::ReleaseOldToOldSlots() { |
| 971 delete[] old_to_old_slots_; | 972 delete[] old_to_old_slots_; |
| 972 old_to_old_slots_ = nullptr; | 973 old_to_old_slots_ = nullptr; |
| 973 } | 974 } |
| 974 | 975 |
| 976 void MemoryChunk::AllocateTypedOldToOldSlots() { |
| 977 DCHECK(nullptr == typed_old_to_old_slots_); |
| 978 typed_old_to_old_slots_ = new TypedSlotSet(address()); |
| 979 } |
| 980 |
| 981 void MemoryChunk::ReleaseTypedOldToOldSlots() { |
| 982 delete typed_old_to_old_slots_; |
| 983 typed_old_to_old_slots_ = nullptr; |
| 984 } |
| 975 // ----------------------------------------------------------------------------- | 985 // ----------------------------------------------------------------------------- |
| 976 // PagedSpace implementation | 986 // PagedSpace implementation |
| 977 | 987 |
| 978 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == | 988 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == |
| 979 ObjectSpace::kObjectSpaceNewSpace); | 989 ObjectSpace::kObjectSpaceNewSpace); |
| 980 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == | 990 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == |
| 981 ObjectSpace::kObjectSpaceOldSpace); | 991 ObjectSpace::kObjectSpaceOldSpace); |
| 982 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == | 992 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == |
| 983 ObjectSpace::kObjectSpaceCodeSpace); | 993 ObjectSpace::kObjectSpaceCodeSpace); |
| 984 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == | 994 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) == |
| (...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3234 object->ShortPrint(); | 3244 object->ShortPrint(); |
| 3235 PrintF("\n"); | 3245 PrintF("\n"); |
| 3236 } | 3246 } |
| 3237 printf(" --------------------------------------\n"); | 3247 printf(" --------------------------------------\n"); |
| 3238 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3248 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3239 } | 3249 } |
| 3240 | 3250 |
| 3241 #endif // DEBUG | 3251 #endif // DEBUG |
| 3242 } // namespace internal | 3252 } // namespace internal |
| 3243 } // namespace v8 | 3253 } // namespace v8 |
| OLD | NEW |