OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/feedback-vector.h" | 5 #include "src/feedback-vector.h" |
6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
7 #include "src/feedback-vector-inl.h" | 7 #include "src/feedback-vector-inl.h" |
8 #include "src/ic/ic-inl.h" | 8 #include "src/ic/ic-inl.h" |
9 #include "src/ic/ic-state.h" | 9 #include "src/ic/ic-state.h" |
10 #include "src/objects.h" | 10 #include "src/objects.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 return "?"; | 154 return "?"; |
155 } | 155 } |
156 | 156 |
157 FeedbackSlotKind FeedbackVector::GetKind(FeedbackSlot slot) const { | 157 FeedbackSlotKind FeedbackVector::GetKind(FeedbackSlot slot) const { |
158 DCHECK(!is_empty()); | 158 DCHECK(!is_empty()); |
159 return metadata()->GetKind(slot); | 159 return metadata()->GetKind(slot); |
160 } | 160 } |
161 | 161 |
162 // static | 162 // static |
163 Handle<FeedbackVector> FeedbackVector::New(Isolate* isolate, | 163 Handle<FeedbackVector> FeedbackVector::New(Isolate* isolate, |
164 Handle<FeedbackMetadata> metadata) { | 164 Handle<SharedFunctionInfo> shared) { |
165 Factory* factory = isolate->factory(); | 165 Factory* factory = isolate->factory(); |
166 | 166 |
167 const int slot_count = metadata->slot_count(); | 167 const int slot_count = shared->feedback_metadata()->slot_count(); |
168 const int length = slot_count + kReservedIndexCount; | 168 const int length = slot_count + kReservedIndexCount; |
169 if (length == kReservedIndexCount) { | |
170 return Handle<FeedbackVector>::cast(factory->empty_feedback_vector()); | |
171 } | |
172 | 169 |
173 Handle<FixedArray> array = factory->NewFixedArray(length, TENURED); | 170 Handle<FixedArray> array = factory->NewFixedArray(length, TENURED); |
174 array->set_map_no_write_barrier(isolate->heap()->feedback_vector_map()); | 171 array->set_map_no_write_barrier(isolate->heap()->feedback_vector_map()); |
175 array->set(kMetadataIndex, *metadata); | 172 array->set(kSharedFunctionInfoIndex, *shared); |
176 array->set(kInvocationCountIndex, Smi::kZero); | 173 array->set(kInvocationCountIndex, Smi::kZero); |
177 | 174 |
178 // Ensure we can skip the write barrier | 175 // Ensure we can skip the write barrier |
179 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate); | 176 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate); |
180 DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel); | 177 DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel); |
181 Handle<Oddball> undefined_value = factory->undefined_value(); | 178 Handle<Oddball> undefined_value = factory->undefined_value(); |
182 for (int i = 0; i < slot_count;) { | 179 for (int i = 0; i < slot_count;) { |
183 FeedbackSlot slot(i); | 180 FeedbackSlot slot(i); |
184 FeedbackSlotKind kind = metadata->GetKind(slot); | 181 FeedbackSlotKind kind = shared->feedback_metadata()->GetKind(slot); |
185 int index = FeedbackVector::GetIndex(slot); | 182 int index = FeedbackVector::GetIndex(slot); |
186 int entry_size = FeedbackMetadata::GetSlotSize(kind); | 183 int entry_size = FeedbackMetadata::GetSlotSize(kind); |
187 | 184 |
188 Object* extra_value = *uninitialized_sentinel; | 185 Object* extra_value = *uninitialized_sentinel; |
189 switch (kind) { | 186 switch (kind) { |
190 case FeedbackSlotKind::LOAD_GLOBAL_INSIDE_TYPEOF_IC: | 187 case FeedbackSlotKind::LOAD_GLOBAL_INSIDE_TYPEOF_IC: |
191 case FeedbackSlotKind::LOAD_GLOBAL_NOT_INSIDE_TYPEOF_IC: | 188 case FeedbackSlotKind::LOAD_GLOBAL_NOT_INSIDE_TYPEOF_IC: |
192 array->set(index, isolate->heap()->empty_weak_cell(), | 189 array->set(index, isolate->heap()->empty_weak_cell(), |
193 SKIP_WRITE_BARRIER); | 190 SKIP_WRITE_BARRIER); |
194 break; | 191 break; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // StaticMarkingVisitor<StaticVisitor>::VisitCodeTarget. | 243 // StaticMarkingVisitor<StaticVisitor>::VisitCodeTarget. |
247 static bool ClearLogic(Isolate* isolate) { | 244 static bool ClearLogic(Isolate* isolate) { |
248 return FLAG_cleanup_code_caches_at_gc && isolate->serializer_enabled(); | 245 return FLAG_cleanup_code_caches_at_gc && isolate->serializer_enabled(); |
249 } | 246 } |
250 | 247 |
251 void FeedbackVector::ClearSlotsImpl(SharedFunctionInfo* shared, | 248 void FeedbackVector::ClearSlotsImpl(SharedFunctionInfo* shared, |
252 bool force_clear) { | 249 bool force_clear) { |
253 Isolate* isolate = GetIsolate(); | 250 Isolate* isolate = GetIsolate(); |
254 if (!force_clear && !ClearLogic(isolate)) return; | 251 if (!force_clear && !ClearLogic(isolate)) return; |
255 | 252 |
256 if (this == isolate->heap()->empty_feedback_vector()) return; | |
257 | |
258 Object* uninitialized_sentinel = | 253 Object* uninitialized_sentinel = |
259 FeedbackVector::RawUninitializedSentinel(isolate); | 254 FeedbackVector::RawUninitializedSentinel(isolate); |
260 Oddball* undefined_value = isolate->heap()->undefined_value(); | 255 Oddball* undefined_value = isolate->heap()->undefined_value(); |
261 | 256 |
262 FeedbackMetadataIterator iter(metadata()); | 257 FeedbackMetadataIterator iter(metadata()); |
263 while (iter.HasNext()) { | 258 while (iter.HasNext()) { |
264 FeedbackSlot slot = iter.Next(); | 259 FeedbackSlot slot = iter.Next(); |
265 FeedbackSlotKind kind = iter.kind(); | 260 FeedbackSlotKind kind = iter.kind(); |
266 | 261 |
267 Object* obj = Get(slot); | 262 Object* obj = Get(slot); |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic( | 992 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic( |
998 Handle<Name> name, Handle<Map> receiver_map) { | 993 Handle<Name> name, Handle<Map> receiver_map) { |
999 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); | 994 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); |
1000 | 995 |
1001 SetFeedback(*cell); | 996 SetFeedback(*cell); |
1002 SetFeedbackExtra(*name); | 997 SetFeedbackExtra(*name); |
1003 } | 998 } |
1004 | 999 |
1005 } // namespace internal | 1000 } // namespace internal |
1006 } // namespace v8 | 1001 } // namespace v8 |
OLD | NEW |