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

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
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 =
3673 AllocateRaw(size, space, OLD_SPACE, array_type == kExternalFloat64Array);
3678 if (!allocation.To(&object)) return allocation; 3674 if (!allocation.To(&object)) return allocation;
3679 3675
3680 if (array_type == kExternalFloat64Array) {
3681 object = EnsureDoubleAligned(object, size);
3682 }
3683
3684 object->set_map(MapForFixedTypedArray(array_type)); 3676 object->set_map(MapForFixedTypedArray(array_type));
3685 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object); 3677 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object);
3686 elements->set_length(length); 3678 elements->set_length(length);
3687 memset(elements->DataPtr(), 0, elements->DataSize()); 3679 memset(elements->DataPtr(), 0, elements->DataSize());
3688 return elements; 3680 return elements;
3689 } 3681 }
3690 3682
3691 3683
3692 AllocationResult Heap::AllocateCode(int object_size, bool immovable) { 3684 AllocationResult Heap::AllocateCode(int object_size, bool immovable) {
3693 DCHECK(IsAligned(static_cast<intptr_t>(object_size), kCodeAlignment)); 3685 DCHECK(IsAligned(static_cast<intptr_t>(object_size), kCodeAlignment));
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
4391 return elements; 4383 return elements;
4392 } 4384 }
4393 4385
4394 4386
4395 AllocationResult Heap::AllocateRawFixedDoubleArray(int length, 4387 AllocationResult Heap::AllocateRawFixedDoubleArray(int length,
4396 PretenureFlag pretenure) { 4388 PretenureFlag pretenure) {
4397 if (length < 0 || length > FixedDoubleArray::kMaxLength) { 4389 if (length < 0 || length > FixedDoubleArray::kMaxLength) {
4398 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); 4390 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true);
4399 } 4391 }
4400 int size = FixedDoubleArray::SizeFor(length); 4392 int size = FixedDoubleArray::SizeFor(length);
4401 #ifndef V8_HOST_ARCH_64_BIT
4402 size += kPointerSize;
4403 #endif
4404 AllocationSpace space = SelectSpace(size, pretenure); 4393 AllocationSpace space = SelectSpace(size, pretenure);
4405 4394
4406 HeapObject* object; 4395 HeapObject* object;
4407 { 4396 {
4408 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); 4397 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE, true);
4409 if (!allocation.To(&object)) return allocation; 4398 if (!allocation.To(&object)) return allocation;
4410 } 4399 }
4411 4400
4412 return EnsureDoubleAligned(object, size); 4401 return object;
4413 } 4402 }
4414 4403
4415 4404
4416 AllocationResult Heap::AllocateConstantPoolArray( 4405 AllocationResult Heap::AllocateConstantPoolArray(
4417 const ConstantPoolArray::NumberOfEntries& small) { 4406 const ConstantPoolArray::NumberOfEntries& small) {
4418 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); 4407 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType));
4419 int size = ConstantPoolArray::SizeFor(small); 4408 int size = ConstantPoolArray::SizeFor(small);
4420 #ifndef V8_HOST_ARCH_64_BIT
4421 size += kPointerSize;
4422 #endif
4423 AllocationSpace space = SelectSpace(size, TENURED); 4409 AllocationSpace space = SelectSpace(size, TENURED);
4424 4410
4425 HeapObject* object; 4411 HeapObject* object;
4426 { 4412 {
4427 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); 4413 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE, true);
4428 if (!allocation.To(&object)) return allocation; 4414 if (!allocation.To(&object)) return allocation;
4429 } 4415 }
4430 object = EnsureDoubleAligned(object, size);
4431 object->set_map_no_write_barrier(constant_pool_array_map()); 4416 object->set_map_no_write_barrier(constant_pool_array_map());
4432 4417
4433 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); 4418 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object);
4434 constant_pool->Init(small); 4419 constant_pool->Init(small);
4435 constant_pool->ClearPtrEntries(isolate()); 4420 constant_pool->ClearPtrEntries(isolate());
4436 return constant_pool; 4421 return constant_pool;
4437 } 4422 }
4438 4423
4439 4424
4440 AllocationResult Heap::AllocateExtendedConstantPoolArray( 4425 AllocationResult Heap::AllocateExtendedConstantPoolArray(
4441 const ConstantPoolArray::NumberOfEntries& small, 4426 const ConstantPoolArray::NumberOfEntries& small,
4442 const ConstantPoolArray::NumberOfEntries& extended) { 4427 const ConstantPoolArray::NumberOfEntries& extended) {
4443 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); 4428 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType));
4444 CHECK(extended.are_in_range(0, kMaxInt)); 4429 CHECK(extended.are_in_range(0, kMaxInt));
4445 int size = ConstantPoolArray::SizeForExtended(small, extended); 4430 int size = ConstantPoolArray::SizeForExtended(small, extended);
4446 #ifndef V8_HOST_ARCH_64_BIT
4447 size += kPointerSize;
4448 #endif
4449 AllocationSpace space = SelectSpace(size, TENURED); 4431 AllocationSpace space = SelectSpace(size, TENURED);
4450 4432
4451 HeapObject* object; 4433 HeapObject* object;
4452 { 4434 {
4453 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); 4435 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE, true);
4454 if (!allocation.To(&object)) return allocation; 4436 if (!allocation.To(&object)) return allocation;
4455 } 4437 }
4456 object = EnsureDoubleAligned(object, size);
4457 object->set_map_no_write_barrier(constant_pool_array_map()); 4438 object->set_map_no_write_barrier(constant_pool_array_map());
4458 4439
4459 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); 4440 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object);
4460 constant_pool->InitExtended(small, extended); 4441 constant_pool->InitExtended(small, extended);
4461 constant_pool->ClearPtrEntries(isolate()); 4442 constant_pool->ClearPtrEntries(isolate());
4462 return constant_pool; 4443 return constant_pool;
4463 } 4444 }
4464 4445
4465 4446
4466 AllocationResult Heap::AllocateEmptyConstantPoolArray() { 4447 AllocationResult Heap::AllocateEmptyConstantPoolArray() {
(...skipping 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after
6496 } 6477 }
6497 delete list; 6478 delete list;
6498 } else { 6479 } else {
6499 prev = list; 6480 prev = list;
6500 } 6481 }
6501 list = next; 6482 list = next;
6502 } 6483 }
6503 } 6484 }
6504 } 6485 }
6505 } // namespace v8::internal 6486 } // namespace v8::internal
OLDNEW
« src/heap/heap.h ('K') | « 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