Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: src/heap/spaces.cc

Issue 1683653002: Add a generic remembered set class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 // MemoryChunk implementation 924 // MemoryChunk implementation
924 925
925 void MemoryChunk::ReleaseAllocatedMemory() { 926 void MemoryChunk::ReleaseAllocatedMemory() {
926 delete slots_buffer_; 927 delete slots_buffer_;
927 slots_buffer_ = nullptr; 928 slots_buffer_ = nullptr;
928 delete skip_list_; 929 delete skip_list_;
929 skip_list_ = nullptr; 930 skip_list_ = nullptr;
930 delete mutex_; 931 delete mutex_;
931 mutex_ = nullptr; 932 mutex_ = nullptr;
932 ReleaseOldToNewSlots(); 933 ReleaseOldToNewSlots();
934 ReleaseOldToOldSlots();
935 }
936
937 static SlotSet* AllocateSlotSet(size_t size, Address page_start) {
938 size_t pages = (size + Page::kPageSize - 1) / Page::kPageSize;
939 DCHECK(pages > 0);
940 SlotSet* slot_set = new SlotSet[pages];
941 for (size_t i = 0; i < pages; i++) {
942 slot_set[i].SetPageStart(page_start + i * Page::kPageSize);
943 }
944 return slot_set;
933 } 945 }
934 946
935 void MemoryChunk::AllocateOldToNewSlots() { 947 void MemoryChunk::AllocateOldToNewSlots() {
936 size_t pages = (size_ + Page::kPageSize - 1) / Page::kPageSize;
937 DCHECK(owner() == heap_->lo_space() || pages == 1);
938 DCHECK(pages > 0);
939 DCHECK(nullptr == old_to_new_slots_); 948 DCHECK(nullptr == old_to_new_slots_);
940 old_to_new_slots_ = new SlotSet[pages]; 949 old_to_new_slots_ = AllocateSlotSet(size_, address());
941 for (size_t i = 0; i < pages; i++) {
942 old_to_new_slots_[i].SetPageStart(address() + i * Page::kPageSize);
943 }
944 } 950 }
945 951
946 void MemoryChunk::ReleaseOldToNewSlots() { 952 void MemoryChunk::ReleaseOldToNewSlots() {
947 delete[] old_to_new_slots_; 953 delete[] old_to_new_slots_;
948 old_to_new_slots_ = nullptr; 954 old_to_new_slots_ = nullptr;
949 } 955 }
950 956
957 void MemoryChunk::AllocateOldToOldSlots() {
958 DCHECK(nullptr == old_to_old_slots_);
959 old_to_old_slots_ = AllocateSlotSet(size_, address());
960 }
961
962 void MemoryChunk::ReleaseOldToOldSlots() {
963 delete[] old_to_old_slots_;
964 old_to_old_slots_ = nullptr;
965 }
951 966
952 // ----------------------------------------------------------------------------- 967 // -----------------------------------------------------------------------------
953 // PagedSpace implementation 968 // PagedSpace implementation
954 969
955 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) == 970 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) ==
956 ObjectSpace::kObjectSpaceNewSpace); 971 ObjectSpace::kObjectSpaceNewSpace);
957 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) == 972 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) ==
958 ObjectSpace::kObjectSpaceOldSpace); 973 ObjectSpace::kObjectSpaceOldSpace);
959 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) == 974 STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) ==
960 ObjectSpace::kObjectSpaceCodeSpace); 975 ObjectSpace::kObjectSpaceCodeSpace);
(...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 object->ShortPrint(); 3245 object->ShortPrint();
3231 PrintF("\n"); 3246 PrintF("\n");
3232 } 3247 }
3233 printf(" --------------------------------------\n"); 3248 printf(" --------------------------------------\n");
3234 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3249 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3235 } 3250 }
3236 3251
3237 #endif // DEBUG 3252 #endif // DEBUG
3238 } // namespace internal 3253 } // namespace internal
3239 } // namespace v8 3254 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698