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 @@
namespace v8 {
namespace internal {
AllocationResult LocalAllocator::Allocate(AllocationSpace space,
int object_size,
AllocationOrigin origin,
AllocationAlignment alignment) {
AllocationResult EvacuationAllocator::Allocate(AllocationSpace space,
int object_size,
AllocationOrigin origin,
AllocationAlignment alignment) {
switch (space) {
case NEW_SPACE:
return AllocateInNewSpace(object_size, origin, alignment);
......@@ -30,8 +30,8 @@ AllocationResult LocalAllocator::Allocate(AllocationSpace space,
}
}
void LocalAllocator::FreeLast(AllocationSpace space, HeapObject object,
int object_size) {
void EvacuationAllocator::FreeLast(AllocationSpace space, HeapObject object,
int object_size) {
switch (space) {
case NEW_SPACE:
FreeLastInNewSpace(object, object_size);
......@@ -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)) {
// We couldn't free the last object so we have to write a proper filler.
heap_->CreateFillerObjectAt(object.address(), 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)) {
// We couldn't free the last object so we have to write a proper filler.
heap_->CreateFillerObjectAt(object.address(), object_size,
......@@ -61,8 +63,8 @@ void LocalAllocator::FreeLastInOldSpace(HeapObject object, int object_size) {
}
}
AllocationResult LocalAllocator::AllocateInLAB(int object_size,
AllocationAlignment alignment) {
AllocationResult EvacuationAllocator::AllocateInLAB(
int object_size, AllocationAlignment alignment) {
AllocationResult allocation;
if (!new_space_lab_.IsValid() && !NewLocalAllocationBuffer()) {
return AllocationResult::Retry(OLD_SPACE);
......@@ -79,7 +81,7 @@ AllocationResult LocalAllocator::AllocateInLAB(int object_size,
return allocation;
}
bool LocalAllocator::NewLocalAllocationBuffer() {
bool EvacuationAllocator::NewLocalAllocationBuffer() {
if (lab_allocation_will_fail_) return false;
LocalAllocationBuffer saved_lab_ = new_space_lab_;
AllocationResult result =
......@@ -94,7 +96,7 @@ bool LocalAllocator::NewLocalAllocationBuffer() {
return false;
}
AllocationResult LocalAllocator::AllocateInNewSpace(
AllocationResult EvacuationAllocator::AllocateInNewSpace(
int object_size, AllocationOrigin origin, AllocationAlignment alignment) {
if (object_size > kMaxLabObjectSize) {
return new_space_->AllocateRawSynchronized(object_size, alignment, origin);
......
......@@ -12,25 +12,26 @@
namespace v8 {
namespace internal {
// Allocator encapsulating thread-local allocation. Assumes that all other
// allocations also go through LocalAllocator.
class LocalAllocator {
// Allocator encapsulating thread-local allocation durning collection. Assumes
// that all other allocations also go through EvacuationAllocator.
class EvacuationAllocator {
public:
static const int kLabSize = 32 * 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),
new_space_(heap->new_space()),
compaction_spaces_(heap, local_space_kind),
new_space_lab_(LocalAllocationBuffer::InvalidBuffer()),
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() {
heap_->old_space()->MergeLocalSpace(compaction_spaces_.Get(OLD_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.
const LinearAllocationArea info = new_space_lab_.Close();
const Address top = new_space_->top();
......
......@@ -1323,7 +1323,7 @@ class EvacuateVisitorBase : public HeapObjectVisitor {
src.set_map_word(MapWord::FromForwardingAddress(dst));
}
EvacuateVisitorBase(Heap* heap, LocalAllocator* local_allocator,
EvacuateVisitorBase(Heap* heap, EvacuationAllocator* local_allocator,
RecordMigratedSlotVisitor* record_visitor)
: heap_(heap),
local_allocator_(local_allocator),
......@@ -1382,7 +1382,7 @@ class EvacuateVisitorBase : public HeapObjectVisitor {
#endif // VERIFY_HEAP
Heap* heap_;
LocalAllocator* local_allocator_;
EvacuationAllocator* local_allocator_;
RecordMigratedSlotVisitor* record_visitor_;
std::vector<MigrationObserver*> observers_;
MigrateFunction migration_function_;
......@@ -1391,7 +1391,7 @@ class EvacuateVisitorBase : public HeapObjectVisitor {
class EvacuateNewSpaceVisitor final : public EvacuateVisitorBase {
public:
explicit EvacuateNewSpaceVisitor(
Heap* heap, LocalAllocator* local_allocator,
Heap* heap, EvacuationAllocator* local_allocator,
RecordMigratedSlotVisitor* record_visitor,
Heap::PretenuringFeedbackMap* local_pretenuring_feedback,
bool always_promote_young)
......@@ -1545,7 +1545,7 @@ class EvacuateNewSpacePageVisitor final : public HeapObjectVisitor {
class EvacuateOldSpaceVisitor final : public EvacuateVisitorBase {
public:
EvacuateOldSpaceVisitor(Heap* heap, LocalAllocator* local_allocator,
EvacuateOldSpaceVisitor(Heap* heap, EvacuationAllocator* local_allocator,
RecordMigratedSlotVisitor* record_visitor)
: EvacuateVisitorBase(heap, local_allocator, record_visitor) {}
......@@ -2869,7 +2869,7 @@ class Evacuator : public Malloced {
}
Evacuator(Heap* heap, RecordMigratedSlotVisitor* record_visitor,
LocalAllocator* local_allocator, bool always_promote_young)
EvacuationAllocator* local_allocator, bool always_promote_young)
: heap_(heap),
local_pretenuring_feedback_(kInitialLocalPretenuringFeedbackCapacity),
new_space_visitor_(heap_, local_allocator, record_visitor,
......@@ -2927,7 +2927,7 @@ class Evacuator : public Malloced {
EvacuateOldSpaceVisitor old_space_visitor_;
// Locally cached collector data.
LocalAllocator* local_allocator_;
EvacuationAllocator* local_allocator_;
// Book keeping info.
double duration_;
......@@ -3015,7 +3015,7 @@ class FullEvacuator : public Evacuator {
void RawEvacuatePage(MemoryChunk* chunk, intptr_t* live_bytes) override;
EphemeronRememberedSet ephemeron_remembered_set_;
RecordMigratedSlotVisitor record_visitor_;
LocalAllocator local_allocator_;
EvacuationAllocator local_allocator_;
MarkCompactCollector* collector_;
};
......@@ -5049,7 +5049,7 @@ class YoungGenerationEvacuator : public Evacuator {
void RawEvacuatePage(MemoryChunk* chunk, intptr_t* live_bytes) override;
YoungGenerationRecordMigratedSlotVisitor record_visitor_;
LocalAllocator local_allocator_;
EvacuationAllocator local_allocator_;
MinorMarkCompactCollector* collector_;
};
......
......@@ -216,7 +216,7 @@ class Scavenger {
Heap::PretenuringFeedbackMap local_pretenuring_feedback_;
size_t copied_size_;
size_t promoted_size_;
LocalAllocator allocator_;
EvacuationAllocator allocator_;
SurvivingNewLargeObjectsMap surviving_new_large_objects_;
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