Commit 2c742fc8 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Rename LocalAllocator to EvacuationAllocator

Local is used in other contexts as well, e.g. LocalIsolate or LocalHeap. Make it clear from the name that EvacuationAllocator is only used during collections.

Bug: v8:10315
Change-Id: I7483270aabc3dfe1fdecf0e77d1638c6711a8a2c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2137413Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67034}
parent fda8b057
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
AllocationResult LocalAllocator::Allocate(AllocationSpace space, AllocationResult EvacuationAllocator::Allocate(AllocationSpace space,
int object_size, int object_size,
AllocationOrigin origin, AllocationOrigin origin,
AllocationAlignment alignment) { AllocationAlignment alignment) {
switch (space) { switch (space) {
case NEW_SPACE: case NEW_SPACE:
return AllocateInNewSpace(object_size, origin, alignment); return AllocateInNewSpace(object_size, origin, alignment);
...@@ -30,8 +30,8 @@ AllocationResult LocalAllocator::Allocate(AllocationSpace space, ...@@ -30,8 +30,8 @@ AllocationResult LocalAllocator::Allocate(AllocationSpace space,
} }
} }
void LocalAllocator::FreeLast(AllocationSpace space, HeapObject object, void EvacuationAllocator::FreeLast(AllocationSpace space, HeapObject object,
int object_size) { int object_size) {
switch (space) { switch (space) {
case NEW_SPACE: case NEW_SPACE:
FreeLastInNewSpace(object, object_size); FreeLastInNewSpace(object, object_size);
...@@ -45,7 +45,8 @@ void LocalAllocator::FreeLast(AllocationSpace space, HeapObject object, ...@@ -45,7 +45,8 @@ void LocalAllocator::FreeLast(AllocationSpace space, HeapObject object,
} }
} }
void LocalAllocator::FreeLastInNewSpace(HeapObject object, int object_size) { void EvacuationAllocator::FreeLastInNewSpace(HeapObject object,
int object_size) {
if (!new_space_lab_.TryFreeLast(object, object_size)) { if (!new_space_lab_.TryFreeLast(object, object_size)) {
// We couldn't free the last object so we have to write a proper filler. // We couldn't free the last object so we have to write a proper filler.
heap_->CreateFillerObjectAt(object.address(), object_size, heap_->CreateFillerObjectAt(object.address(), object_size,
...@@ -53,7 +54,8 @@ void LocalAllocator::FreeLastInNewSpace(HeapObject object, int object_size) { ...@@ -53,7 +54,8 @@ void LocalAllocator::FreeLastInNewSpace(HeapObject object, int object_size) {
} }
} }
void LocalAllocator::FreeLastInOldSpace(HeapObject object, int object_size) { void EvacuationAllocator::FreeLastInOldSpace(HeapObject object,
int object_size) {
if (!compaction_spaces_.Get(OLD_SPACE)->TryFreeLast(object, object_size)) { if (!compaction_spaces_.Get(OLD_SPACE)->TryFreeLast(object, object_size)) {
// We couldn't free the last object so we have to write a proper filler. // We couldn't free the last object so we have to write a proper filler.
heap_->CreateFillerObjectAt(object.address(), object_size, heap_->CreateFillerObjectAt(object.address(), object_size,
...@@ -61,8 +63,8 @@ void LocalAllocator::FreeLastInOldSpace(HeapObject object, int object_size) { ...@@ -61,8 +63,8 @@ void LocalAllocator::FreeLastInOldSpace(HeapObject object, int object_size) {
} }
} }
AllocationResult LocalAllocator::AllocateInLAB(int object_size, AllocationResult EvacuationAllocator::AllocateInLAB(
AllocationAlignment alignment) { int object_size, AllocationAlignment alignment) {
AllocationResult allocation; AllocationResult allocation;
if (!new_space_lab_.IsValid() && !NewLocalAllocationBuffer()) { if (!new_space_lab_.IsValid() && !NewLocalAllocationBuffer()) {
return AllocationResult::Retry(OLD_SPACE); return AllocationResult::Retry(OLD_SPACE);
...@@ -79,7 +81,7 @@ AllocationResult LocalAllocator::AllocateInLAB(int object_size, ...@@ -79,7 +81,7 @@ AllocationResult LocalAllocator::AllocateInLAB(int object_size,
return allocation; return allocation;
} }
bool LocalAllocator::NewLocalAllocationBuffer() { bool EvacuationAllocator::NewLocalAllocationBuffer() {
if (lab_allocation_will_fail_) return false; if (lab_allocation_will_fail_) return false;
LocalAllocationBuffer saved_lab_ = new_space_lab_; LocalAllocationBuffer saved_lab_ = new_space_lab_;
AllocationResult result = AllocationResult result =
...@@ -94,7 +96,7 @@ bool LocalAllocator::NewLocalAllocationBuffer() { ...@@ -94,7 +96,7 @@ bool LocalAllocator::NewLocalAllocationBuffer() {
return false; return false;
} }
AllocationResult LocalAllocator::AllocateInNewSpace( AllocationResult EvacuationAllocator::AllocateInNewSpace(
int object_size, AllocationOrigin origin, AllocationAlignment alignment) { int object_size, AllocationOrigin origin, AllocationAlignment alignment) {
if (object_size > kMaxLabObjectSize) { if (object_size > kMaxLabObjectSize) {
return new_space_->AllocateRawSynchronized(object_size, alignment, origin); return new_space_->AllocateRawSynchronized(object_size, alignment, origin);
......
...@@ -12,25 +12,26 @@ ...@@ -12,25 +12,26 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
// Allocator encapsulating thread-local allocation. Assumes that all other // Allocator encapsulating thread-local allocation durning collection. Assumes
// allocations also go through LocalAllocator. // that all other allocations also go through EvacuationAllocator.
class LocalAllocator { class EvacuationAllocator {
public: public:
static const int kLabSize = 32 * KB; static const int kLabSize = 32 * KB;
static const int kMaxLabObjectSize = 8 * KB; static const int kMaxLabObjectSize = 8 * KB;
explicit LocalAllocator(Heap* heap, LocalSpaceKind local_space_kind) explicit EvacuationAllocator(Heap* heap, LocalSpaceKind local_space_kind)
: heap_(heap), : heap_(heap),
new_space_(heap->new_space()), new_space_(heap->new_space()),
compaction_spaces_(heap, local_space_kind), compaction_spaces_(heap, local_space_kind),
new_space_lab_(LocalAllocationBuffer::InvalidBuffer()), new_space_lab_(LocalAllocationBuffer::InvalidBuffer()),
lab_allocation_will_fail_(false) {} lab_allocation_will_fail_(false) {}
// Needs to be called from the main thread to finalize this LocalAllocator. // Needs to be called from the main thread to finalize this
// EvacuationAllocator.
void Finalize() { void Finalize() {
heap_->old_space()->MergeLocalSpace(compaction_spaces_.Get(OLD_SPACE)); heap_->old_space()->MergeLocalSpace(compaction_spaces_.Get(OLD_SPACE));
heap_->code_space()->MergeLocalSpace(compaction_spaces_.Get(CODE_SPACE)); heap_->code_space()->MergeLocalSpace(compaction_spaces_.Get(CODE_SPACE));
// Give back remaining LAB space if this LocalAllocator's new space LAB // Give back remaining LAB space if this EvacuationAllocator's new space LAB
// sits right next to new space allocation top. // sits right next to new space allocation top.
const LinearAllocationArea info = new_space_lab_.Close(); const LinearAllocationArea info = new_space_lab_.Close();
const Address top = new_space_->top(); const Address top = new_space_->top();
......
...@@ -1323,7 +1323,7 @@ class EvacuateVisitorBase : public HeapObjectVisitor { ...@@ -1323,7 +1323,7 @@ class EvacuateVisitorBase : public HeapObjectVisitor {
src.set_map_word(MapWord::FromForwardingAddress(dst)); src.set_map_word(MapWord::FromForwardingAddress(dst));
} }
EvacuateVisitorBase(Heap* heap, LocalAllocator* local_allocator, EvacuateVisitorBase(Heap* heap, EvacuationAllocator* local_allocator,
RecordMigratedSlotVisitor* record_visitor) RecordMigratedSlotVisitor* record_visitor)
: heap_(heap), : heap_(heap),
local_allocator_(local_allocator), local_allocator_(local_allocator),
...@@ -1382,7 +1382,7 @@ class EvacuateVisitorBase : public HeapObjectVisitor { ...@@ -1382,7 +1382,7 @@ class EvacuateVisitorBase : public HeapObjectVisitor {
#endif // VERIFY_HEAP #endif // VERIFY_HEAP
Heap* heap_; Heap* heap_;
LocalAllocator* local_allocator_; EvacuationAllocator* local_allocator_;
RecordMigratedSlotVisitor* record_visitor_; RecordMigratedSlotVisitor* record_visitor_;
std::vector<MigrationObserver*> observers_; std::vector<MigrationObserver*> observers_;
MigrateFunction migration_function_; MigrateFunction migration_function_;
...@@ -1391,7 +1391,7 @@ class EvacuateVisitorBase : public HeapObjectVisitor { ...@@ -1391,7 +1391,7 @@ class EvacuateVisitorBase : public HeapObjectVisitor {
class EvacuateNewSpaceVisitor final : public EvacuateVisitorBase { class EvacuateNewSpaceVisitor final : public EvacuateVisitorBase {
public: public:
explicit EvacuateNewSpaceVisitor( explicit EvacuateNewSpaceVisitor(
Heap* heap, LocalAllocator* local_allocator, Heap* heap, EvacuationAllocator* local_allocator,
RecordMigratedSlotVisitor* record_visitor, RecordMigratedSlotVisitor* record_visitor,
Heap::PretenuringFeedbackMap* local_pretenuring_feedback, Heap::PretenuringFeedbackMap* local_pretenuring_feedback,
bool always_promote_young) bool always_promote_young)
...@@ -1545,7 +1545,7 @@ class EvacuateNewSpacePageVisitor final : public HeapObjectVisitor { ...@@ -1545,7 +1545,7 @@ class EvacuateNewSpacePageVisitor final : public HeapObjectVisitor {
class EvacuateOldSpaceVisitor final : public EvacuateVisitorBase { class EvacuateOldSpaceVisitor final : public EvacuateVisitorBase {
public: public:
EvacuateOldSpaceVisitor(Heap* heap, LocalAllocator* local_allocator, EvacuateOldSpaceVisitor(Heap* heap, EvacuationAllocator* local_allocator,
RecordMigratedSlotVisitor* record_visitor) RecordMigratedSlotVisitor* record_visitor)
: EvacuateVisitorBase(heap, local_allocator, record_visitor) {} : EvacuateVisitorBase(heap, local_allocator, record_visitor) {}
...@@ -2869,7 +2869,7 @@ class Evacuator : public Malloced { ...@@ -2869,7 +2869,7 @@ class Evacuator : public Malloced {
} }
Evacuator(Heap* heap, RecordMigratedSlotVisitor* record_visitor, Evacuator(Heap* heap, RecordMigratedSlotVisitor* record_visitor,
LocalAllocator* local_allocator, bool always_promote_young) EvacuationAllocator* local_allocator, bool always_promote_young)
: heap_(heap), : heap_(heap),
local_pretenuring_feedback_(kInitialLocalPretenuringFeedbackCapacity), local_pretenuring_feedback_(kInitialLocalPretenuringFeedbackCapacity),
new_space_visitor_(heap_, local_allocator, record_visitor, new_space_visitor_(heap_, local_allocator, record_visitor,
...@@ -2927,7 +2927,7 @@ class Evacuator : public Malloced { ...@@ -2927,7 +2927,7 @@ class Evacuator : public Malloced {
EvacuateOldSpaceVisitor old_space_visitor_; EvacuateOldSpaceVisitor old_space_visitor_;
// Locally cached collector data. // Locally cached collector data.
LocalAllocator* local_allocator_; EvacuationAllocator* local_allocator_;
// Book keeping info. // Book keeping info.
double duration_; double duration_;
...@@ -3015,7 +3015,7 @@ class FullEvacuator : public Evacuator { ...@@ -3015,7 +3015,7 @@ class FullEvacuator : public Evacuator {
void RawEvacuatePage(MemoryChunk* chunk, intptr_t* live_bytes) override; void RawEvacuatePage(MemoryChunk* chunk, intptr_t* live_bytes) override;
EphemeronRememberedSet ephemeron_remembered_set_; EphemeronRememberedSet ephemeron_remembered_set_;
RecordMigratedSlotVisitor record_visitor_; RecordMigratedSlotVisitor record_visitor_;
LocalAllocator local_allocator_; EvacuationAllocator local_allocator_;
MarkCompactCollector* collector_; MarkCompactCollector* collector_;
}; };
...@@ -5049,7 +5049,7 @@ class YoungGenerationEvacuator : public Evacuator { ...@@ -5049,7 +5049,7 @@ class YoungGenerationEvacuator : public Evacuator {
void RawEvacuatePage(MemoryChunk* chunk, intptr_t* live_bytes) override; void RawEvacuatePage(MemoryChunk* chunk, intptr_t* live_bytes) override;
YoungGenerationRecordMigratedSlotVisitor record_visitor_; YoungGenerationRecordMigratedSlotVisitor record_visitor_;
LocalAllocator local_allocator_; EvacuationAllocator local_allocator_;
MinorMarkCompactCollector* collector_; MinorMarkCompactCollector* collector_;
}; };
......
...@@ -216,7 +216,7 @@ class Scavenger { ...@@ -216,7 +216,7 @@ class Scavenger {
Heap::PretenuringFeedbackMap local_pretenuring_feedback_; Heap::PretenuringFeedbackMap local_pretenuring_feedback_;
size_t copied_size_; size_t copied_size_;
size_t promoted_size_; size_t promoted_size_;
LocalAllocator allocator_; EvacuationAllocator allocator_;
SurvivingNewLargeObjectsMap surviving_new_large_objects_; SurvivingNewLargeObjectsMap surviving_new_large_objects_;
EphemeronRememberedSet ephemeron_remembered_set_; EphemeronRememberedSet ephemeron_remembered_set_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment