Respect double alignment in Mark-compact collector.
authorhpayer <hpayer@chromium.org>
Wed, 6 May 2015 17:25:57 +0000 (10:25 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 6 May 2015 17:26:04 +0000 (17:26 +0000)
BUG=chromium:436911
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#28274}

src/heap/heap.cc
src/heap/mark-compact.cc

index e7f7283..cddd0a2 100644 (file)
@@ -1939,6 +1939,8 @@ STATIC_ASSERT((ConstantPoolArray::kFirstEntryOffset & kDoubleAlignmentMask) ==
               0);  // NOLINT
 STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset &
                kDoubleAlignmentMask) == 0);  // NOLINT
+STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) ==
+              0);  // NOLINT
 
 
 HeapObject* Heap::EnsureDoubleAligned(HeapObject* object, int size) {
index 85031ca..7e02afa 100644 (file)
@@ -1940,7 +1940,16 @@ int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
         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 (!new_space->AddFreshPage()) {
           // Shouldn't happen. We are sweeping linearly, and to-space
@@ -1948,7 +1957,15 @@ int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
           // always room.
           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);
+#endif
         DCHECK(!allocation.IsRetry());
       }
       Object* target = allocation.ToObjectChecked();
@@ -3077,7 +3094,16 @@ bool MarkCompactCollector::TryPromoteObject(HeapObject* object,
   OldSpace* old_space = heap()->old_space();
 
   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)) {
     MigrateObject(target, object, object_size, old_space->identity());
     heap()->IncrementPromotedObjectsSize(object_size);