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

Unified Diff: src/heap/heap.cc

Issue 1152513002: Generalize alignment in heap GC functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 8b08802f461acd17f24c2e2676a39f2812fcd684..d18a67d88b7f256df14f543d1d676986cd80cfac 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -2148,16 +2148,14 @@ class ScavengingVisitor : public StaticVisitorBase {
}
}
- template <int alignment>
+ template <AllocationAlignment alignment>
static inline bool SemiSpaceCopyObject(Map* map, HeapObject** slot,
HeapObject* object, int object_size) {
Heap* heap = map->GetHeap();
DCHECK(heap->AllowedToBeMigrated(object, NEW_SPACE));
- AllocationAlignment align =
- alignment == kDoubleAlignment ? kDoubleAligned : kWordAligned;
AllocationResult allocation =
- heap->new_space()->AllocateRaw(object_size, align);
+ heap->new_space()->AllocateRaw(object_size, alignment);
HeapObject* target = NULL; // Initialization to please compiler.
if (allocation.To(&target)) {
@@ -2179,15 +2177,13 @@ class ScavengingVisitor : public StaticVisitorBase {
}
- template <ObjectContents object_contents, int alignment>
+ template <ObjectContents object_contents, AllocationAlignment alignment>
static inline bool PromoteObject(Map* map, HeapObject** slot,
HeapObject* object, int object_size) {
Heap* heap = map->GetHeap();
- AllocationAlignment align =
- alignment == kDoubleAlignment ? kDoubleAligned : kWordAligned;
AllocationResult allocation =
- heap->old_space()->AllocateRaw(object_size, align);
+ heap->old_space()->AllocateRaw(object_size, alignment);
HeapObject* target = NULL; // Initialization to please compiler.
if (allocation.To(&target)) {
@@ -2211,7 +2207,7 @@ class ScavengingVisitor : public StaticVisitorBase {
}
- template <ObjectContents object_contents, int alignment>
+ template <ObjectContents object_contents, AllocationAlignment alignment>
static inline void EvacuateObject(Map* map, HeapObject** slot,
HeapObject* object, int object_size) {
SLOW_DCHECK(object_size <= Page::kMaxRegularHeapObjectSize);
@@ -2265,8 +2261,8 @@ class ScavengingVisitor : public StaticVisitorBase {
static inline void EvacuateFixedArray(Map* map, HeapObject** slot,
HeapObject* object) {
int object_size = FixedArray::BodyDescriptor::SizeOf(map, object);
- EvacuateObject<POINTER_OBJECT, kObjectAlignment>(map, slot, object,
- object_size);
+ EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object,
+ object_size);
}
@@ -2274,32 +2270,28 @@ class ScavengingVisitor : public StaticVisitorBase {
HeapObject* object) {
int length = reinterpret_cast<FixedDoubleArray*>(object)->length();
int object_size = FixedDoubleArray::SizeFor(length);
- EvacuateObject<DATA_OBJECT, kDoubleAlignment>(map, slot, object,
- object_size);
+ EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size);
}
static inline void EvacuateFixedTypedArray(Map* map, HeapObject** slot,
HeapObject* object) {
int object_size = reinterpret_cast<FixedTypedArrayBase*>(object)->size();
- EvacuateObject<DATA_OBJECT, kObjectAlignment>(map, slot, object,
- object_size);
+ EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size);
}
static inline void EvacuateFixedFloat64Array(Map* map, HeapObject** slot,
HeapObject* object) {
int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size();
- EvacuateObject<DATA_OBJECT, kDoubleAlignment>(map, slot, object,
- object_size);
+ EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size);
}
static inline void EvacuateByteArray(Map* map, HeapObject** slot,
HeapObject* object) {
int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize();
- EvacuateObject<DATA_OBJECT, kObjectAlignment>(map, slot, object,
- object_size);
+ EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size);
}
@@ -2307,8 +2299,7 @@ class ScavengingVisitor : public StaticVisitorBase {
HeapObject* object) {
int object_size = SeqOneByteString::cast(object)
->SeqOneByteStringSize(map->instance_type());
- EvacuateObject<DATA_OBJECT, kObjectAlignment>(map, slot, object,
- object_size);
+ EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size);
}
@@ -2316,8 +2307,7 @@ class ScavengingVisitor : public StaticVisitorBase {
HeapObject* object) {
int object_size = SeqTwoByteString::cast(object)
->SeqTwoByteStringSize(map->instance_type());
- EvacuateObject<DATA_OBJECT, kObjectAlignment>(map, slot, object,
- object_size);
+ EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size);
}
@@ -2354,8 +2344,8 @@ class ScavengingVisitor : public StaticVisitorBase {
}
int object_size = ConsString::kSize;
- EvacuateObject<POINTER_OBJECT, kObjectAlignment>(map, slot, object,
- object_size);
+ EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object,
+ object_size);
}
template <ObjectContents object_contents>
@@ -2364,14 +2354,14 @@ class ScavengingVisitor : public StaticVisitorBase {
template <int object_size>
static inline void VisitSpecialized(Map* map, HeapObject** slot,
HeapObject* object) {
- EvacuateObject<object_contents, kObjectAlignment>(map, slot, object,
- object_size);
+ EvacuateObject<object_contents, kWordAligned>(map, slot, object,
+ object_size);
}
static inline void Visit(Map* map, HeapObject** slot, HeapObject* object) {
int object_size = map->instance_size();
- EvacuateObject<object_contents, kObjectAlignment>(map, slot, object,
- object_size);
+ EvacuateObject<object_contents, kWordAligned>(map, slot, object,
+ object_size);
}
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698