| Index: src/heap/heap.cc
|
| diff --git a/src/heap/heap.cc b/src/heap/heap.cc
|
| index b5850271170967281dceddf308021fc936ec7598..b45033a629907085d1c8720dcb5369939a76b29d 100644
|
| --- a/src/heap/heap.cc
|
| +++ b/src/heap/heap.cc
|
| @@ -1972,31 +1972,32 @@ STATIC_ASSERT((HeapNumber::kValueOffset & kDoubleAlignmentMask) !=
|
| #endif
|
|
|
|
|
| -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;
|
| - }
|
| +int Heap::GetAlignmentSize(Address address, AllocationAlignment alignment) {
|
| + intptr_t offset = OffsetFrom(address);
|
| + if (alignment == kDoubleAligned && (offset & kDoubleAlignmentMask) != 0)
|
| + return kPointerSize;
|
| + if (alignment == kDoubleValueAligned && (offset & kDoubleAlignmentMask) == 0)
|
| + return kPointerSize;
|
| + return 0;
|
| }
|
|
|
|
|
| -HeapObject* Heap::PrecedeWithFiller(HeapObject* object) {
|
| - CreateFillerObjectAt(object->address(), kPointerSize);
|
| - return HeapObject::FromAddress(object->address() + kPointerSize);
|
| +HeapObject* Heap::PrecedeWithFiller(HeapObject* object, int fill_size) {
|
| + CreateFillerObjectAt(object->address(), fill_size);
|
| + return HeapObject::FromAddress(object->address() + fill_size);
|
| }
|
|
|
|
|
| HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) {
|
| - return EnsureAligned(object, size, kDoubleAligned);
|
| + Address address = object->address();
|
| + int fill_size = GetAlignmentSize(address, kDoubleAligned);
|
| + // If object is not aligned, add fill to align it.
|
| + if (fill_size) return PrecedeWithFiller(object, kPointerSize);
|
| +
|
| + // object is aligned. Add fill in the extra space at the end.
|
| + // TODO(bbudge) Calculate alignment fill earlier to avoid this.
|
| + CreateFillerObjectAt(address + size - kPointerSize, kPointerSize);
|
| + return object;
|
| }
|
|
|
|
|
| @@ -2847,7 +2848,7 @@ AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode,
|
| HeapObject* result;
|
| {
|
| AllocationResult allocation =
|
| - AllocateRaw(size, space, OLD_SPACE, kDoubleUnaligned);
|
| + AllocateRaw(size, space, OLD_SPACE, kDoubleValueAligned);
|
| if (!allocation.To(&result)) return allocation;
|
| }
|
|
|
|
|