Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index b7a59189e451fdfeb8ebfdcb1238da62b910f681..89edfd72cf58a545a305160cbf43aa557daf584b 100644 |
--- a/src/heap.cc |
+++ b/src/heap.cc |
@@ -1786,7 +1786,10 @@ Address Heap::DoScavenge(ObjectVisitor* scavenge_visitor, |
STATIC_ASSERT((FixedDoubleArray::kHeaderSize & kDoubleAlignmentMask) == 0); |
-STATIC_ASSERT((ConstantPoolArray::kHeaderSize & kDoubleAlignmentMask) == 0); |
+STATIC_ASSERT( |
+ (ConstantPoolArray::kFirstEntryOffset & kDoubleAlignmentMask) == 0); |
+STATIC_ASSERT( |
+ (ConstantPoolArray::kExtendedFirstOffset & kDoubleAlignmentMask) == 0); |
INLINE(static HeapObject* EnsureDoubleAligned(Heap* heap, |
@@ -4027,23 +4030,45 @@ AllocationResult Heap::CopyFixedDoubleArrayWithMap(FixedDoubleArray* src, |
AllocationResult Heap::CopyConstantPoolArrayWithMap(ConstantPoolArray* src, |
Map* map) { |
- int int64_entries = src->count_of_int64_entries(); |
- int code_ptr_entries = src->count_of_code_ptr_entries(); |
- int heap_ptr_entries = src->count_of_heap_ptr_entries(); |
- int int32_entries = src->count_of_int32_entries(); |
HeapObject* obj; |
- { AllocationResult allocation = |
- AllocateConstantPoolArray(int64_entries, code_ptr_entries, |
- heap_ptr_entries, int32_entries); |
+ if (src->is_extended_layout()) { |
+ AllocationResult allocation = |
+ AllocateExtendedConstantPoolArray( |
+ src->number_of_entries(ConstantPoolArray::INT64, |
+ ConstantPoolArray::SMALL_SECTION), |
+ src->number_of_entries(ConstantPoolArray::CODE_PTR, |
+ ConstantPoolArray::SMALL_SECTION), |
+ src->number_of_entries(ConstantPoolArray::HEAP_PTR, |
+ ConstantPoolArray::SMALL_SECTION), |
+ src->number_of_entries(ConstantPoolArray::INT32, |
+ ConstantPoolArray::SMALL_SECTION), |
+ src->number_of_entries(ConstantPoolArray::INT64, |
+ ConstantPoolArray::EXTENDED_SECTION), |
+ src->number_of_entries(ConstantPoolArray::CODE_PTR, |
+ ConstantPoolArray::EXTENDED_SECTION), |
+ src->number_of_entries(ConstantPoolArray::HEAP_PTR, |
+ ConstantPoolArray::EXTENDED_SECTION), |
+ src->number_of_entries(ConstantPoolArray::INT64, |
+ ConstantPoolArray::EXTENDED_SECTION)); |
+ if (!allocation.To(&obj)) return allocation; |
+ } else { |
+ AllocationResult allocation = |
+ AllocateConstantPoolArray( |
+ src->number_of_entries(ConstantPoolArray::INT64, |
+ ConstantPoolArray::SMALL_SECTION), |
+ src->number_of_entries(ConstantPoolArray::CODE_PTR, |
+ ConstantPoolArray::SMALL_SECTION), |
+ src->number_of_entries(ConstantPoolArray::HEAP_PTR, |
+ ConstantPoolArray::SMALL_SECTION), |
+ src->number_of_entries(ConstantPoolArray::INT32, |
+ ConstantPoolArray::SMALL_SECTION)); |
if (!allocation.To(&obj)) return allocation; |
} |
obj->set_map_no_write_barrier(map); |
- int size = ConstantPoolArray::SizeFor( |
- int64_entries, code_ptr_entries, heap_ptr_entries, int32_entries); |
CopyBlock( |
- obj->address() + ConstantPoolArray::kLengthOffset, |
- src->address() + ConstantPoolArray::kLengthOffset, |
- size - ConstantPoolArray::kLengthOffset); |
+ obj->address() + ConstantPoolArray::kFirstEntryOffset, |
+ src->address() + ConstantPoolArray::kFirstEntryOffset, |
+ src->size() - ConstantPoolArray::kFirstEntryOffset); |
return obj; |
} |
@@ -4135,22 +4160,22 @@ AllocationResult Heap::AllocateRawFixedDoubleArray(int length, |
} |
-AllocationResult Heap::AllocateConstantPoolArray(int number_of_int64_entries, |
- int number_of_code_ptr_entries, |
- int number_of_heap_ptr_entries, |
- int number_of_int32_entries) { |
- CHECK(number_of_int64_entries >= 0 && |
- number_of_int64_entries <= ConstantPoolArray::kMaxEntriesPerType && |
- number_of_code_ptr_entries >= 0 && |
- number_of_code_ptr_entries <= ConstantPoolArray::kMaxEntriesPerType && |
- number_of_heap_ptr_entries >= 0 && |
- number_of_heap_ptr_entries <= ConstantPoolArray::kMaxEntriesPerType && |
- number_of_int32_entries >= 0 && |
- number_of_int32_entries <= ConstantPoolArray::kMaxEntriesPerType); |
- int size = ConstantPoolArray::SizeFor(number_of_int64_entries, |
- number_of_code_ptr_entries, |
- number_of_heap_ptr_entries, |
- number_of_int32_entries); |
+AllocationResult Heap::AllocateConstantPoolArray(int int64_count, |
+ int code_ptr_count, |
+ int heap_ptr_count, |
+ int int32_count) { |
+ CHECK(int64_count >= 0 && |
+ int64_count <= ConstantPoolArray::kMaxSmallEntriesPerType && |
+ code_ptr_count >= 0 && |
+ code_ptr_count <= ConstantPoolArray::kMaxSmallEntriesPerType && |
+ heap_ptr_count >= 0 && |
+ heap_ptr_count <= ConstantPoolArray::kMaxSmallEntriesPerType && |
+ int32_count >= 0 && |
+ int32_count <= ConstantPoolArray::kMaxSmallEntriesPerType); |
+ int size = ConstantPoolArray::SizeFor(int64_count, |
+ code_ptr_count, |
+ heap_ptr_count, |
+ int32_count); |
#ifndef V8_HOST_ARCH_64_BIT |
size += kPointerSize; |
#endif |
@@ -4164,26 +4189,65 @@ AllocationResult Heap::AllocateConstantPoolArray(int number_of_int64_entries, |
object->set_map_no_write_barrier(constant_pool_array_map()); |
ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); |
- constant_pool->Init(number_of_int64_entries, |
- number_of_code_ptr_entries, |
- number_of_heap_ptr_entries, |
- number_of_int32_entries); |
- if (number_of_code_ptr_entries > 0) { |
- int offset = |
- constant_pool->OffsetOfElementAt(constant_pool->first_code_ptr_index()); |
- MemsetPointer( |
- reinterpret_cast<Address*>(HeapObject::RawField(constant_pool, offset)), |
- isolate()->builtins()->builtin(Builtins::kIllegal)->entry(), |
- number_of_code_ptr_entries); |
- } |
- if (number_of_heap_ptr_entries > 0) { |
- int offset = |
- constant_pool->OffsetOfElementAt(constant_pool->first_heap_ptr_index()); |
- MemsetPointer( |
- HeapObject::RawField(constant_pool, offset), |
- undefined_value(), |
- number_of_heap_ptr_entries); |
+ constant_pool->Init(int64_count, code_ptr_count, heap_ptr_count, int32_count); |
+ constant_pool->ClearPtrEntries(isolate()); |
+ return constant_pool; |
+} |
+ |
+ |
+AllocationResult Heap::AllocateExtendedConstantPoolArray( |
+ int small_section_int64_entries, |
+ int small_section_code_ptr_entries, |
+ int small_section_heap_ptr_entries, |
+ int small_section_int32_entries, |
+ int extended_section_int64_entries, |
+ int extended_section_code_ptr_entries, |
+ int extended_section_heap_ptr_entries, |
+ int extended_section_int32_entries) { |
+ int max_small_entries = ConstantPoolArray::kMaxSmallEntriesPerType; |
+ CHECK(small_section_int64_entries >= 0 && |
+ small_section_int64_entries <= max_small_entries && |
+ small_section_code_ptr_entries >= 0 && |
+ small_section_code_ptr_entries <= max_small_entries && |
+ small_section_heap_ptr_entries >= 0 && |
+ small_section_heap_ptr_entries <= max_small_entries && |
+ small_section_int32_entries >= 0 && |
+ small_section_int32_entries <= max_small_entries); |
+ CHECK(extended_section_int64_entries >= 0 && |
+ extended_section_code_ptr_entries >= 0 && |
+ extended_section_heap_ptr_entries >= 0 && |
+ extended_section_int32_entries >= 0); |
+ int size = ConstantPoolArray::SizeForExtended( |
+ small_section_int64_entries, |
+ small_section_code_ptr_entries, |
+ small_section_heap_ptr_entries, |
+ small_section_int32_entries, |
+ extended_section_int64_entries, |
+ extended_section_code_ptr_entries, |
+ extended_section_heap_ptr_entries, |
+ extended_section_int32_entries); |
+#ifndef V8_HOST_ARCH_64_BIT |
+ size += kPointerSize; |
+#endif |
+ AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); |
+ |
+ HeapObject* object; |
+ { AllocationResult allocation = AllocateRaw(size, space, OLD_POINTER_SPACE); |
+ if (!allocation.To(&object)) return allocation; |
} |
+ object = EnsureDoubleAligned(this, object, size); |
+ object->set_map_no_write_barrier(constant_pool_array_map()); |
+ |
+ ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); |
+ constant_pool->InitExtended(small_section_int64_entries, |
+ small_section_code_ptr_entries, |
+ small_section_heap_ptr_entries, |
+ small_section_int32_entries, |
+ extended_section_int64_entries, |
+ extended_section_code_ptr_entries, |
+ extended_section_heap_ptr_entries, |
+ extended_section_int32_entries); |
+ constant_pool->ClearPtrEntries(isolate()); |
return constant_pool; |
} |