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

Side by Side Diff: src/heap/heap.cc

Issue 1128323003: Remove explicit double alignment from allocation helper functions. (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 unified diff | Download patch
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/heap-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 3648 matching lines...) Expand 10 before | Expand all | Expand 10 after
3659 3659
3660 3660
3661 AllocationResult Heap::AllocateFixedTypedArray(int length, 3661 AllocationResult Heap::AllocateFixedTypedArray(int length,
3662 ExternalArrayType array_type, 3662 ExternalArrayType array_type,
3663 PretenureFlag pretenure) { 3663 PretenureFlag pretenure) {
3664 int element_size; 3664 int element_size;
3665 ElementsKind elements_kind; 3665 ElementsKind elements_kind;
3666 ForFixedTypedArray(array_type, &element_size, &elements_kind); 3666 ForFixedTypedArray(array_type, &element_size, &elements_kind);
3667 int size = OBJECT_POINTER_ALIGN(length * element_size + 3667 int size = OBJECT_POINTER_ALIGN(length * element_size +
3668 FixedTypedArrayBase::kDataOffset); 3668 FixedTypedArrayBase::kDataOffset);
3669 #ifndef V8_HOST_ARCH_64_BIT
3670 if (array_type == kExternalFloat64Array) {
3671 size += kPointerSize;
3672 }
3673 #endif
3674 AllocationSpace space = SelectSpace(size, pretenure); 3669 AllocationSpace space = SelectSpace(size, pretenure);
3675 3670
3676 HeapObject* object; 3671 HeapObject* object;
3677 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); 3672 AllocationResult allocation = AllocateRaw(
3673 size, space, OLD_SPACE,
3674 array_type == kExternalFloat64Array ? kDoubleAligned : kWordAligned);
3678 if (!allocation.To(&object)) return allocation; 3675 if (!allocation.To(&object)) return allocation;
3679 3676
3680 if (array_type == kExternalFloat64Array) {
3681 object = EnsureDoubleAligned(object, size);
3682 }
3683
3684 object->set_map(MapForFixedTypedArray(array_type)); 3677 object->set_map(MapForFixedTypedArray(array_type));
3685 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object); 3678 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object);
3686 elements->set_length(length); 3679 elements->set_length(length);
3687 memset(elements->DataPtr(), 0, elements->DataSize()); 3680 memset(elements->DataPtr(), 0, elements->DataSize());
3688 return elements; 3681 return elements;
3689 } 3682 }
3690 3683
3691 3684
3692 AllocationResult Heap::AllocateCode(int object_size, bool immovable) { 3685 AllocationResult Heap::AllocateCode(int object_size, bool immovable) {
3693 DCHECK(IsAligned(static_cast<intptr_t>(object_size), kCodeAlignment)); 3686 DCHECK(IsAligned(static_cast<intptr_t>(object_size), kCodeAlignment));
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
4388 4381
4389 elements->set_map_no_write_barrier(fixed_double_array_map()); 4382 elements->set_map_no_write_barrier(fixed_double_array_map());
4390 FixedDoubleArray::cast(elements)->set_length(length); 4383 FixedDoubleArray::cast(elements)->set_length(length);
4391 return elements; 4384 return elements;
4392 } 4385 }
4393 4386
4394 4387
4395 AllocationResult Heap::AllocateRawFixedDoubleArray(int length, 4388 AllocationResult Heap::AllocateRawFixedDoubleArray(int length,
4396 PretenureFlag pretenure) { 4389 PretenureFlag pretenure) {
4397 if (length < 0 || length > FixedDoubleArray::kMaxLength) { 4390 if (length < 0 || length > FixedDoubleArray::kMaxLength) {
4398 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); 4391 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length",
4392 kDoubleAligned);
4399 } 4393 }
4400 int size = FixedDoubleArray::SizeFor(length); 4394 int size = FixedDoubleArray::SizeFor(length);
4401 #ifndef V8_HOST_ARCH_64_BIT
4402 size += kPointerSize;
4403 #endif
4404 AllocationSpace space = SelectSpace(size, pretenure); 4395 AllocationSpace space = SelectSpace(size, pretenure);
4405 4396
4406 HeapObject* object; 4397 HeapObject* object;
4407 { 4398 {
4408 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); 4399 AllocationResult allocation =
4400 AllocateRaw(size, space, OLD_SPACE, kDoubleAligned);
4409 if (!allocation.To(&object)) return allocation; 4401 if (!allocation.To(&object)) return allocation;
4410 } 4402 }
4411 4403
4412 return EnsureDoubleAligned(object, size); 4404 return object;
4413 } 4405 }
4414 4406
4415 4407
4416 AllocationResult Heap::AllocateConstantPoolArray( 4408 AllocationResult Heap::AllocateConstantPoolArray(
4417 const ConstantPoolArray::NumberOfEntries& small) { 4409 const ConstantPoolArray::NumberOfEntries& small) {
4418 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); 4410 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType));
4419 int size = ConstantPoolArray::SizeFor(small); 4411 int size = ConstantPoolArray::SizeFor(small);
4420 #ifndef V8_HOST_ARCH_64_BIT
4421 size += kPointerSize;
4422 #endif
4423 AllocationSpace space = SelectSpace(size, TENURED); 4412 AllocationSpace space = SelectSpace(size, TENURED);
4424 4413
4425 HeapObject* object; 4414 HeapObject* object;
4426 { 4415 {
4427 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); 4416 AllocationResult allocation =
4417 AllocateRaw(size, space, OLD_SPACE, kDoubleAligned);
4428 if (!allocation.To(&object)) return allocation; 4418 if (!allocation.To(&object)) return allocation;
4429 } 4419 }
4430 object = EnsureDoubleAligned(object, size);
4431 object->set_map_no_write_barrier(constant_pool_array_map()); 4420 object->set_map_no_write_barrier(constant_pool_array_map());
4432 4421
4433 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); 4422 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object);
4434 constant_pool->Init(small); 4423 constant_pool->Init(small);
4435 constant_pool->ClearPtrEntries(isolate()); 4424 constant_pool->ClearPtrEntries(isolate());
4436 return constant_pool; 4425 return constant_pool;
4437 } 4426 }
4438 4427
4439 4428
4440 AllocationResult Heap::AllocateExtendedConstantPoolArray( 4429 AllocationResult Heap::AllocateExtendedConstantPoolArray(
4441 const ConstantPoolArray::NumberOfEntries& small, 4430 const ConstantPoolArray::NumberOfEntries& small,
4442 const ConstantPoolArray::NumberOfEntries& extended) { 4431 const ConstantPoolArray::NumberOfEntries& extended) {
4443 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); 4432 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType));
4444 CHECK(extended.are_in_range(0, kMaxInt)); 4433 CHECK(extended.are_in_range(0, kMaxInt));
4445 int size = ConstantPoolArray::SizeForExtended(small, extended); 4434 int size = ConstantPoolArray::SizeForExtended(small, extended);
4446 #ifndef V8_HOST_ARCH_64_BIT
4447 size += kPointerSize;
4448 #endif
4449 AllocationSpace space = SelectSpace(size, TENURED); 4435 AllocationSpace space = SelectSpace(size, TENURED);
4450 4436
4451 HeapObject* object; 4437 HeapObject* object;
4452 { 4438 {
4453 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); 4439 AllocationResult allocation =
4440 AllocateRaw(size, space, OLD_SPACE, kDoubleAligned);
4454 if (!allocation.To(&object)) return allocation; 4441 if (!allocation.To(&object)) return allocation;
4455 } 4442 }
4456 object = EnsureDoubleAligned(object, size);
4457 object->set_map_no_write_barrier(constant_pool_array_map()); 4443 object->set_map_no_write_barrier(constant_pool_array_map());
4458 4444
4459 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); 4445 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object);
4460 constant_pool->InitExtended(small, extended); 4446 constant_pool->InitExtended(small, extended);
4461 constant_pool->ClearPtrEntries(isolate()); 4447 constant_pool->ClearPtrEntries(isolate());
4462 return constant_pool; 4448 return constant_pool;
4463 } 4449 }
4464 4450
4465 4451
4466 AllocationResult Heap::AllocateEmptyConstantPoolArray() { 4452 AllocationResult Heap::AllocateEmptyConstantPoolArray() {
(...skipping 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after
6496 } 6482 }
6497 delete list; 6483 delete list;
6498 } else { 6484 } else {
6499 prev = list; 6485 prev = list;
6500 } 6486 }
6501 list = next; 6487 list = next;
6502 } 6488 }
6503 } 6489 }
6504 } 6490 }
6505 } // namespace v8::internal 6491 } // namespace v8::internal
OLDNEW
« 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