Chromium Code Reviews| Index: src/type-feedback-vector-inl.h |
| diff --git a/src/type-feedback-vector-inl.h b/src/type-feedback-vector-inl.h |
| index 43e768ee5df86601fe070ff05e102b4798b78bb1..024a6425ea730f5b0b5a263d5907410de12e6ce5 100644 |
| --- a/src/type-feedback-vector-inl.h |
| +++ b/src/type-feedback-vector-inl.h |
| @@ -10,6 +10,107 @@ |
| namespace v8 { |
| namespace internal { |
| +int TypeFeedbackVector::ic_with_type_info_count() { |
| + return length() > 0 ? Smi::cast(get(kWithTypesIndex))->value() : 0; |
| +} |
| + |
| + |
| +void TypeFeedbackVector::change_ic_with_type_info_count(int delta) { |
| + if (delta == 0) return; |
| + int value = ic_with_type_info_count() + delta; |
| + // Could go negative because of the debugger. |
| + if (value >= 0) { |
| + set(kWithTypesIndex, Smi::FromInt(value)); |
| + } |
| +} |
| + |
| + |
| +int TypeFeedbackVector::ic_generic_count() { |
| + return length() > 0 ? Smi::cast(get(kGenericCountIndex))->value() : 0; |
| +} |
| + |
| + |
| +void TypeFeedbackVector::change_ic_generic_count(int delta) { |
| + if (delta == 0) return; |
| + int value = ic_generic_count() + delta; |
| + if (value >= 0) { |
| + set(kGenericCountIndex, Smi::FromInt(value)); |
| + } |
| +} |
| + |
| + |
| +int TypeFeedbackVector::Slots() { |
| + if (length() == 0) return 0; |
| + int first_ic_slot = first_ic_slot_index(); |
|
ulan
2014/10/15 10:17:06
If instead of -1, you would make first_ic_slot ==
mvstanton
2014/10/16 10:54:14
Done.
|
| + if (first_ic_slot >= 0) { |
| + DCHECK(first_ic_slot >= kReservedIndexCount); |
| + return first_ic_slot - kReservedIndexCount; |
| + } |
| + DCHECK(length() >= kReservedIndexCount); |
| + return length() - kReservedIndexCount; |
| +} |
| + |
| + |
| +int TypeFeedbackVector::ICSlots() { |
| + if (length() == 0) return 0; |
| + int first_ic_slot = first_ic_slot_index(); |
| + if (first_ic_slot < 0) return 0; |
| + DCHECK(first_ic_slot >= kReservedIndexCount); |
| + return length() - first_ic_slot; |
| +} |
| + |
| + |
| +int TypeFeedbackVector::GetIndex(FeedbackVectorSlot slot) { |
| + return kReservedIndexCount + slot.ToInt(); |
| +} |
| + |
| + |
| +int TypeFeedbackVector::GetIndex(FeedbackVectorICSlot slot) { |
| + int first_ic_slot = first_ic_slot_index(); |
| + DCHECK(first_ic_slot >= 0); |
|
ulan
2014/10/15 10:17:05
DCHECK(slot.ToInt() < ICSlots()) would be more pre
mvstanton
2014/10/16 10:54:15
Done.
|
| + return first_ic_slot + slot.ToInt(); |
| +} |
| + |
| + |
| +FeedbackVectorSlot TypeFeedbackVector::ToSlot(int index) { |
| + DCHECK(index >= kReservedIndexCount); |
|
ulan
2014/10/15 10:17:06
also DCHECK(index < first_ic_slot_index() || first
mvstanton
2014/10/16 10:54:15
Done.
|
| + return FeedbackVectorSlot(index - kReservedIndexCount); |
| +} |
| + |
| + |
| +FeedbackVectorICSlot TypeFeedbackVector::ToICSlot(int index) { |
| + DCHECK(index >= kReservedIndexCount); |
|
ulan
2014/10/15 10:17:05
DCHECK(index >= first_ic_slot_index) would be more
mvstanton
2014/10/16 10:54:15
Done.
|
| + DCHECK(first_ic_slot_index() >= 0); |
| + return FeedbackVectorICSlot(index - first_ic_slot_index()); |
| +} |
| + |
| + |
| +Object* TypeFeedbackVector::Get(FeedbackVectorSlot slot) { |
| + return get(kReservedIndexCount + slot.ToInt()); |
|
ulan
2014/10/15 10:17:06
Why not use GetIndex(slot) here and below? :)
mvstanton
2014/10/16 10:54:14
Oh brother, great idea, thx!
|
| +} |
| + |
| + |
| +void TypeFeedbackVector::Set(FeedbackVectorSlot slot, Object* value, |
| + WriteBarrierMode mode) { |
| + set(kReservedIndexCount + slot.ToInt(), value, mode); |
| +} |
| + |
| + |
| +Object* TypeFeedbackVector::Get(FeedbackVectorICSlot slot) { |
| + int first_ic_slot = first_ic_slot_index(); |
| + DCHECK(first_ic_slot >= 0 && first_ic_slot < length()); |
| + return get(first_ic_slot + slot.ToInt()); |
| +} |
| + |
| + |
| +void TypeFeedbackVector::Set(FeedbackVectorICSlot slot, Object* value, |
| + WriteBarrierMode mode) { |
| + int first_ic_slot = first_ic_slot_index(); |
| + DCHECK(first_ic_slot >= 0 && first_ic_slot < length()); |
| + set(first_ic_slot + slot.ToInt(), value, mode); |
| +} |
| + |
| + |
| Handle<Object> TypeFeedbackVector::UninitializedSentinel(Isolate* isolate) { |
| return isolate->factory()->uninitialized_symbol(); |
| } |
| @@ -21,7 +122,7 @@ Handle<Object> TypeFeedbackVector::MegamorphicSentinel(Isolate* isolate) { |
| Handle<Object> TypeFeedbackVector::PremonomorphicSentinel(Isolate* isolate) { |
| - return isolate->factory()->megamorphic_symbol(); |
| + return isolate->factory()->premonomorphic_symbol(); |
| } |