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

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

Issue 1369973002: Use FeedbackVectorSlotKind instead of Code::Kind for type feedback vector. (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
« no previous file with comments | « src/prettyprinter.cc ('k') | src/type-feedback-vector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/type-feedback-vector.h
diff --git a/src/type-feedback-vector.h b/src/type-feedback-vector.h
index 4fb01997483655aeba19cc9d393afcf9c238806f..c92a6205cb1b42c81a67161e231caa20d6c4b8e5 100644
--- a/src/type-feedback-vector.h
+++ b/src/type-feedback-vector.h
@@ -17,19 +17,36 @@
namespace v8 {
namespace internal {
+
+enum class FeedbackVectorSlotKind {
+ UNUSED,
+ CALL_IC,
+ LOAD_IC,
+ KEYED_LOAD_IC,
+ STORE_IC,
+ KEYED_STORE_IC,
+
+ KINDS_NUMBER // Last value indicating number of kinds.
+};
+
+
+std::ostream& operator<<(std::ostream& os, FeedbackVectorSlotKind kind);
+
+
class FeedbackVectorSpec {
public:
FeedbackVectorSpec() : slots_(0), ic_slots_(0), ic_kinds_(NULL) {}
explicit FeedbackVectorSpec(int slots)
: slots_(slots), ic_slots_(0), ic_kinds_(NULL) {}
- FeedbackVectorSpec(int slots, int ic_slots, Code::Kind* ic_slot_kinds)
+ FeedbackVectorSpec(int slots, int ic_slots,
+ FeedbackVectorSlotKind* ic_slot_kinds)
: slots_(slots), ic_slots_(ic_slots), ic_kinds_(ic_slot_kinds) {}
int slots() const { return slots_; }
int ic_slots() const { return ic_slots_; }
- Code::Kind GetKind(int ic_slot) const {
+ FeedbackVectorSlotKind GetKind(int ic_slot) const {
DCHECK(ic_slots_ > 0 && ic_slot < ic_slots_);
return ic_kinds_[ic_slot];
}
@@ -37,7 +54,7 @@ class FeedbackVectorSpec {
private:
int slots_;
int ic_slots_;
- Code::Kind* ic_kinds_;
+ FeedbackVectorSlotKind* ic_kinds_;
};
@@ -58,12 +75,12 @@ class ZoneFeedbackVectorSpec {
ic_slot_kinds_.resize(ic_slots_);
}
- void SetKind(int ic_slot, Code::Kind kind) {
- ic_slot_kinds_[ic_slot] = kind;
+ void SetKind(int ic_slot, FeedbackVectorSlotKind kind) {
+ ic_slot_kinds_[ic_slot] = static_cast<unsigned char>(kind);
}
- Code::Kind GetKind(int ic_slot) const {
- return static_cast<Code::Kind>(ic_slot_kinds_.at(ic_slot));
+ FeedbackVectorSlotKind GetKind(int ic_slot) const {
+ return static_cast<FeedbackVectorSlotKind>(ic_slot_kinds_.at(ic_slot));
}
private:
@@ -125,7 +142,7 @@ class TypeFeedbackVector : public FixedArray {
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
// IC slots need metadata to recognize the type of IC.
- Code::Kind GetKind(FeedbackVectorICSlot slot) const;
+ FeedbackVectorSlotKind GetKind(FeedbackVectorICSlot slot) const;
template <typename Spec>
static Handle<TypeFeedbackVector> Allocate(Isolate* isolate,
@@ -185,23 +202,17 @@ class TypeFeedbackVector : public FixedArray {
static Handle<TypeFeedbackVector> CreatePushAppliedArgumentsVector(
Isolate* isolate);
+ static const char* Kind2String(FeedbackVectorSlotKind kind);
+
private:
- enum VectorICKind {
- KindUnused = 0x0,
- KindCallIC = 0x1,
- KindLoadIC = 0x2,
- KindKeyedLoadIC = 0x3,
- KindStoreIC = 0x4,
- KindKeyedStoreIC = 0x5,
- };
-
- static const int kVectorICKindBits = 3;
- static VectorICKind FromCodeKind(Code::Kind kind);
- static Code::Kind FromVectorICKind(VectorICKind kind);
- void SetKind(FeedbackVectorICSlot slot, Code::Kind kind);
-
- typedef BitSetComputer<VectorICKind, kVectorICKindBits, kSmiValueSize,
- uint32_t> VectorICComputer;
+ static const int kFeedbackVectorSlotKindBits = 3;
+ STATIC_ASSERT(static_cast<int>(FeedbackVectorSlotKind::KINDS_NUMBER) <
+ (1 << kFeedbackVectorSlotKindBits));
+
+ void SetKind(FeedbackVectorICSlot slot, FeedbackVectorSlotKind kind);
+
+ typedef BitSetComputer<FeedbackVectorSlotKind, kFeedbackVectorSlotKindBits,
+ kSmiValueSize, uint32_t> VectorICComputer;
void ClearSlotsImpl(SharedFunctionInfo* shared, bool force_clear);
void ClearICSlotsImpl(SharedFunctionInfo* shared, bool force_clear);
@@ -300,11 +311,11 @@ class CallICNexus : public FeedbackNexus {
CallICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot)
: FeedbackNexus(vector, slot) {
- DCHECK(vector->GetKind(slot) == Code::CALL_IC);
+ DCHECK_EQ(FeedbackVectorSlotKind::CALL_IC, vector->GetKind(slot));
}
CallICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot)
: FeedbackNexus(vector, slot) {
- DCHECK(vector->GetKind(slot) == Code::CALL_IC);
+ DCHECK_EQ(FeedbackVectorSlotKind::CALL_IC, vector->GetKind(slot));
}
void Clear(Code* host);
@@ -333,7 +344,7 @@ class LoadICNexus : public FeedbackNexus {
public:
LoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot)
: FeedbackNexus(vector, slot) {
- DCHECK(vector->GetKind(slot) == Code::LOAD_IC);
+ DCHECK_EQ(FeedbackVectorSlotKind::LOAD_IC, vector->GetKind(slot));
}
explicit LoadICNexus(Isolate* isolate)
: FeedbackNexus(TypeFeedbackVector::DummyVector(isolate),
@@ -341,7 +352,7 @@ class LoadICNexus : public FeedbackNexus {
TypeFeedbackVector::kDummyLoadICSlot)) {}
LoadICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot)
: FeedbackNexus(vector, slot) {
- DCHECK(vector->GetKind(slot) == Code::LOAD_IC);
+ DCHECK_EQ(FeedbackVectorSlotKind::LOAD_IC, vector->GetKind(slot));
}
void Clear(Code* host);
@@ -358,11 +369,11 @@ class KeyedLoadICNexus : public FeedbackNexus {
public:
KeyedLoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot)
: FeedbackNexus(vector, slot) {
- DCHECK(vector->GetKind(slot) == Code::KEYED_LOAD_IC);
+ DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, vector->GetKind(slot));
}
KeyedLoadICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot)
: FeedbackNexus(vector, slot) {
- DCHECK(vector->GetKind(slot) == Code::KEYED_LOAD_IC);
+ DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, vector->GetKind(slot));
}
void Clear(Code* host);
@@ -383,7 +394,7 @@ class StoreICNexus : public FeedbackNexus {
public:
StoreICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot)
: FeedbackNexus(vector, slot) {
- DCHECK(vector->GetKind(slot) == Code::STORE_IC);
+ DCHECK_EQ(FeedbackVectorSlotKind::STORE_IC, vector->GetKind(slot));
}
explicit StoreICNexus(Isolate* isolate)
: FeedbackNexus(TypeFeedbackVector::DummyVector(isolate),
@@ -391,7 +402,7 @@ class StoreICNexus : public FeedbackNexus {
TypeFeedbackVector::kDummyStoreICSlot)) {}
StoreICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot)
: FeedbackNexus(vector, slot) {
- DCHECK(vector->GetKind(slot) == Code::STORE_IC);
+ DCHECK_EQ(FeedbackVectorSlotKind::STORE_IC, vector->GetKind(slot));
}
void Clear(Code* host);
@@ -409,7 +420,7 @@ class KeyedStoreICNexus : public FeedbackNexus {
KeyedStoreICNexus(Handle<TypeFeedbackVector> vector,
FeedbackVectorICSlot slot)
: FeedbackNexus(vector, slot) {
- DCHECK(vector->GetKind(slot) == Code::KEYED_STORE_IC);
+ DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC, vector->GetKind(slot));
}
explicit KeyedStoreICNexus(Isolate* isolate)
: FeedbackNexus(TypeFeedbackVector::DummyVector(isolate),
@@ -417,7 +428,7 @@ class KeyedStoreICNexus : public FeedbackNexus {
TypeFeedbackVector::kDummyKeyedStoreICSlot)) {}
KeyedStoreICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot)
: FeedbackNexus(vector, slot) {
- DCHECK(vector->GetKind(slot) == Code::KEYED_STORE_IC);
+ DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC, vector->GetKind(slot));
}
void Clear(Code* host);
« no previous file with comments | « src/prettyprinter.cc ('k') | src/type-feedback-vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698