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

Unified Diff: src/heap/heap.cc

Issue 1141523002: Implement unaligned allocate and allocate heap numbers in runtime double unaligned. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/heap-inl.h » ('j') | no next file with comments »
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 2ba75d0f27c6b40eeaec90ca3c2e25c2f0a95cb1..1ccdf3b4a51f7d88e7b0f0a3303ebb06b95fe64e 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -1965,10 +1965,20 @@ STATIC_ASSERT((ConstantPoolArray::kExtendedFirstOffset &
kDoubleAlignmentMask) == 0); // NOLINT
STATIC_ASSERT((FixedTypedArrayBase::kDataOffset & kDoubleAlignmentMask) ==
0); // NOLINT
+#ifdef V8_HOST_ARCH_32_BIT
+STATIC_ASSERT((HeapNumber::kValueOffset & kDoubleAlignmentMask) !=
+ 0); // NOLINT
+#endif
-HeapObject* Heap::EnsureDoubleAligned(HeapObject* object, int size) {
- if ((OffsetFrom(object->address()) & kDoubleAlignmentMask) != 0) {
+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 {
@@ -1978,8 +1988,14 @@ HeapObject* Heap::EnsureDoubleAligned(HeapObject* object, int size) {
}
+HeapObject* Heap::PrecedeWithFiller(HeapObject* object) {
+ CreateFillerObjectAt(object->address(), kPointerSize);
+ return HeapObject::FromAddress(object->address() + kPointerSize);
+}
+
+
HeapObject* Heap::DoubleAlignForDeserialization(HeapObject* object, int size) {
- return EnsureDoubleAligned(object, size);
+ return EnsureAligned(object, size, kDoubleAligned);
}
@@ -2131,9 +2147,10 @@ class ScavengingVisitor : public StaticVisitorBase {
DCHECK(heap->AllowedToBeMigrated(object, NEW_SPACE));
AllocationResult allocation;
-#ifndef V8_HOST_ARCH_64_BIT
+#ifdef V8_HOST_ARCH_32_BIT
if (alignment == kDoubleAlignment) {
- allocation = heap->new_space()->AllocateRawDoubleAligned(object_size);
+ allocation =
+ heap->new_space()->AllocateRawAligned(object_size, kDoubleAligned);
} else {
allocation = heap->new_space()->AllocateRaw(object_size);
}
@@ -2167,9 +2184,10 @@ class ScavengingVisitor : public StaticVisitorBase {
Heap* heap = map->GetHeap();
AllocationResult allocation;
-#ifndef V8_HOST_ARCH_64_BIT
+#ifdef V8_HOST_ARCH_32_BIT
if (alignment == kDoubleAlignment) {
- allocation = heap->old_space()->AllocateRawDoubleAligned(object_size);
+ allocation =
+ heap->old_space()->AllocateRawAligned(object_size, kDoubleAligned);
} else {
allocation = heap->old_space()->AllocateRaw(object_size);
}
@@ -2840,7 +2858,8 @@ AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode,
HeapObject* result;
{
- AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
+ AllocationResult allocation =
+ AllocateRaw(size, space, OLD_SPACE, kDoubleUnaligned);
if (!allocation.To(&result)) return allocation;
}
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698