Chromium Code Reviews| Index: src/heap/heap.cc |
| diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
| index 6039bdb4c6ba64d3d47b7bd9f527c1e9e460bae2..f163aca50d858d959198be3337a1d6a9f0a51df5 100644 |
| --- a/src/heap/heap.cc |
| +++ b/src/heap/heap.cc |
| @@ -2804,6 +2804,8 @@ bool Heap::CreateInitialMaps() { |
| ALLOCATE_PARTIAL_MAP(FIXED_ARRAY_TYPE, kVariableSizeSentinel, fixed_array); |
| ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, undefined); |
| ALLOCATE_PARTIAL_MAP(ODDBALL_TYPE, Oddball::kSize, null); |
| + ALLOCATE_PARTIAL_MAP(FEEDBACK_VECTOR_TYPE, kVariableSizeSentinel, |
| + feedback_vector); |
| #undef ALLOCATE_PARTIAL_MAP |
| } |
| @@ -2815,6 +2817,13 @@ bool Heap::CreateInitialMaps() { |
| } |
| set_empty_fixed_array(FixedArray::cast(obj)); |
| + // Allocate the empty feedback vector. |
| + { |
| + AllocationResult allocation = AllocateEmptyFeedbackVector(); |
| + if (!allocation.To(&obj)) return false; |
| + } |
| + set_empty_feedback_vector(TypeFeedbackVector::cast(obj)); |
| + |
| { |
| AllocationResult allocation = Allocate(null_map(), OLD_SPACE); |
| if (!allocation.To(&obj)) return false; |
| @@ -2876,6 +2885,16 @@ bool Heap::CreateInitialMaps() { |
| null_map()->set_layout_descriptor(LayoutDescriptor::FastPointerLayout()); |
| } |
| + feedback_vector_map()->set_code_cache(empty_fixed_array()); |
| + feedback_vector_map()->set_dependent_code( |
| + DependentCode::cast(empty_fixed_array())); |
| + feedback_vector_map()->set_raw_transitions(Smi::FromInt(0)); |
| + feedback_vector_map()->set_instance_descriptors(empty_descriptor_array()); |
| + if (FLAG_unbox_double_fields) { |
| + feedback_vector_map()->set_layout_descriptor( |
| + LayoutDescriptor::FastPointerLayout()); |
| + } |
| + |
| // Fix prototype object for existing maps. |
| meta_map()->set_prototype(null_value()); |
| meta_map()->set_constructor_or_backpointer(null_value()); |
| @@ -2889,6 +2908,9 @@ bool Heap::CreateInitialMaps() { |
| null_map()->set_prototype(null_value()); |
| null_map()->set_constructor_or_backpointer(null_value()); |
| + feedback_vector_map()->set_prototype(null_value()); |
| + feedback_vector_map()->set_constructor_or_backpointer(null_value()); |
| + |
| { // Map allocation |
| #define ALLOCATE_MAP(instance_type, size, field_name) \ |
| { \ |
| @@ -4473,6 +4495,21 @@ AllocationResult Heap::AllocateEmptyFixedArray() { |
| } |
| +AllocationResult Heap::AllocateEmptyFeedbackVector() { |
| + FeedbackVectorSpec empty_spec; |
| + int size = TypeFeedbackVector::SizeFor(&empty_spec); |
| + HeapObject* result; |
| + { |
| + AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); |
| + if (!allocation.To(&result)) return allocation; |
| + } |
| + // Initialize the object. |
| + result->set_map_no_write_barrier(feedback_vector_map()); |
| + TypeFeedbackVector::cast(result)->set_length(0); |
| + return result; |
| +} |
| + |
| + |
| AllocationResult Heap::AllocateEmptyExternalArray( |
| ExternalArrayType array_type) { |
| return AllocateExternalArray(0, array_type, NULL, TENURED); |
| @@ -4554,6 +4591,32 @@ AllocationResult Heap::CopyFixedDoubleArrayWithMap(FixedDoubleArray* src, |
| } |
| +AllocationResult Heap::CopyTypeFeedbackVectorWithMap(TypeFeedbackVector* src, |
| + Map* map) { |
| + int len = src->length(); |
| + int size = len * kPointerSize + TypeFeedbackVector::kHeaderSize; |
| + if (len == 0) { |
| + return empty_feedback_vector(); |
| + } |
| + |
| + AllocationSpace space = SelectSpace(size, TENURED); |
| + HeapObject* obj; |
| + { |
| + AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); |
| + if (!allocation.To(&obj)) return allocation; |
| + } |
| + obj->set_map_no_write_barrier(map); |
| + TypeFeedbackVector* result = TypeFeedbackVector::cast(obj); |
| + result->set_length(len); |
| + |
| + // Copy the content |
| + DisallowHeapAllocation no_gc; |
| + WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
| + for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); |
| + return result; |
| +} |
| + |
| + |
| AllocationResult Heap::AllocateRawFixedArray(int length, |
| PretenureFlag pretenure) { |
| if (length < 0 || length > FixedArray::kMaxLength) { |
| @@ -4642,6 +4705,33 @@ AllocationResult Heap::AllocateRawFixedDoubleArray(int length, |
| } |
| +template AllocationResult Heap::AllocateTypeFeedbackVector( |
| + const ZoneFeedbackVectorSpec* spec); |
| +template AllocationResult Heap::AllocateTypeFeedbackVector( |
| + const FeedbackVectorSpec* spec); |
| + |
| +template <typename Spec> |
| +AllocationResult Heap::AllocateTypeFeedbackVector(const Spec* spec) { |
| + int size = TypeFeedbackVector::SizeFor(spec); |
| + if (size == TypeFeedbackVector::kHeaderSize) { |
| + return empty_feedback_vector(); |
| + } |
| + AllocationSpace space = SelectSpace(size, TENURED); |
| + |
| + HeapObject* object; |
| + { |
| + AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); |
| + if (!allocation.To(&object)) return allocation; |
| + } |
| + // object = EnsureDoubleAligned(this, object, size); |
|
Hannes Payer (out of office)
2015/06/30 13:59:11
Do you have to double align the type feedback vect
mvstanton
2015/06/30 15:00:46
Nope. Removed comment, thx.
|
| + object->set_map_no_write_barrier(feedback_vector_map()); |
| + |
| + TypeFeedbackVector* vector = TypeFeedbackVector::cast(object); |
| + vector->Init(isolate(), spec); |
| + return vector; |
| +} |
| + |
| + |
| AllocationResult Heap::AllocateSymbol() { |
| // Statically ensure that it is safe to allocate symbols in paged spaces. |
| STATIC_ASSERT(Symbol::kSize <= Page::kMaxRegularHeapObjectSize); |