Reviewers: jochen,
Description:
Remove explicit double alignment from allocation helper functions.
BUG=
Please review this at https://codereview.chromium.org/1128323003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+26, -27 lines):
M src/heap/heap.h
M src/heap/heap.cc
M src/heap/heap-inl.h
Index: src/heap/heap-inl.h
diff --git a/src/heap/heap-inl.h b/src/heap/heap-inl.h
index
38deb1f31df4c49b8325dd79a04e4ce813116e72..3a72d95e92c406cc399669da63b86a41f9ab1ca6
100644
--- a/src/heap/heap-inl.h
+++ b/src/heap/heap-inl.h
@@ -156,7 +156,8 @@ AllocationResult
Heap::CopyConstantPoolArray(ConstantPoolArray* src) {
AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationSpace
space,
- AllocationSpace retry_space) {
+ AllocationSpace retry_space,
+ bool double_align) {
DCHECK(AllowHandleAllocation::IsAllowed());
DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK(gc_state_ == NOT_IN_GC);
@@ -172,7 +173,15 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes,
AllocationSpace space,
HeapObject* object;
AllocationResult allocation;
if (NEW_SPACE == space) {
+#ifndef V8_HOST_ARCH_64_BIT
+ if (double_align) {
+ allocation = new_space_.AllocateRawDoubleAligned(size_in_bytes);
+ } else {
+ allocation = new_space_.AllocateRaw(size_in_bytes);
+ }
+#else
allocation = new_space_.AllocateRaw(size_in_bytes);
+#endif
if (always_allocate() && allocation.IsRetry() && retry_space !=
NEW_SPACE) {
space = retry_space;
} else {
@@ -184,7 +193,15 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes,
AllocationSpace space,
}
if (OLD_SPACE == space) {
+#ifndef V8_HOST_ARCH_64_BIT
+ if (double_align) {
+ allocation = old_space_->AllocateRawDoubleAligned(size_in_bytes);
+ } else {
+ allocation = old_space_->AllocateRaw(size_in_bytes);
+ }
+#else
allocation = old_space_->AllocateRaw(size_in_bytes);
+#endif
} else if (CODE_SPACE == space) {
if (size_in_bytes <= code_space()->AreaSize()) {
allocation = code_space_->AllocateRaw(size_in_bytes);
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
bfd1fb50958ee8288422606051700c4324438775..992967f2f537b07b39c0777b1fa668aff05b7cbf
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -3666,21 +3666,13 @@ AllocationResult Heap::AllocateFixedTypedArray(int
length,
ForFixedTypedArray(array_type, &element_size, &elements_kind);
int size = OBJECT_POINTER_ALIGN(length * element_size +
FixedTypedArrayBase::kDataOffset);
-#ifndef V8_HOST_ARCH_64_BIT
- if (array_type == kExternalFloat64Array) {
- size += kPointerSize;
- }
-#endif
AllocationSpace space = SelectSpace(size, pretenure);
HeapObject* object;
- AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
+ AllocationResult allocation =
+ AllocateRaw(size, space, OLD_SPACE, array_type ==
kExternalFloat64Array);
if (!allocation.To(&object)) return allocation;
- if (array_type == kExternalFloat64Array) {
- object = EnsureDoubleAligned(object, size);
- }
-
object->set_map(MapForFixedTypedArray(array_type));
FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object);
elements->set_length(length);
@@ -4398,18 +4390,15 @@ AllocationResult
Heap::AllocateRawFixedDoubleArray(int length,
v8::internal::Heap::FatalProcessOutOfMemory("invalid array length",
true);
}
int size = FixedDoubleArray::SizeFor(length);
-#ifndef V8_HOST_ARCH_64_BIT
- size += kPointerSize;
-#endif
AllocationSpace space = SelectSpace(size, pretenure);
HeapObject* object;
{
- AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
+ AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE,
true);
if (!allocation.To(&object)) return allocation;
}
- return EnsureDoubleAligned(object, size);
+ return object;
}
@@ -4417,17 +4406,13 @@ AllocationResult Heap::AllocateConstantPoolArray(
const ConstantPoolArray::NumberOfEntries& small) {
CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType));
int size = ConstantPoolArray::SizeFor(small);
-#ifndef V8_HOST_ARCH_64_BIT
- size += kPointerSize;
-#endif
AllocationSpace space = SelectSpace(size, TENURED);
HeapObject* object;
{
- AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
+ AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE,
true);
if (!allocation.To(&object)) return allocation;
}
- object = EnsureDoubleAligned(object, size);
object->set_map_no_write_barrier(constant_pool_array_map());
ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object);
@@ -4443,17 +4428,13 @@ AllocationResult
Heap::AllocateExtendedConstantPoolArray(
CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType));
CHECK(extended.are_in_range(0, kMaxInt));
int size = ConstantPoolArray::SizeForExtended(small, extended);
-#ifndef V8_HOST_ARCH_64_BIT
- size += kPointerSize;
-#endif
AllocationSpace space = SelectSpace(size, TENURED);
HeapObject* object;
{
- AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
+ AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE,
true);
if (!allocation.To(&object)) return allocation;
}
- object = EnsureDoubleAligned(object, size);
object->set_map_no_write_barrier(constant_pool_array_map());
ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object);
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index
dfbcc701e6939f5a7215d19c9118f09440fe9121..ded8a010800bea1be4a151087d590b59038f5a09
100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -1820,7 +1820,8 @@ class Heap {
// performed by the runtime and should not be bypassed (to extend this to
// inlined allocations, use the Heap::DisableInlineAllocation() support).
MUST_USE_RESULT inline AllocationResult AllocateRaw(
- int size_in_bytes, AllocationSpace space, AllocationSpace
retry_space);
+ int size_in_bytes, AllocationSpace space, AllocationSpace
retry_space,
+ bool double_align = false);
// Allocates a heap object based on the map.
MUST_USE_RESULT AllocationResult
--
--
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.