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