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