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

Unified Diff: src/heap/heap.cc

Issue 1150593003: Clean up aligned allocation code in preparation for SIMD alignments. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compile. 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 | « src/heap/heap.h ('k') | src/heap/spaces.h » ('j') | src/heap/spaces-inl.h » ('J')
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 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;
}
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/spaces.h » ('j') | src/heap/spaces-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698