Reviewers: Hannes Payer,
Description:
Generalize alignment in heap GC functions.
Changes template parameters from int to AllocationAlignment.
LOG=N
BUG=v8:4124
Please review this at https://codereview.chromium.org/1152513002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+24, -29 lines):
M src/heap/heap.cc
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
+#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,
+ 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);
}
};
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.