Index: src/heap/heap.cc |
diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
index 76cab33693938e23fd949ec7d1b8f82e10fe7175..09f4cc71278e39c57be57099f4c08aedcef34cbd 100644 |
--- a/src/heap/heap.cc |
+++ b/src/heap/heap.cc |
@@ -1982,54 +1982,31 @@ |
#endif |
-int Heap::GetMaximumFillToAlign(AllocationAlignment alignment) { |
- switch (alignment) { |
- case kWordAligned: |
- return 0; |
- case kDoubleAligned: |
- case kDoubleUnaligned: |
- return kDoubleSize - kPointerSize; |
- default: |
- UNREACHABLE(); |
- } |
- return 0; |
-} |
- |
- |
-int Heap::GetFillToAlign(Address address, AllocationAlignment alignment) { |
- intptr_t offset = OffsetFrom(address); |
- if (alignment == kDoubleAligned && (offset & kDoubleAlignmentMask) != 0) |
- return kPointerSize; |
- if (alignment == kDoubleUnaligned && (offset & kDoubleAlignmentMask) == 0) |
- return kDoubleSize - kPointerSize; // No fill if double is always aligned. |
- return 0; |
-} |
- |
- |
-HeapObject* Heap::PrecedeWithFiller(HeapObject* object, int filler_size) { |
- CreateFillerObjectAt(object->address(), filler_size); |
- return HeapObject::FromAddress(object->address() + filler_size); |
-} |
- |
- |
-HeapObject* Heap::AlignWithFiller(HeapObject* object, int object_size, |
- int allocation_size, |
- AllocationAlignment alignment) { |
- int filler_size = allocation_size - object_size; |
- DCHECK(filler_size > 0); |
- int pre_filler = GetFillToAlign(object->address(), alignment); |
- if (pre_filler) { |
- object = PrecedeWithFiller(object, pre_filler); |
- filler_size -= pre_filler; |
- } |
- if (filler_size) |
- CreateFillerObjectAt(object->address() + object_size, filler_size); |
- return object; |
+HeapObject* Heap::EnsureAligned(HeapObject* object, int size, |
+ AllocationAlignment alignment) { |
+ if (alignment == kDoubleAligned && |
+ (OffsetFrom(object->address()) & kDoubleAlignmentMask) != 0) { |
+ CreateFillerObjectAt(object->address(), kPointerSize); |
+ return HeapObject::FromAddress(object->address() + kPointerSize); |
+ } else if (alignment == kDoubleUnaligned && |
+ (OffsetFrom(object->address()) & kDoubleAlignmentMask) == 0) { |
+ CreateFillerObjectAt(object->address(), kPointerSize); |
+ return HeapObject::FromAddress(object->address() + kPointerSize); |
+ } else { |
+ CreateFillerObjectAt(object->address() + size - kPointerSize, kPointerSize); |
+ return object; |
+ } |
+} |
+ |
+ |
+HeapObject* Heap::PrecedeWithFiller(HeapObject* object) { |
+ CreateFillerObjectAt(object->address(), kPointerSize); |
+ return HeapObject::FromAddress(object->address() + kPointerSize); |
} |
HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) { |
- return AlignWithFiller(object, size, size + kPointerSize, kDoubleAligned); |
+ return EnsureAligned(object, size, kDoubleAligned); |
} |