Index: src/type-feedback-vector.h |
diff --git a/src/type-feedback-vector.h b/src/type-feedback-vector.h |
index 0c741a37bba9c17d65889f4d5459823ea3fba47a..a71e978ba9117798e5d5a0c32fa9ece7023e407f 100644 |
--- a/src/type-feedback-vector.h |
+++ b/src/type-feedback-vector.h |
@@ -31,6 +31,8 @@ enum class FeedbackVectorSlotKind { |
INTERPRETER_BINARYOP_IC, |
INTERPRETER_COMPARE_IC, |
+ // This kind of slot has an integer parameter associated with it. |
+ CREATE_CLOSURE, |
// This is a general purpose slot that occupies one feedback vector element. |
GENERAL, |
@@ -57,6 +59,11 @@ class FeedbackVectorSpecBase { |
return AddSlot(FeedbackVectorSlotKind::LOAD_GLOBAL_IC); |
} |
+ FeedbackVectorSlot AddCreateClosureSlot(int size) { |
+ This()->append_parameter(size); |
+ return AddSlot(FeedbackVectorSlotKind::CREATE_CLOSURE); |
+ } |
+ |
FeedbackVectorSlot AddKeyedLoadICSlot() { |
return AddSlot(FeedbackVectorSlotKind::KEYED_LOAD_IC); |
} |
@@ -96,7 +103,7 @@ class FeedbackVectorSpecBase { |
class StaticFeedbackVectorSpec |
: public FeedbackVectorSpecBase<StaticFeedbackVectorSpec> { |
public: |
- StaticFeedbackVectorSpec() : slot_count_(0) {} |
+ StaticFeedbackVectorSpec() : slot_count_(0), parameters_count_(0) {} |
int slots() const { return slot_count_; } |
@@ -105,6 +112,13 @@ class StaticFeedbackVectorSpec |
return kinds_[slot]; |
} |
+ int parameters_count() const { return parameters_count_; } |
+ |
+ int GetParameter(int index) const { |
+ DCHECK(index >= 0 && index < parameters_count_); |
+ return parameters_[index]; |
+ } |
+ |
private: |
friend class FeedbackVectorSpecBase<StaticFeedbackVectorSpec>; |
@@ -113,17 +127,26 @@ class StaticFeedbackVectorSpec |
kinds_[slot_count_++] = kind; |
} |
+ void append_parameter(int parameter) { |
+ DCHECK(parameters_count_ < kMaxLength); |
+ parameters_[parameters_count_++] = parameter; |
+ } |
+ |
static const int kMaxLength = 12; |
int slot_count_; |
FeedbackVectorSlotKind kinds_[kMaxLength]; |
+ int parameters_count_; |
+ int parameters_[kMaxLength]; |
}; |
class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> { |
public: |
- explicit FeedbackVectorSpec(Zone* zone) : slot_kinds_(zone) { |
+ explicit FeedbackVectorSpec(Zone* zone) |
+ : slot_kinds_(zone), parameters_(zone) { |
slot_kinds_.reserve(16); |
+ parameters_.reserve(8); |
} |
int slots() const { return static_cast<int>(slot_kinds_.size()); } |
@@ -132,6 +155,10 @@ class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> { |
return static_cast<FeedbackVectorSlotKind>(slot_kinds_.at(slot)); |
} |
+ int parameters_count() const { return static_cast<int>(parameters_.size()); } |
+ |
+ int GetParameter(int index) const { return parameters_.at(index); } |
+ |
private: |
friend class FeedbackVectorSpecBase<FeedbackVectorSpec>; |
@@ -139,14 +166,18 @@ class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> { |
slot_kinds_.push_back(static_cast<unsigned char>(kind)); |
} |
+ void append_parameter(int parameter) { parameters_.push_back(parameter); } |
+ |
ZoneVector<unsigned char> slot_kinds_; |
+ ZoneVector<int> parameters_; |
}; |
// The shape of the TypeFeedbackMetadata is an array with: |
// 0: slot_count |
// 1: names table |
-// 2..N: slot kinds packed into a bit vector |
+// 2: parameters table |
+// 3..N: slot kinds packed into a bit vector |
// |
class TypeFeedbackMetadata : public FixedArray { |
public: |
@@ -154,11 +185,15 @@ class TypeFeedbackMetadata : public FixedArray { |
static inline TypeFeedbackMetadata* cast(Object* obj); |
static const int kSlotsCountIndex = 0; |
- static const int kReservedIndexCount = 1; |
+ static const int kParametersTableIndex = 1; |
+ static const int kReservedIndexCount = 2; |
// Returns number of feedback vector elements used by given slot kind. |
static inline int GetSlotSize(FeedbackVectorSlotKind kind); |
+ // Defines if slots of given kind require "parameter". |
+ static inline bool SlotRequiresParameter(FeedbackVectorSlotKind kind); |
+ |
bool SpecDiffersFrom(const FeedbackVectorSpec* other_spec) const; |
bool DiffersFrom(const TypeFeedbackMetadata* other_metadata) const; |
@@ -171,6 +206,9 @@ class TypeFeedbackMetadata : public FixedArray { |
// Returns slot kind for given slot. |
FeedbackVectorSlotKind GetKind(FeedbackVectorSlot slot) const; |
+ // Returns parameter for given index (note: this is not the slot) |
+ int GetParameter(int parameter_index) const; |
+ |
template <typename Spec> |
static Handle<TypeFeedbackMetadata> New(Isolate* isolate, const Spec* spec); |
@@ -239,6 +277,8 @@ class TypeFeedbackVector : public FixedArray { |
// Returns slot kind for given slot. |
FeedbackVectorSlotKind GetKind(FeedbackVectorSlot slot) const; |
+ // Returns parameter corresponding to given slot or -1. |
+ int GetParameter(FeedbackVectorSlot slot) const; |
static Handle<TypeFeedbackVector> New(Isolate* isolate, |
Handle<TypeFeedbackMetadata> metadata); |