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

Unified Diff: src/heap/scavenger.cc

Issue 2005173003: Immediatelly promote marked objects (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove FORCE_PROMOTION Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: src/heap/scavenger.cc
diff --git a/src/heap/scavenger.cc b/src/heap/scavenger.cc
index 2b0234dd0b9891cbf698d344be1d185231e4556a..59291a5a781d4977ff1c66e6d6c08e9a34e81491 100644
--- a/src/heap/scavenger.cc
+++ b/src/heap/scavenger.cc
@@ -23,8 +23,7 @@ enum LoggingAndProfiling {
enum MarksHandling { TRANSFER_MARKS, IGNORE_MARKS };
-
-template <MarksHandling marks_handling,
+template <MarksHandling marks_handling, PromotionMode promotion_mode,
LoggingAndProfiling logging_and_profiling_mode>
class ScavengingVisitor : public StaticVisitorBase {
public:
@@ -202,14 +201,13 @@ class ScavengingVisitor : public StaticVisitorBase {
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<promotion_mode>(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,8 +219,8 @@ class ScavengingVisitor : public StaticVisitorBase {
object_size)) {
return;
}
- if (promotion_mode == FORCE_PROMOTION) {
- FatalProcessOutOfMemory("Scavenger: forced promotion\n");
+ if (promotion_mode == PROMOTE_MARKED) {
+ FatalProcessOutOfMemory("Scavenger: promoting marked\n");
}
// If promotion failed, we try to copy the object to the other semi-space
if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) return;
@@ -231,10 +229,8 @@ class ScavengingVisitor : public StaticVisitorBase {
}
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;
@@ -257,44 +253,37 @@ 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);
Heap* heap = map->GetHeap();
MapWord map_word = object->map_word();
@@ -306,34 +295,27 @@ class ScavengingVisitor : public StaticVisitorBase {
}
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();
@@ -359,14 +341,14 @@ class ScavengingVisitor : public StaticVisitorBase {
return;
}
- Scavenger::ScavengeObjectSlow(slot, first, promotion_mode);
+ Scavenger::ScavengeObjectSlow<promotion_mode>(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>
@@ -374,51 +356,36 @@ 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);
}
};
static VisitorDispatchTable<ScavengingCallback> table_;
};
-
-template <MarksHandling marks_handling,
+template <MarksHandling marks_handling, PromotionMode promotion_mode,
LoggingAndProfiling logging_and_profiling_mode>
-VisitorDispatchTable<ScavengingCallback>
- ScavengingVisitor<marks_handling, logging_and_profiling_mode>::table_;
-
+VisitorDispatchTable<ScavengingCallback> ScavengingVisitor<
+ marks_handling, promotion_mode, logging_and_profiling_mode>::table_;
// static
void Scavenger::Initialize() {
- ScavengingVisitor<TRANSFER_MARKS,
+ ScavengingVisitor<TRANSFER_MARKS, PROMOTE_MARKED,
+ LOGGING_AND_PROFILING_DISABLED>::Initialize();
+ ScavengingVisitor<IGNORE_MARKS, DEFAULT_PROMOTION,
LOGGING_AND_PROFILING_DISABLED>::Initialize();
- ScavengingVisitor<IGNORE_MARKS, LOGGING_AND_PROFILING_DISABLED>::Initialize();
- ScavengingVisitor<TRANSFER_MARKS,
+ ScavengingVisitor<TRANSFER_MARKS, PROMOTE_MARKED,
+ LOGGING_AND_PROFILING_ENABLED>::Initialize();
+ ScavengingVisitor<IGNORE_MARKS, DEFAULT_PROMOTION,
LOGGING_AND_PROFILING_ENABLED>::Initialize();
- ScavengingVisitor<IGNORE_MARKS, LOGGING_AND_PROFILING_ENABLED>::Initialize();
-}
-
-
-// static
-void Scavenger::ScavengeObjectSlow(HeapObject** p, HeapObject* object,
- PromotionMode promotion_mode) {
- 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);
}
@@ -432,21 +399,21 @@ void Scavenger::SelectScavengingVisitorsTable() {
if (!heap()->incremental_marking()->IsMarking()) {
if (!logging_and_profiling) {
scavenging_visitors_table_.CopyFrom(
- ScavengingVisitor<IGNORE_MARKS,
+ ScavengingVisitor<IGNORE_MARKS, DEFAULT_PROMOTION,
LOGGING_AND_PROFILING_DISABLED>::GetTable());
} else {
scavenging_visitors_table_.CopyFrom(
- ScavengingVisitor<IGNORE_MARKS,
+ ScavengingVisitor<IGNORE_MARKS, DEFAULT_PROMOTION,
LOGGING_AND_PROFILING_ENABLED>::GetTable());
}
} else {
if (!logging_and_profiling) {
scavenging_visitors_table_.CopyFrom(
- ScavengingVisitor<TRANSFER_MARKS,
+ ScavengingVisitor<TRANSFER_MARKS, PROMOTE_MARKED,
LOGGING_AND_PROFILING_DISABLED>::GetTable());
} else {
scavenging_visitors_table_.CopyFrom(
- ScavengingVisitor<TRANSFER_MARKS,
+ ScavengingVisitor<TRANSFER_MARKS, PROMOTE_MARKED,
LOGGING_AND_PROFILING_ENABLED>::GetTable());
}
@@ -467,21 +434,5 @@ void Scavenger::SelectScavengingVisitorsTable() {
Isolate* Scavenger::isolate() { return heap()->isolate(); }
-void ScavengeVisitor::VisitPointer(Object** p) { ScavengePointer(p); }
-
-
-void ScavengeVisitor::VisitPointers(Object** start, Object** end) {
- // Copy all HeapObject pointers in [start, end)
- for (Object** p = start; p < end; p++) ScavengePointer(p);
-}
-
-
-void ScavengeVisitor::ScavengePointer(Object** p) {
- Object* object = *p;
- if (!heap_->InNewSpace(object)) return;
- Scavenger::ScavengeObject(reinterpret_cast<HeapObject**>(p),
- reinterpret_cast<HeapObject*>(object));
-}
-
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698