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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ic/ic.h" | 7 #include "src/ic/ic.h" |
8 #include "src/ic/ic-state.h" | 8 #include "src/ic/ic-state.h" |
9 #include "src/objects.h" | 9 #include "src/objects.h" |
10 #include "src/type-feedback-vector-inl.h" | 10 #include "src/type-feedback-vector-inl.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length, TENURED); | 92 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length, TENURED); |
93 if (ic_slot_count > 0) { | 93 if (ic_slot_count > 0) { |
94 array->set(kFirstICSlotIndex, | 94 array->set(kFirstICSlotIndex, |
95 Smi::FromInt(slot_count + index_count + kReservedIndexCount)); | 95 Smi::FromInt(slot_count + index_count + kReservedIndexCount)); |
96 } else { | 96 } else { |
97 array->set(kFirstICSlotIndex, Smi::FromInt(length)); | 97 array->set(kFirstICSlotIndex, Smi::FromInt(length)); |
98 } | 98 } |
99 array->set(kWithTypesIndex, Smi::FromInt(0)); | 99 array->set(kWithTypesIndex, Smi::FromInt(0)); |
100 array->set(kGenericCountIndex, Smi::FromInt(0)); | 100 array->set(kGenericCountIndex, Smi::FromInt(0)); |
| 101 // Fill the indexes with zeros. |
| 102 for (int i = 0; i < index_count; i++) { |
| 103 array->set(kReservedIndexCount + i, Smi::FromInt(0)); |
| 104 } |
101 | 105 |
102 // Ensure we can skip the write barrier | 106 // Ensure we can skip the write barrier |
103 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate); | 107 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate); |
104 DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel); | 108 DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel); |
105 for (int i = kReservedIndexCount + index_count; i < length; i++) { | 109 for (int i = kReservedIndexCount + index_count; i < length; i++) { |
106 array->set(i, *uninitialized_sentinel, SKIP_WRITE_BARRIER); | 110 array->set(i, *uninitialized_sentinel, SKIP_WRITE_BARRIER); |
107 } | 111 } |
108 | 112 |
109 Handle<TypeFeedbackVector> vector = Handle<TypeFeedbackVector>::cast(array); | 113 Handle<TypeFeedbackVector> vector = Handle<TypeFeedbackVector>::cast(array); |
110 if (FLAG_vector_ics) { | 114 if (FLAG_vector_ics) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } | 255 } |
252 | 256 |
253 | 257 |
254 InlineCacheState KeyedLoadICNexus::StateFromFeedback() const { | 258 InlineCacheState KeyedLoadICNexus::StateFromFeedback() const { |
255 Isolate* isolate = GetIsolate(); | 259 Isolate* isolate = GetIsolate(); |
256 Object* feedback = GetFeedback(); | 260 Object* feedback = GetFeedback(); |
257 if (feedback == *vector()->UninitializedSentinel(isolate)) { | 261 if (feedback == *vector()->UninitializedSentinel(isolate)) { |
258 return UNINITIALIZED; | 262 return UNINITIALIZED; |
259 } else if (feedback == *vector()->PremonomorphicSentinel(isolate)) { | 263 } else if (feedback == *vector()->PremonomorphicSentinel(isolate)) { |
260 return PREMONOMORPHIC; | 264 return PREMONOMORPHIC; |
261 } else if (feedback == *vector()->MegamorphicSentinel(isolate)) { | |
262 return MEGAMORPHIC; | |
263 } else if (feedback == *vector()->GenericSentinel(isolate)) { | 265 } else if (feedback == *vector()->GenericSentinel(isolate)) { |
264 return GENERIC; | 266 return GENERIC; |
265 } else if (feedback->IsFixedArray()) { | 267 } else if (feedback->IsFixedArray()) { |
266 FixedArray* array = FixedArray::cast(feedback); | 268 FixedArray* array = FixedArray::cast(feedback); |
267 int length = array->length(); | 269 int length = array->length(); |
268 DCHECK(length >= 3); | 270 DCHECK(length >= 3); |
269 return length == 3 ? MONOMORPHIC : POLYMORPHIC; | 271 return length == 3 ? MONOMORPHIC : POLYMORPHIC; |
270 } | 272 } |
271 | 273 |
272 return UNINITIALIZED; | 274 return UNINITIALIZED; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 void CallICNexus::ConfigureMonomorphic(Handle<JSFunction> function) { | 317 void CallICNexus::ConfigureMonomorphic(Handle<JSFunction> function) { |
316 SetFeedback(*function); | 318 SetFeedback(*function); |
317 } | 319 } |
318 | 320 |
319 | 321 |
320 void KeyedLoadICNexus::ConfigureGeneric() { | 322 void KeyedLoadICNexus::ConfigureGeneric() { |
321 SetFeedback(*vector()->GenericSentinel(GetIsolate()), SKIP_WRITE_BARRIER); | 323 SetFeedback(*vector()->GenericSentinel(GetIsolate()), SKIP_WRITE_BARRIER); |
322 } | 324 } |
323 | 325 |
324 | 326 |
325 void KeyedLoadICNexus::ConfigureMegamorphic() { | |
326 SetFeedback(*vector()->MegamorphicSentinel(GetIsolate()), SKIP_WRITE_BARRIER); | |
327 } | |
328 | |
329 | |
330 void LoadICNexus::ConfigureMegamorphic() { | 327 void LoadICNexus::ConfigureMegamorphic() { |
331 SetFeedback(*vector()->MegamorphicSentinel(GetIsolate()), SKIP_WRITE_BARRIER); | 328 SetFeedback(*vector()->MegamorphicSentinel(GetIsolate()), SKIP_WRITE_BARRIER); |
332 } | 329 } |
333 | 330 |
334 | 331 |
335 void LoadICNexus::ConfigurePremonomorphic() { | 332 void LoadICNexus::ConfigurePremonomorphic() { |
336 SetFeedback(*vector()->PremonomorphicSentinel(GetIsolate()), | 333 SetFeedback(*vector()->PremonomorphicSentinel(GetIsolate()), |
337 SKIP_WRITE_BARRIER); | 334 SKIP_WRITE_BARRIER); |
338 } | 335 } |
339 | 336 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 if (feedback->IsFixedArray()) { | 489 if (feedback->IsFixedArray()) { |
493 FixedArray* array = FixedArray::cast(feedback); | 490 FixedArray* array = FixedArray::cast(feedback); |
494 DCHECK(array->length() >= 3); | 491 DCHECK(array->length() >= 3); |
495 Object* name = array->get(0); | 492 Object* name = array->get(0); |
496 if (name->IsName()) return Name::cast(name); | 493 if (name->IsName()) return Name::cast(name); |
497 } | 494 } |
498 return NULL; | 495 return NULL; |
499 } | 496 } |
500 } | 497 } |
501 } // namespace v8::internal | 498 } // namespace v8::internal |
OLD | NEW |