Respect double alignment in Mark-compact collector.

BUG=chromium:436911
LOG=n

Review URL: https://codereview.chromium.org/1130833002

Cr-Commit-Position: refs/heads/master@{#28274}
This commit is contained in:
hpayer 2015-05-06 10:25:57 -07:00 committed by Commit bot
parent 04b0a96b2b
commit d0423746d6
2 changed files with 30 additions and 2 deletions

View File

@ -1939,6 +1939,8 @@ STATIC_ASSERT((ConstantPoolArray::kFirstEntryOffset & kDoubleAlignmentMask) ==
0); // NOLINT 0); // NOLINT
STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset & STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset &
kDoubleAlignmentMask) == 0); // NOLINT kDoubleAlignmentMask) == 0); // NOLINT
STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) ==
0); // NOLINT
HeapObject* Heap::EnsureDoubleAligned(HeapObject* object, int size) { HeapObject* Heap::EnsureDoubleAligned(HeapObject* object, int size) {

View File

@ -1940,7 +1940,16 @@ int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
continue; continue;
} }
AllocationResult allocation = new_space->AllocateRaw(size); AllocationResult allocation;
#ifndef V8_HOST_ARCH_64_BIT
if (object->NeedsToEnsureDoubleAlignment()) {
allocation = new_space->AllocateRawDoubleAligned(size);
} else {
allocation = new_space->AllocateRaw(size);
}
#else
allocation = new_space->AllocateRaw(size);
#endif
if (allocation.IsRetry()) { if (allocation.IsRetry()) {
if (!new_space->AddFreshPage()) { if (!new_space->AddFreshPage()) {
// Shouldn't happen. We are sweeping linearly, and to-space // Shouldn't happen. We are sweeping linearly, and to-space
@ -1948,7 +1957,15 @@ int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
// always room. // always room.
UNREACHABLE(); UNREACHABLE();
} }
#ifndef V8_HOST_ARCH_64_BIT
if (object->NeedsToEnsureDoubleAlignment()) {
allocation = new_space->AllocateRawDoubleAligned(size);
} else {
allocation = new_space->AllocateRaw(size);
}
#else
allocation = new_space->AllocateRaw(size); allocation = new_space->AllocateRaw(size);
#endif
DCHECK(!allocation.IsRetry()); DCHECK(!allocation.IsRetry());
} }
Object* target = allocation.ToObjectChecked(); Object* target = allocation.ToObjectChecked();
@ -3077,7 +3094,16 @@ bool MarkCompactCollector::TryPromoteObject(HeapObject* object,
OldSpace* old_space = heap()->old_space(); OldSpace* old_space = heap()->old_space();
HeapObject* target; HeapObject* target;
AllocationResult allocation = old_space->AllocateRaw(object_size); AllocationResult allocation;
#ifndef V8_HOST_ARCH_64_BIT
if (object->NeedsToEnsureDoubleAlignment()) {
allocation = old_space->AllocateRawDoubleAligned(object_size);
} else {
allocation = old_space->AllocateRaw(object_size);
}
#else
allocation = old_space->AllocateRaw(object_size);
#endif
if (allocation.To(&target)) { if (allocation.To(&target)) {
MigrateObject(target, object, object_size, old_space->identity()); MigrateObject(target, object, object_size, old_space->identity());
heap()->IncrementPromotedObjectsSize(object_size); heap()->IncrementPromotedObjectsSize(object_size);