Reviewers: jochen,
Description:
Respect double alignment in Mark-compact collector.
BUG=
Please review this at https://codereview.chromium.org/1130833002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+36, -2 lines):
M src/heap/heap.cc
M src/heap/mark-compact.cc
M src/objects.h
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
22029d63c41a387a44d92cd1d15b8ece61332c3c..cff54748d8868d38f49bf80b69cd8d257bb27478
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -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: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index
85031caeef9781168c42870a52a324be8e3c0291..826242a7a8f8b4c2f19c01ea4800de0a65f11d65
100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -1940,7 +1940,16 @@ int
MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
continue;
}
- AllocationResult allocation = new_space->AllocateRaw(size);
+ AllocationResult allocation;
+#ifndef V8_HOST_ARCH_64_BIT
+ if (object->map()->ShouldDoubleAlign()) {
+ 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->map()->ShouldDoubleAlign()) {
+ 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->map()->ShouldDoubleAlign()) {
+ 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);
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
f56bdb2cff0df7d70bdfa66b4a14244f1c8f53e1..df5c8c615598a581c4c8171b96c46951c74863c1
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -6374,6 +6374,12 @@ class Map: public HeapObject {
return instance_type() >= FIRST_JS_OBJECT_TYPE;
}
+ bool ShouldDoubleAlign() {
+ InstanceType type = instance_type();
+ return type == FIXED_DOUBLE_ARRAY_TYPE ||
+ type == FIXED_FLOAT64_ARRAY_TYPE || type ==
CONSTANT_POOL_ARRAY_TYPE;
+ }
+
bool IsJSObjectMap() {
return instance_type() >= FIRST_JS_OBJECT_TYPE;
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.