[heap] Update allocation sites after migrating and object

Bug: chromium:738865
Change-Id: I065c4e63a437daaeba8b42826f91ddd5c1b542e4
Reviewed-on: https://chromium-review.googlesource.com/570161
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46633}
This commit is contained in:
Michael Lippautz 2017-07-13 14:27:20 +02:00 committed by Commit Bot
parent 5d16e866e7
commit eaa47e1c08
6 changed files with 18 additions and 18 deletions

View File

@ -458,9 +458,9 @@ void Heap::CopyBlock(Address dst, Address src, int byte_size) {
}
template <Heap::FindMementoMode mode>
AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) {
AllocationMemento* Heap::FindAllocationMemento(Map* map, HeapObject* object) {
Address object_address = object->address();
Address memento_address = object_address + object->Size();
Address memento_address = object_address + object->SizeFromMap(map);
Address last_memento_word_address = memento_address + kPointerSize;
// If the memento would be on another page, bail out immediately.
if (!Page::OnSamePage(object_address, last_memento_word_address)) {
@ -519,7 +519,7 @@ AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) {
}
template <Heap::UpdateAllocationSiteMode mode>
void Heap::UpdateAllocationSite(HeapObject* object,
void Heap::UpdateAllocationSite(Map* map, HeapObject* object,
base::HashMap* pretenuring_feedback) {
DCHECK(InFromSpace(object) ||
(InToSpace(object) &&
@ -529,9 +529,10 @@ void Heap::UpdateAllocationSite(HeapObject* object,
Page::FromAddress(object->address())
->IsFlagSet(Page::PAGE_NEW_OLD_PROMOTION)));
if (!FLAG_allocation_site_pretenuring ||
!AllocationSite::CanTrack(object->map()->instance_type()))
!AllocationSite::CanTrack(map->instance_type()))
return;
AllocationMemento* memento_candidate = FindAllocationMemento<kForGC>(object);
AllocationMemento* memento_candidate =
FindAllocationMemento<kForGC>(map, object);
if (memento_candidate == nullptr) return;
if (mode == kGlobal) {

View File

@ -780,7 +780,7 @@ class Heap {
// If an object has an AllocationMemento trailing it, return it, otherwise
// return NULL;
template <FindMementoMode mode>
inline AllocationMemento* FindAllocationMemento(HeapObject* object);
inline AllocationMemento* FindAllocationMemento(Map* map, HeapObject* object);
// Returns false if not able to reserve.
bool ReserveSpace(Reservation* reservations, List<Address>* maps);
@ -1457,7 +1457,7 @@ class Heap {
// in the hash map is created. Otherwise the entry (including a the count
// value) is cached on the local pretenuring feedback.
template <UpdateAllocationSiteMode mode>
inline void UpdateAllocationSite(HeapObject* object,
inline void UpdateAllocationSite(Map* map, HeapObject* object,
base::HashMap* pretenuring_feedback);
// Removes an entry from the global pretenuring storage.

View File

@ -1699,7 +1699,7 @@ class EvacuateNewSpaceVisitor final : public EvacuateVisitorBase {
promoted_size_ += size;
return true;
}
heap_->UpdateAllocationSite<Heap::kCached>(object,
heap_->UpdateAllocationSite<Heap::kCached>(object->map(), object,
local_pretenuring_feedback_);
HeapObject* target = nullptr;
AllocationSpace space = AllocateTargetObject(object, size, &target);
@ -1845,7 +1845,7 @@ class EvacuateNewSpacePageVisitor final : public HeapObjectVisitor {
inline bool Visit(HeapObject* object, int size) {
if (mode == NEW_TO_NEW) {
heap_->UpdateAllocationSite<Heap::kCached>(object,
heap_->UpdateAllocationSite<Heap::kCached>(object->map(), object,
local_pretenuring_feedback_);
} else if (mode == NEW_TO_OLD) {
object->IterateBodyFast(record_visitor_);

View File

@ -34,7 +34,7 @@ bool ContainsOnlyData(VisitorId visitor_id) {
} // namespace
void Scavenger::MigrateObject(HeapObject* source, HeapObject* target,
void Scavenger::MigrateObject(Map* map, HeapObject* source, HeapObject* target,
int size) {
// If we migrate into to-space, then the to-space top pointer should be
// right after the target object. Incorporate double alignment
@ -58,6 +58,8 @@ void Scavenger::MigrateObject(HeapObject* source, HeapObject* target,
if (is_incremental_marking_) {
heap()->incremental_marking()->TransferColor(source, target);
}
heap()->UpdateAllocationSite<Heap::kCached>(map, source,
&local_pretenuring_feedback_);
}
bool Scavenger::SemiSpaceCopyObject(Map* map, HeapObject** slot,
@ -71,7 +73,7 @@ bool Scavenger::SemiSpaceCopyObject(Map* map, HeapObject** slot,
if (allocation.To(&target)) {
DCHECK(ObjectMarking::IsWhite(
target, heap()->mark_compact_collector()->marking_state(target)));
MigrateObject(object, target, object_size);
MigrateObject(map, object, target, object_size);
*slot = target;
copied_list_.Insert(target, object_size);
@ -91,7 +93,7 @@ bool Scavenger::PromoteObject(Map* map, HeapObject** slot, HeapObject* object,
if (allocation.To(&target)) {
DCHECK(ObjectMarking::IsWhite(
target, heap()->mark_compact_collector()->marking_state(target)));
MigrateObject(object, target, object_size);
MigrateObject(map, object, target, object_size);
*slot = target;
if (!ContainsOnlyData(static_cast<VisitorId>(map->visitor_id()))) {
@ -106,7 +108,7 @@ bool Scavenger::PromoteObject(Map* map, HeapObject** slot, HeapObject* object,
void Scavenger::EvacuateObjectDefault(Map* map, HeapObject** slot,
HeapObject* object, int object_size) {
SLOW_DCHECK(object_size <= Page::kAllocatableMemory);
SLOW_DCHECK(object->Size() == object_size);
SLOW_DCHECK(object->SizeFromMap(map) == object_size);
if (!heap()->ShouldBePromoted(object->address())) {
// A semi-space copy may fail due to fragmentation. In that case, we
@ -235,9 +237,6 @@ void Scavenger::ScavengeObject(HeapObject** p, HeapObject* object) {
return;
}
heap()->UpdateAllocationSite<Heap::kCached>(object,
&local_pretenuring_feedback_);
Map* map = first_word.ToMap();
// AllocationMementos are unrooted and shouldn't survive a scavenge
DCHECK_NE(heap()->allocation_memento_map(), map);

View File

@ -101,7 +101,7 @@ class Scavenger {
inline Heap* heap() { return heap_; }
// Copies |source| to |target| and sets the forwarding pointer in |source|.
V8_INLINE void MigrateObject(HeapObject* source, HeapObject* target,
V8_INLINE void MigrateObject(Map* map, HeapObject* source, HeapObject* target,
int size);
V8_INLINE bool SemiSpaceCopyObject(Map* map, HeapObject** slot,

View File

@ -15809,7 +15809,7 @@ bool JSObject::UpdateAllocationSite(Handle<JSObject> object,
DisallowHeapAllocation no_allocation;
AllocationMemento* memento =
heap->FindAllocationMemento<Heap::kForRuntime>(*object);
heap->FindAllocationMemento<Heap::kForRuntime>(object->map(), *object);
if (memento == NULL) return false;
// Walk through to the Allocation Site