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

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: 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 e801ff94cfb3ab9f4593712a68c62960a6748f3f..407a8565dfff9663f17e37a9fb456e8ab2789d02 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -2144,16 +2144,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)) {
@@ -2175,15 +2173,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)) {
@@ -2207,7 +2203,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);
@@ -2257,12 +2253,17 @@ class ScavengingVisitor : public StaticVisitorBase {
}
}
+#if V8_HOST_ARCH_64_BIT
+#define kObjectAligned kDoubleAligned
Hannes Payer (out of office) 2015/05/22 06:11:12 Why do we need this?
bbudge 2015/05/22 07:34:33 I was confused about word size vs. word aligned, w
+#else
+#define kObjectAligned kWordAligned
+#endif
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, kObjectAligned>(map, slot, object,
Hannes Payer (out of office) 2015/05/22 06:11:13 Why not kWordAligned?
bbudge 2015/05/22 07:34:33 Changed to use kWordAligned.
+ object_size);
}
@@ -2270,32 +2271,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, kObjectAligned>(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, kObjectAligned>(map, slot, object, object_size);
}
@@ -2303,8 +2300,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, kObjectAligned>(map, slot, object, object_size);
}
@@ -2312,8 +2308,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, kObjectAligned>(map, slot, object, object_size);
}
@@ -2350,8 +2345,8 @@ class ScavengingVisitor : public StaticVisitorBase {
}
int object_size = ConsString::kSize;
- EvacuateObject<POINTER_OBJECT, kObjectAlignment>(map, slot, object,
- object_size);
+ EvacuateObject<POINTER_OBJECT, kObjectAligned>(map, slot, object,
+ object_size);
}
template <ObjectContents object_contents>
@@ -2360,14 +2355,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, kObjectAligned>(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, kObjectAligned>(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