Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Unified Diff: src/type-feedback-vector-inl.h

Issue 1370303004: Distinction between FeedbackVectorICSlot and FeedbackVectorSlot eliminated. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed release builds Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/type-feedback-vector.cc ('k') | src/type-info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/type-feedback-vector-inl.h
diff --git a/src/type-feedback-vector-inl.h b/src/type-feedback-vector-inl.h
index 2301f03a45ffc856bc69a5ee4d218aeda94755bb..4389cfe94495b15d7c194ee3a5cf539f181c6e47 100644
--- a/src/type-feedback-vector-inl.h
+++ b/src/type-feedback-vector-inl.h
@@ -10,6 +10,22 @@
namespace v8 {
namespace internal {
+
+template <typename Derived>
+FeedbackVectorSlot FeedbackVectorSpecBase<Derived>::AddSlot(
+ FeedbackVectorSlotKind kind) {
+ Derived* derived = static_cast<Derived*>(this);
+
+ int slot = derived->slots();
+ int entries_per_slot = TypeFeedbackVector::GetSlotSize(kind);
+ derived->append(kind);
+ for (int i = 1; i < entries_per_slot; i++) {
+ derived->append(FeedbackVectorSlotKind::INVALID);
+ }
+ return FeedbackVectorSlot(slot);
+}
+
+
// static
TypeFeedbackVector* TypeFeedbackVector::cast(Object* obj) {
DCHECK(obj->IsTypeFeedbackVector());
@@ -17,9 +33,24 @@ TypeFeedbackVector* TypeFeedbackVector::cast(Object* obj) {
}
-int TypeFeedbackVector::first_ic_slot_index() const {
+int TypeFeedbackVector::GetSlotSize(FeedbackVectorSlotKind kind) {
+ DCHECK_NE(FeedbackVectorSlotKind::INVALID, kind);
+ DCHECK_NE(FeedbackVectorSlotKind::KINDS_NUMBER, kind);
+ return kind == FeedbackVectorSlotKind::GENERAL ? 1 : 2;
+}
+
+
+bool TypeFeedbackVector::is_empty() const {
+ if (length() == 0) return true;
+ DCHECK(length() >= kReservedIndexCount);
+ return false;
+}
+
+
+int TypeFeedbackVector::Slots() const {
+ if (length() == 0) return 0;
DCHECK(length() >= kReservedIndexCount);
- return Smi::cast(get(kFirstICSlotIndex))->value();
+ return Smi::cast(get(kSlotsCountIndex))->value();
}
@@ -52,54 +83,26 @@ void TypeFeedbackVector::change_ic_generic_count(int delta) {
}
-int TypeFeedbackVector::Slots() const {
- if (length() == 0) return 0;
- return Max(
- 0, first_ic_slot_index() - ic_metadata_length() - kReservedIndexCount);
-}
-
-
-int TypeFeedbackVector::ICSlots() const {
- if (length() == 0) return 0;
- return (length() - first_ic_slot_index()) / elements_per_ic_slot();
-}
-
-
int TypeFeedbackVector::ic_metadata_length() const {
- return VectorICComputer::word_count(ICSlots());
+ return VectorICComputer::word_count(Slots());
}
-// Conversion from a slot or ic slot to an integer index to the underlying
-// array.
int TypeFeedbackVector::GetIndex(FeedbackVectorSlot slot) const {
- DCHECK(slot.ToInt() < first_ic_slot_index());
+ DCHECK(slot.ToInt() < Slots());
return kReservedIndexCount + ic_metadata_length() + slot.ToInt();
}
-int TypeFeedbackVector::GetIndex(FeedbackVectorICSlot slot) const {
- int first_ic_slot = first_ic_slot_index();
- DCHECK(slot.ToInt() < ICSlots());
- return first_ic_slot + slot.ToInt() * elements_per_ic_slot();
-}
-
-
// Conversion from an integer index to either a slot or an ic slot. The caller
// should know what kind she expects.
FeedbackVectorSlot TypeFeedbackVector::ToSlot(int index) const {
- DCHECK(index >= kReservedIndexCount && index < first_ic_slot_index());
+ DCHECK(index >= kReservedIndexCount + ic_metadata_length() &&
+ index < length());
return FeedbackVectorSlot(index - ic_metadata_length() - kReservedIndexCount);
}
-FeedbackVectorICSlot TypeFeedbackVector::ToICSlot(int index) const {
- DCHECK(index >= first_ic_slot_index() && index < length());
- int ic_slot = (index - first_ic_slot_index()) / elements_per_ic_slot();
- return FeedbackVectorICSlot(ic_slot);
-}
-
-
Object* TypeFeedbackVector::Get(FeedbackVectorSlot slot) const {
return get(GetIndex(slot));
}
@@ -111,17 +114,6 @@ void TypeFeedbackVector::Set(FeedbackVectorSlot slot, Object* value,
}
-Object* TypeFeedbackVector::Get(FeedbackVectorICSlot slot) const {
- return get(GetIndex(slot));
-}
-
-
-void TypeFeedbackVector::Set(FeedbackVectorICSlot slot, Object* value,
- WriteBarrierMode mode) {
- set(GetIndex(slot), value, mode);
-}
-
-
Handle<Object> TypeFeedbackVector::UninitializedSentinel(Isolate* isolate) {
return isolate->factory()->uninitialized_symbol();
}
@@ -137,8 +129,8 @@ Handle<Object> TypeFeedbackVector::PremonomorphicSentinel(Isolate* isolate) {
}
-Object* TypeFeedbackVector::RawUninitializedSentinel(Heap* heap) {
- return heap->uninitialized_symbol();
+Object* TypeFeedbackVector::RawUninitializedSentinel(Isolate* isolate) {
+ return isolate->heap()->uninitialized_symbol();
}
@@ -146,7 +138,10 @@ Object* FeedbackNexus::GetFeedback() const { return vector()->Get(slot()); }
Object* FeedbackNexus::GetFeedbackExtra() const {
- DCHECK(TypeFeedbackVector::elements_per_ic_slot() > 1);
+#ifdef DEBUG
+ FeedbackVectorSlotKind kind = vector()->GetKind(slot());
+ DCHECK_LT(1, TypeFeedbackVector::GetSlotSize(kind));
+#endif
int extra_index = vector()->GetIndex(slot()) + 1;
return vector()->get(extra_index);
}
@@ -159,7 +154,10 @@ void FeedbackNexus::SetFeedback(Object* feedback, WriteBarrierMode mode) {
void FeedbackNexus::SetFeedbackExtra(Object* feedback_extra,
WriteBarrierMode mode) {
- DCHECK(TypeFeedbackVector::elements_per_ic_slot() > 1);
+#ifdef DEBUG
+ FeedbackVectorSlotKind kind = vector()->GetKind(slot());
+ DCHECK_LT(1, TypeFeedbackVector::GetSlotSize(kind));
+#endif
int index = vector()->GetIndex(slot()) + 1;
vector()->set(index, feedback_extra, mode);
}
« no previous file with comments | « src/type-feedback-vector.cc ('k') | src/type-info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698