Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef V8_TYPE_FEEDBACK_VECTOR_INL_H_ | 5 #ifndef V8_TYPE_FEEDBACK_VECTOR_INL_H_ |
| 6 #define V8_TYPE_FEEDBACK_VECTOR_INL_H_ | 6 #define V8_TYPE_FEEDBACK_VECTOR_INL_H_ |
| 7 | 7 |
| 8 #include "src/type-feedback-vector.h" | 8 #include "src/type-feedback-vector.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 | 12 |
| 13 int TypeFeedbackVector::ic_with_type_info_count() { | |
| 14 return length() > 0 ? Smi::cast(get(kWithTypesIndex))->value() : 0; | |
| 15 } | |
| 16 | |
| 17 | |
| 18 void TypeFeedbackVector::change_ic_with_type_info_count(int delta) { | |
| 19 if (delta == 0) return; | |
| 20 int value = ic_with_type_info_count() + delta; | |
| 21 // Could go negative because of the debugger. | |
| 22 if (value >= 0) { | |
| 23 set(kWithTypesIndex, Smi::FromInt(value)); | |
| 24 } | |
| 25 } | |
| 26 | |
| 27 | |
| 28 int TypeFeedbackVector::ic_generic_count() { | |
| 29 return length() > 0 ? Smi::cast(get(kGenericCountIndex))->value() : 0; | |
| 30 } | |
| 31 | |
| 32 | |
| 33 void TypeFeedbackVector::change_ic_generic_count(int delta) { | |
| 34 if (delta == 0) return; | |
| 35 int value = ic_generic_count() + delta; | |
| 36 if (value >= 0) { | |
| 37 set(kGenericCountIndex, Smi::FromInt(value)); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 | |
| 42 int TypeFeedbackVector::Slots() { | |
| 43 if (length() == 0) return 0; | |
| 44 return Max(0, first_ic_slot_index() - kReservedIndexCount); | |
| 45 } | |
| 46 | |
| 47 | |
| 48 int TypeFeedbackVector::ICSlots() { | |
| 49 if (length() == 0) return 0; | |
| 50 return length() - first_ic_slot_index(); | |
| 51 } | |
| 52 | |
| 53 | |
| 54 int TypeFeedbackVector::GetIndex(FeedbackVectorSlot slot) { | |
| 55 return kReservedIndexCount + slot.ToInt(); | |
| 56 } | |
| 57 | |
| 58 | |
| 59 int TypeFeedbackVector::GetIndex(FeedbackVectorICSlot slot) { | |
| 60 int first_ic_slot = first_ic_slot_index(); | |
| 61 DCHECK(slot.ToInt() < ICSlots()); | |
| 62 return first_ic_slot + slot.ToInt(); | |
| 63 } | |
| 64 | |
| 65 | |
| 66 FeedbackVectorSlot TypeFeedbackVector::ToSlot(int index) { | |
| 67 DCHECK(index >= kReservedIndexCount && index < first_ic_slot_index()); | |
| 68 return FeedbackVectorSlot(index - kReservedIndexCount); | |
| 69 } | |
| 70 | |
| 71 | |
| 72 FeedbackVectorICSlot TypeFeedbackVector::ToICSlot(int index) { | |
| 73 DCHECK(index >= first_ic_slot_index() && index < length()); | |
| 74 return FeedbackVectorICSlot(index - first_ic_slot_index()); | |
| 75 } | |
| 76 | |
| 77 | |
| 78 Object* TypeFeedbackVector::Get(FeedbackVectorSlot slot) { | |
| 79 return get(GetIndex(slot)); | |
| 80 } | |
| 81 | |
| 82 | |
| 83 void TypeFeedbackVector::Set(FeedbackVectorSlot slot, Object* value, | |
| 84 WriteBarrierMode mode) { | |
| 85 set(GetIndex(slot), value, mode); | |
| 86 } | |
| 87 | |
| 88 | |
| 89 Object* TypeFeedbackVector::Get(FeedbackVectorICSlot slot) { | |
| 90 return get(GetIndex(slot)); | |
| 91 } | |
| 92 | |
| 93 | |
| 94 void TypeFeedbackVector::Set(FeedbackVectorICSlot slot, Object* value, | |
| 95 WriteBarrierMode mode) { | |
| 96 set(GetIndex(slot), value, mode); | |
| 97 } | |
|
mvstanton
2014/10/20 07:57:44
I've moved these out of -inl.h back to .h. They do
| |
| 98 | |
| 99 | |
| 13 Handle<Object> TypeFeedbackVector::UninitializedSentinel(Isolate* isolate) { | 100 Handle<Object> TypeFeedbackVector::UninitializedSentinel(Isolate* isolate) { |
| 14 return isolate->factory()->uninitialized_symbol(); | 101 return isolate->factory()->uninitialized_symbol(); |
| 15 } | 102 } |
| 16 | 103 |
| 17 | 104 |
| 18 Handle<Object> TypeFeedbackVector::MegamorphicSentinel(Isolate* isolate) { | 105 Handle<Object> TypeFeedbackVector::MegamorphicSentinel(Isolate* isolate) { |
| 19 return isolate->factory()->megamorphic_symbol(); | 106 return isolate->factory()->megamorphic_symbol(); |
| 20 } | 107 } |
| 21 | 108 |
| 22 | 109 |
| 23 Handle<Object> TypeFeedbackVector::PremonomorphicSentinel(Isolate* isolate) { | 110 Handle<Object> TypeFeedbackVector::PremonomorphicSentinel(Isolate* isolate) { |
| 24 return isolate->factory()->megamorphic_symbol(); | 111 return isolate->factory()->premonomorphic_symbol(); |
| 25 } | 112 } |
| 26 | 113 |
| 27 | 114 |
| 28 Handle<Object> TypeFeedbackVector::GenericSentinel(Isolate* isolate) { | 115 Handle<Object> TypeFeedbackVector::GenericSentinel(Isolate* isolate) { |
| 29 return isolate->factory()->generic_symbol(); | 116 return isolate->factory()->generic_symbol(); |
| 30 } | 117 } |
| 31 | 118 |
| 32 | 119 |
| 33 Handle<Object> TypeFeedbackVector::MonomorphicArraySentinel( | 120 Handle<Object> TypeFeedbackVector::MonomorphicArraySentinel( |
| 34 Isolate* isolate, ElementsKind elements_kind) { | 121 Isolate* isolate, ElementsKind elements_kind) { |
| 35 return Handle<Object>(Smi::FromInt(static_cast<int>(elements_kind)), isolate); | 122 return Handle<Object>(Smi::FromInt(static_cast<int>(elements_kind)), isolate); |
| 36 } | 123 } |
| 37 | 124 |
| 38 | 125 |
| 39 Object* TypeFeedbackVector::RawUninitializedSentinel(Heap* heap) { | 126 Object* TypeFeedbackVector::RawUninitializedSentinel(Heap* heap) { |
| 40 return heap->uninitialized_symbol(); | 127 return heap->uninitialized_symbol(); |
| 41 } | 128 } |
| 42 } | 129 } |
| 43 } // namespace v8::internal | 130 } // namespace v8::internal |
| 44 | 131 |
| 45 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_ | 132 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_ |
| OLD | NEW |