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

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: 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
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..f01d7c493e0b59816539d17a0067694c08cb39f7 100644
--- a/src/type-feedback-vector-inl.h
+++ b/src/type-feedback-vector-inl.h
@@ -10,6 +10,18 @@
namespace v8 {
namespace internal {
+
+FeedbackVectorSlot FeedbackVectorSpec::AddSlot(FeedbackVectorSlotKind kind) {
+ int slot = slots();
+ int entries_per_slot = TypeFeedbackVector::GetSlotSize(kind);
+ slot_kinds_.resize(
+ slot + entries_per_slot,
+ static_cast<unsigned char>(FeedbackVectorSlotKind::INVALID));
+ slot_kinds_[slot] = static_cast<unsigned char>(kind);
+ return FeedbackVectorSlot(slot);
+}
+
+
// static
TypeFeedbackVector* TypeFeedbackVector::cast(Object* obj) {
DCHECK(obj->IsTypeFeedbackVector());
@@ -17,9 +29,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::STUB ? 1 : 2;
+}
+
+
+bool TypeFeedbackVector::is_empty() const {
+ if (length() == 0) return true;
DCHECK(length() >= kReservedIndexCount);
- return Smi::cast(get(kFirstICSlotIndex))->value();
+ return false;
+}
+
+
+int TypeFeedbackVector::Slots() const {
+ if (length() == 0) return 0;
+ DCHECK(length() >= kReservedIndexCount);
+ return Smi::cast(get(kSlotsCountIndex))->value();
}
@@ -52,54 +79,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 +110,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 +125,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 +134,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 +150,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);
}

Powered by Google App Engine
This is Rietveld 408576698