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

Unified Diff: src/heap/scavenger.cc

Issue 2002013002: [heap] Pass a force_promotion flag to the evacuation routine in the scavenger. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. 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
« no previous file with comments | « src/heap/scavenger.h ('k') | src/heap/scavenger-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/scavenger.cc
diff --git a/src/heap/scavenger.cc b/src/heap/scavenger.cc
index 1d785d08d24232388be4d45603d68f9da313c22a..2b0234dd0b9891cbf698d344be1d185231e4556a 100644
--- a/src/heap/scavenger.cc
+++ b/src/heap/scavenger.cc
@@ -200,15 +200,16 @@ 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) {
+ HeapObject* object, int object_size,
+ PromotionMode promotion_mode) {
SLOW_DCHECK(object_size <= Page::kAllocatableMemory);
SLOW_DCHECK(object->Size() == object_size);
Heap* heap = map->GetHeap();
- if (!heap->ShouldBePromoted(object->address(), object_size)) {
+ if (promotion_mode != FORCE_PROMOTION &&
+ !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)) {
@@ -220,17 +221,20 @@ 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) {
- ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object);
+ HeapObject* object,
+ PromotionMode promotion_mode) {
+ ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object,
+ promotion_mode);
if (marks_handling == IGNORE_MARKS) return;
@@ -252,43 +256,45 @@ class ScavengingVisitor : public StaticVisitorBase {
}
}
-
static inline void EvacuateFixedArray(Map* map, HeapObject** slot,
- HeapObject* object) {
+ HeapObject* object,
+ PromotionMode promotion_mode) {
int length = reinterpret_cast<FixedArray*>(object)->synchronized_length();
int object_size = FixedArray::SizeFor(length);
- EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object,
- object_size);
+ EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object, object_size,
+ promotion_mode);
}
-
static inline void EvacuateFixedDoubleArray(Map* map, HeapObject** slot,
- HeapObject* object) {
+ HeapObject* object,
+ PromotionMode promotion_mode) {
int length = reinterpret_cast<FixedDoubleArray*>(object)->length();
int object_size = FixedDoubleArray::SizeFor(length);
- EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size);
+ EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size,
+ promotion_mode);
}
-
static inline void EvacuateFixedTypedArray(Map* map, HeapObject** slot,
- HeapObject* object) {
+ HeapObject* object,
+ PromotionMode promotion_mode) {
int object_size = reinterpret_cast<FixedTypedArrayBase*>(object)->size();
- EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object,
- object_size);
+ EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object, object_size,
+ promotion_mode);
}
-
static inline void EvacuateFixedFloat64Array(Map* map, HeapObject** slot,
- HeapObject* object) {
+ HeapObject* object,
+ PromotionMode promotion_mode) {
int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size();
EvacuateObject<POINTER_OBJECT, kDoubleAligned>(map, slot, object,
- object_size);
+ object_size, promotion_mode);
}
-
static inline void EvacuateJSArrayBuffer(Map* map, HeapObject** slot,
- HeapObject* object) {
- ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object);
+ HeapObject* object,
+ PromotionMode promotion_mode) {
+ ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object,
+ promotion_mode);
Heap* heap = map->GetHeap();
MapWord map_word = object->map_word();
@@ -299,32 +305,35 @@ class ScavengingVisitor : public StaticVisitorBase {
}
}
-
static inline void EvacuateByteArray(Map* map, HeapObject** slot,
- HeapObject* object) {
+ HeapObject* object,
+ PromotionMode promotion_mode) {
int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize();
- EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size);
+ EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size,
+ promotion_mode);
}
-
static inline void EvacuateSeqOneByteString(Map* map, HeapObject** slot,
- HeapObject* object) {
+ HeapObject* object,
+ PromotionMode promotion_mode) {
int object_size = SeqOneByteString::cast(object)
->SeqOneByteStringSize(map->instance_type());
- EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size);
+ EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size,
+ promotion_mode);
}
-
static inline void EvacuateSeqTwoByteString(Map* map, HeapObject** slot,
- HeapObject* object) {
+ HeapObject* object,
+ PromotionMode promotion_mode) {
int object_size = SeqTwoByteString::cast(object)
->SeqTwoByteStringSize(map->instance_type());
- EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size);
+ EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size,
+ promotion_mode);
}
-
static inline void EvacuateShortcutCandidate(Map* map, HeapObject** slot,
- HeapObject* object) {
+ HeapObject* object,
+ PromotionMode promotion_mode) {
DCHECK(IsShortcutCandidate(map->instance_type()));
Heap* heap = map->GetHeap();
@@ -350,14 +359,14 @@ class ScavengingVisitor : public StaticVisitorBase {
return;
}
- Scavenger::ScavengeObjectSlow(slot, first);
+ Scavenger::ScavengeObjectSlow(slot, first, promotion_mode);
object->set_map_word(MapWord::FromForwardingAddress(*slot));
return;
}
int object_size = ConsString::kSize;
- EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object,
- object_size);
+ EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object, object_size,
+ promotion_mode);
}
template <ObjectContents object_contents>
@@ -365,15 +374,17 @@ class ScavengingVisitor : public StaticVisitorBase {
public:
template <int object_size>
static inline void VisitSpecialized(Map* map, HeapObject** slot,
- HeapObject* object) {
- EvacuateObject<object_contents, kWordAligned>(map, slot, object,
- object_size);
+ HeapObject* object,
+ PromotionMode promotion_mode) {
+ EvacuateObject<object_contents, kWordAligned>(
+ map, slot, object, object_size, promotion_mode);
}
- static inline void Visit(Map* map, HeapObject** slot, HeapObject* object) {
+ static inline void Visit(Map* map, HeapObject** slot, HeapObject* object,
+ PromotionMode promotion_mode) {
int object_size = map->instance_size();
- EvacuateObject<object_contents, kWordAligned>(map, slot, object,
- object_size);
+ EvacuateObject<object_contents, kWordAligned>(
+ map, slot, object, object_size, promotion_mode);
}
};
@@ -399,13 +410,15 @@ void Scavenger::Initialize() {
// static
-void Scavenger::ScavengeObjectSlow(HeapObject** p, HeapObject* object) {
+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);
+ scavenger->scavenging_visitors_table_.GetVisitor(map)(map, p, object,
+ promotion_mode);
}
« no previous file with comments | « src/heap/scavenger.h ('k') | src/heap/scavenger-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698