Commit b01b9f4b authored by mlippautz's avatar mlippautz Committed by Commit bot

Revert of [heap] Pass a force_promotion flag to the evacuation routine in the...

Revert of [heap] Pass a force_promotion flag to the evacuation routine in the scavenger. (patchset #3 id:40001 of https://codereview.chromium.org/2002013002/ )

Reason for revert:
Need to revert JSArrayBuffer change. Please rebase and reland.

Original issue's description:
> [heap] Pass a force_promotion flag to the evacuation routine in the scavenger.
>
> The {force_promotion} flag causes the scavenger to move an object to the
> old generation instead of to the other semi-space. We use the flag to force
> the promotion of objects which are referenced by code objects.
>
> R=ulan@chromium.org
>
> Committed: https://crrev.com/f2a7ba6449406d0b11a245aa1f5b4981265b6f20
> Cr-Commit-Position: refs/heads/master@{#36443}

TBR=ulan@chromium.org,ahaas@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.chromium.org/2007563004
Cr-Commit-Position: refs/heads/master@{#36460}
parent 6b9c9157
......@@ -1668,18 +1668,15 @@ void Heap::Scavenge() {
// Copy objects reachable from the old generation.
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS);
RememberedSet<OLD_TO_NEW>::Iterate(this, [this](Address addr) {
return Scavenger::CheckAndScavengeObject(this, addr, DEFAULT_PROMOTION);
return Scavenger::CheckAndScavengeObject(this, addr);
});
RememberedSet<OLD_TO_NEW>::IterateTyped(
this, [this](SlotType type, Address addr) {
return UpdateTypedSlotHelper::UpdateTypedSlot(
isolate(), type, addr, [this](Object** addr) {
// We expect that objects referenced by code are long living.
// If we do not force promotion, then we need to clear
// old_to_new slots in dead code objects after mark-compact.
return Scavenger::CheckAndScavengeObject(
this, reinterpret_cast<Address>(addr), FORCE_PROMOTION);
this, reinterpret_cast<Address>(addr));
});
});
}
......@@ -4668,8 +4665,8 @@ void Heap::IteratePromotedObjectPointers(HeapObject* object, Address start,
Object* target = *slot;
if (target->IsHeapObject()) {
if (Heap::InFromSpace(target)) {
callback(reinterpret_cast<HeapObject**>(slot), HeapObject::cast(target),
DEFAULT_PROMOTION);
callback(reinterpret_cast<HeapObject**>(slot),
HeapObject::cast(target));
Object* new_target = *slot;
if (InNewSpace(new_target)) {
SLOW_DCHECK(Heap::InToSpace(new_target));
......
......@@ -301,10 +301,7 @@ class Scavenger;
class ScavengeJob;
class WeakObjectRetainer;
enum PromotionMode { FORCE_PROMOTION, DEFAULT_PROMOTION };
typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to,
PromotionMode mode);
typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to);
// A queue of objects promoted during scavenge. Each object is accompanied
// by it's size to avoid dereferencing a map pointer for scanning.
......
......@@ -10,8 +10,7 @@
namespace v8 {
namespace internal {
void Scavenger::ScavengeObject(HeapObject** p, HeapObject* object,
PromotionMode promotion_mode) {
void Scavenger::ScavengeObject(HeapObject** p, HeapObject* object) {
DCHECK(object->GetIsolate()->heap()->InFromSpace(object));
// We use the first word (where the map pointer usually is) of a heap
......@@ -35,19 +34,18 @@ void Scavenger::ScavengeObject(HeapObject** p, HeapObject* object,
// AllocationMementos are unrooted and shouldn't survive a scavenge
DCHECK(object->map() != object->GetHeap()->allocation_memento_map());
// Call the slow part of scavenge object.
return ScavengeObjectSlow(p, object, promotion_mode);
return ScavengeObjectSlow(p, object);
}
SlotCallbackResult Scavenger::CheckAndScavengeObject(
Heap* heap, Address slot_address, PromotionMode promotion_mode) {
SlotCallbackResult Scavenger::CheckAndScavengeObject(Heap* heap,
Address slot_address) {
Object** slot = reinterpret_cast<Object**>(slot_address);
Object* object = *slot;
if (heap->InFromSpace(object)) {
HeapObject* heap_object = reinterpret_cast<HeapObject*>(object);
DCHECK(heap_object->IsHeapObject());
ScavengeObject(reinterpret_cast<HeapObject**>(slot), heap_object,
promotion_mode);
ScavengeObject(reinterpret_cast<HeapObject**>(slot), heap_object);
object = *slot;
// If the object was in from space before and is after executing the
......@@ -69,8 +67,7 @@ void StaticScavengeVisitor::VisitPointer(Heap* heap, HeapObject* obj,
Object* object = *p;
if (!heap->InNewSpace(object)) return;
Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p),
reinterpret_cast<HeapObject*>(object),
DEFAULT_PROMOTION);
reinterpret_cast<HeapObject*>(object));
}
} // namespace internal
......
......@@ -200,16 +200,15 @@ class ScavengingVisitor : public StaticVisitorBase {
return false;
}
template <ObjectContents object_contents, AllocationAlignment alignment>
static inline void EvacuateObject(Map* map, HeapObject** slot,
HeapObject* object, int object_size,
PromotionMode promotion_mode) {
HeapObject* object, int object_size) {
SLOW_DCHECK(object_size <= Page::kAllocatableMemory);
SLOW_DCHECK(object->Size() == object_size);
Heap* heap = map->GetHeap();
if (promotion_mode != FORCE_PROMOTION &&
!heap->ShouldBePromoted(object->address(), object_size)) {
if (!heap->ShouldBePromoted(object->address(), object_size)) {
// A semi-space copy may fail due to fragmentation. In that case, we
// try to promote the object.
if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) {
......@@ -221,20 +220,17 @@ class ScavengingVisitor : public StaticVisitorBase {
object_size)) {
return;
}
if (promotion_mode == FORCE_PROMOTION) {
FatalProcessOutOfMemory("Scavenger: forced promotion\n");
}
// If promotion failed, we try to copy the object to the other semi-space
if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) return;
FatalProcessOutOfMemory("Scavenger: semi-space copy\n");
}
static inline void EvacuateJSFunction(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode) {
ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object,
promotion_mode);
HeapObject* object) {
ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object);
if (marks_handling == IGNORE_MARKS) return;
......@@ -256,76 +252,71 @@ class ScavengingVisitor : public StaticVisitorBase {
}
}
static inline void EvacuateFixedArray(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode) {
HeapObject* object) {
int length = reinterpret_cast<FixedArray*>(object)->synchronized_length();
int object_size = FixedArray::SizeFor(length);
EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object, object_size,
promotion_mode);
EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object,
object_size);
}
static inline void EvacuateFixedDoubleArray(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode) {
HeapObject* object) {
int length = reinterpret_cast<FixedDoubleArray*>(object)->length();
int object_size = FixedDoubleArray::SizeFor(length);
EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size,
promotion_mode);
EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size);
}
static inline void EvacuateFixedTypedArray(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode) {
HeapObject* object) {
int object_size = reinterpret_cast<FixedTypedArrayBase*>(object)->size();
EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object, object_size,
promotion_mode);
EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object,
object_size);
}
static inline void EvacuateFixedFloat64Array(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode) {
HeapObject* object) {
int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size();
EvacuateObject<POINTER_OBJECT, kDoubleAligned>(map, slot, object,
object_size, promotion_mode);
object_size);
}
static inline void EvacuateJSArrayBuffer(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode) {
ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object,
promotion_mode);
HeapObject* object) {
ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object);
}
static inline void EvacuateByteArray(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode) {
HeapObject* object) {
int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize();
EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size,
promotion_mode);
EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size);
}
static inline void EvacuateSeqOneByteString(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode) {
HeapObject* object) {
int object_size = SeqOneByteString::cast(object)
->SeqOneByteStringSize(map->instance_type());
EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size,
promotion_mode);
EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size);
}
static inline void EvacuateSeqTwoByteString(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode) {
HeapObject* object) {
int object_size = SeqTwoByteString::cast(object)
->SeqTwoByteStringSize(map->instance_type());
EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size,
promotion_mode);
EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size);
}
static inline void EvacuateShortcutCandidate(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode) {
HeapObject* object) {
DCHECK(IsShortcutCandidate(map->instance_type()));
Heap* heap = map->GetHeap();
......@@ -351,14 +342,14 @@ class ScavengingVisitor : public StaticVisitorBase {
return;
}
Scavenger::ScavengeObjectSlow(slot, first, promotion_mode);
Scavenger::ScavengeObjectSlow(slot, first);
object->set_map_word(MapWord::FromForwardingAddress(*slot));
return;
}
int object_size = ConsString::kSize;
EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object, object_size,
promotion_mode);
EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object,
object_size);
}
template <ObjectContents object_contents>
......@@ -366,17 +357,15 @@ class ScavengingVisitor : public StaticVisitorBase {
public:
template <int object_size>
static inline void VisitSpecialized(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode) {
EvacuateObject<object_contents, kWordAligned>(
map, slot, object, object_size, promotion_mode);
HeapObject* object) {
EvacuateObject<object_contents, kWordAligned>(map, slot, object,
object_size);
}
static inline void Visit(Map* map, HeapObject** slot, HeapObject* object,
PromotionMode promotion_mode) {
static inline void Visit(Map* map, HeapObject** slot, HeapObject* object) {
int object_size = map->instance_size();
EvacuateObject<object_contents, kWordAligned>(
map, slot, object, object_size, promotion_mode);
EvacuateObject<object_contents, kWordAligned>(map, slot, object,
object_size);
}
};
......@@ -402,15 +391,13 @@ void Scavenger::Initialize() {
// static
void Scavenger::ScavengeObjectSlow(HeapObject** p, HeapObject* object,
PromotionMode promotion_mode) {
void Scavenger::ScavengeObjectSlow(HeapObject** p, HeapObject* object) {
SLOW_DCHECK(object->GetIsolate()->heap()->InFromSpace(object));
MapWord first_word = object->map_word();
SLOW_DCHECK(!first_word.IsForwardingAddress());
Map* map = first_word.ToMap();
Scavenger* scavenger = map->GetHeap()->scavenge_collector_;
scavenger->scavenging_visitors_table_.GetVisitor(map)(map, p, object,
promotion_mode);
scavenger->scavenging_visitors_table_.GetVisitor(map)(map, p, object);
}
......
......@@ -12,8 +12,7 @@ namespace v8 {
namespace internal {
typedef void (*ScavengingCallback)(Map* map, HeapObject** slot,
HeapObject* object,
PromotionMode promotion_mode);
HeapObject* object);
class Scavenger {
public:
......@@ -26,15 +25,12 @@ class Scavenger {
// necessary, the object might be promoted to an old space. The caller must
// ensure the precondition that the object is (a) a heap object and (b) in
// the heap's from space.
static inline void ScavengeObject(
HeapObject** p, HeapObject* object,
PromotionMode promotion_mode = DEFAULT_PROMOTION);
static inline SlotCallbackResult CheckAndScavengeObject(
Heap* heap, Address slot_address, PromotionMode promotion_mode);
static inline void ScavengeObject(HeapObject** p, HeapObject* object);
static inline SlotCallbackResult CheckAndScavengeObject(Heap* heap,
Address slot_address);
// Slow part of {ScavengeObject} above.
static void ScavengeObjectSlow(HeapObject** p, HeapObject* object,
PromotionMode promotion_mode);
static void ScavengeObjectSlow(HeapObject** p, HeapObject* object);
// Chooses an appropriate static visitor table depending on the current state
// of the heap (i.e. incremental marking, logging and profiling).
......
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