Commit 73980ae4 authored by mvstanton's avatar mvstanton Committed by Commit bot

[TypeFeedbackVector] Remove unnecessary Parameters metadata

This is a remnant of a previous design to a solution yet to be
checked in.

BUG=v8:5456
R=bmeurer@chromium.org

Review-Url: https://codereview.chromium.org/2650853008
Cr-Commit-Position: refs/heads/master@{#42692}
parent ec00a78f
...@@ -2603,10 +2603,7 @@ class FunctionLiteral final : public Expression { ...@@ -2603,10 +2603,7 @@ class FunctionLiteral final : public Expression {
void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec,
FeedbackVectorSlotCache* cache) { FeedbackVectorSlotCache* cache) {
// The + 1 is because we need an array with room for the literals literal_feedback_slot_ = spec->AddCreateClosureSlot();
// as well as the feedback vector.
literal_feedback_slot_ =
spec->AddCreateClosureSlot(materialized_literal_count_ + 1);
} }
FeedbackVectorSlot LiteralFeedbackSlot() const { FeedbackVectorSlot LiteralFeedbackSlot() const {
...@@ -2873,12 +2870,9 @@ class NativeFunctionLiteral final : public Expression { ...@@ -2873,12 +2870,9 @@ class NativeFunctionLiteral final : public Expression {
void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec,
FeedbackVectorSlotCache* cache) { FeedbackVectorSlotCache* cache) {
// 0 is a magic number here. It means we are holding the literals
// array for a native function literal, which needs to be
// the empty literals array.
// TODO(mvstanton): The FeedbackVectorSlotCache can be adapted // TODO(mvstanton): The FeedbackVectorSlotCache can be adapted
// to always return the same slot for this case. // to always return the same slot for this case.
literal_feedback_slot_ = spec->AddCreateClosureSlot(0); literal_feedback_slot_ = spec->AddCreateClosureSlot();
} }
private: private:
......
...@@ -729,10 +729,6 @@ void TypeFeedbackMetadata::TypeFeedbackMetadataPrint( ...@@ -729,10 +729,6 @@ void TypeFeedbackMetadata::TypeFeedbackMetadataPrint(
FeedbackVectorSlot slot = iter.Next(); FeedbackVectorSlot slot = iter.Next();
FeedbackVectorSlotKind kind = iter.kind(); FeedbackVectorSlotKind kind = iter.kind();
os << "\n Slot " << slot << " " << kind; os << "\n Slot " << slot << " " << kind;
if (TypeFeedbackMetadata::SlotRequiresParameter(kind)) {
int parameter_value = this->GetParameter(parameter_index++);
os << " [" << parameter_value << "]";
}
} }
os << "\n"; os << "\n";
} }
...@@ -807,12 +803,7 @@ void TypeFeedbackVector::TypeFeedbackVectorPrint(std::ostream& os) { // NOLINT ...@@ -807,12 +803,7 @@ void TypeFeedbackVector::TypeFeedbackVectorPrint(std::ostream& os) { // NOLINT
os << Code::ICState2String(nexus.StateFromFeedback()); os << Code::ICState2String(nexus.StateFromFeedback());
break; break;
} }
case FeedbackVectorSlotKind::CREATE_CLOSURE: { case FeedbackVectorSlotKind::CREATE_CLOSURE:
// TODO(mvstanton): Integrate this into the iterator.
int parameter_value = metadata()->GetParameter(parameter_index++);
os << "[" << parameter_value << "]";
break;
}
case FeedbackVectorSlotKind::GENERAL: case FeedbackVectorSlotKind::GENERAL:
break; break;
case FeedbackVectorSlotKind::INVALID: case FeedbackVectorSlotKind::INVALID:
......
...@@ -63,31 +63,6 @@ int TypeFeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind kind) { ...@@ -63,31 +63,6 @@ int TypeFeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind kind) {
return 2; return 2;
} }
bool TypeFeedbackMetadata::SlotRequiresParameter(FeedbackVectorSlotKind kind) {
switch (kind) {
case FeedbackVectorSlotKind::CREATE_CLOSURE:
return true;
case FeedbackVectorSlotKind::CALL_IC:
case FeedbackVectorSlotKind::LOAD_IC:
case FeedbackVectorSlotKind::LOAD_GLOBAL_IC:
case FeedbackVectorSlotKind::KEYED_LOAD_IC:
case FeedbackVectorSlotKind::STORE_IC:
case FeedbackVectorSlotKind::KEYED_STORE_IC:
case FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC:
case FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC:
case FeedbackVectorSlotKind::STORE_DATA_PROPERTY_IN_LITERAL_IC:
case FeedbackVectorSlotKind::GENERAL:
case FeedbackVectorSlotKind::INVALID:
return false;
case FeedbackVectorSlotKind::KINDS_NUMBER:
break;
}
UNREACHABLE();
return false;
}
bool TypeFeedbackVector::is_empty() const { bool TypeFeedbackVector::is_empty() const {
return length() == kReservedIndexCount; return length() == kReservedIndexCount;
} }
......
...@@ -37,11 +37,6 @@ FeedbackVectorSlotKind TypeFeedbackMetadata::GetKind( ...@@ -37,11 +37,6 @@ FeedbackVectorSlotKind TypeFeedbackMetadata::GetKind(
return VectorICComputer::decode(data, slot.ToInt()); return VectorICComputer::decode(data, slot.ToInt());
} }
int TypeFeedbackMetadata::GetParameter(int parameter_index) const {
FixedArray* parameters = FixedArray::cast(get(kParametersTableIndex));
return Smi::cast(parameters->get(parameter_index))->value();
}
void TypeFeedbackMetadata::SetKind(FeedbackVectorSlot slot, void TypeFeedbackMetadata::SetKind(FeedbackVectorSlot slot,
FeedbackVectorSlotKind kind) { FeedbackVectorSlotKind kind) {
int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt()); int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt());
...@@ -96,18 +91,6 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate, ...@@ -96,18 +91,6 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate,
metadata->SetKind(FeedbackVectorSlot(i), kind); metadata->SetKind(FeedbackVectorSlot(i), kind);
} }
if (spec->parameters_count() > 0) {
const int parameters_count = spec->parameters_count();
Handle<FixedArray> params_array =
factory->NewFixedArray(parameters_count, TENURED);
for (int i = 0; i < parameters_count; i++) {
params_array->set(i, Smi::FromInt(spec->GetParameter(i)));
}
metadata->set(kParametersTableIndex, *params_array);
} else {
metadata->set(kParametersTableIndex, *factory->empty_fixed_array());
}
// It's important that the TypeFeedbackMetadata have a COW map, since it's // It's important that the TypeFeedbackMetadata have a COW map, since it's
// pointed to by both a SharedFunctionInfo and indirectly by closures through // pointed to by both a SharedFunctionInfo and indirectly by closures through
// the TypeFeedbackVector. The serializer uses the COW map type to decide // the TypeFeedbackVector. The serializer uses the COW map type to decide
...@@ -125,7 +108,6 @@ bool TypeFeedbackMetadata::SpecDiffersFrom( ...@@ -125,7 +108,6 @@ bool TypeFeedbackMetadata::SpecDiffersFrom(
} }
int slots = slot_count(); int slots = slot_count();
int parameter_index = 0;
for (int i = 0; i < slots;) { for (int i = 0; i < slots;) {
FeedbackVectorSlot slot(i); FeedbackVectorSlot slot(i);
FeedbackVectorSlotKind kind = GetKind(slot); FeedbackVectorSlotKind kind = GetKind(slot);
...@@ -134,14 +116,6 @@ bool TypeFeedbackMetadata::SpecDiffersFrom( ...@@ -134,14 +116,6 @@ bool TypeFeedbackMetadata::SpecDiffersFrom(
if (kind != other_spec->GetKind(i)) { if (kind != other_spec->GetKind(i)) {
return true; return true;
} }
if (SlotRequiresParameter(kind)) {
int parameter = GetParameter(parameter_index);
int other_parameter = other_spec->GetParameter(parameter_index);
if (parameter != other_parameter) {
return true;
}
parameter_index++;
}
i += entry_size; i += entry_size;
} }
return false; return false;
...@@ -154,7 +128,6 @@ bool TypeFeedbackMetadata::DiffersFrom( ...@@ -154,7 +128,6 @@ bool TypeFeedbackMetadata::DiffersFrom(
} }
int slots = slot_count(); int slots = slot_count();
int parameter_index = 0;
for (int i = 0; i < slots;) { for (int i = 0; i < slots;) {
FeedbackVectorSlot slot(i); FeedbackVectorSlot slot(i);
FeedbackVectorSlotKind kind = GetKind(slot); FeedbackVectorSlotKind kind = GetKind(slot);
...@@ -162,13 +135,6 @@ bool TypeFeedbackMetadata::DiffersFrom( ...@@ -162,13 +135,6 @@ bool TypeFeedbackMetadata::DiffersFrom(
if (GetKind(slot) != other_metadata->GetKind(slot)) { if (GetKind(slot) != other_metadata->GetKind(slot)) {
return true; return true;
} }
if (SlotRequiresParameter(kind)) {
if (GetParameter(parameter_index) !=
other_metadata->GetParameter(parameter_index)) {
return true;
}
parameter_index++;
}
i += entry_size; i += entry_size;
} }
return false; return false;
...@@ -213,13 +179,6 @@ FeedbackVectorSlotKind TypeFeedbackVector::GetKind( ...@@ -213,13 +179,6 @@ FeedbackVectorSlotKind TypeFeedbackVector::GetKind(
return metadata()->GetKind(slot); return metadata()->GetKind(slot);
} }
int TypeFeedbackVector::GetParameter(FeedbackVectorSlot slot) const {
DCHECK(!is_empty());
DCHECK(
TypeFeedbackMetadata::SlotRequiresParameter(metadata()->GetKind(slot)));
return FixedArray::cast(Get(slot))->length();
}
// static // static
Handle<TypeFeedbackVector> TypeFeedbackVector::New( Handle<TypeFeedbackVector> TypeFeedbackVector::New(
Isolate* isolate, Handle<TypeFeedbackMetadata> metadata) { Isolate* isolate, Handle<TypeFeedbackMetadata> metadata) {
...@@ -236,7 +195,6 @@ Handle<TypeFeedbackVector> TypeFeedbackVector::New( ...@@ -236,7 +195,6 @@ Handle<TypeFeedbackVector> TypeFeedbackVector::New(
array->set_map_no_write_barrier(isolate->heap()->type_feedback_vector_map()); array->set_map_no_write_barrier(isolate->heap()->type_feedback_vector_map());
array->set(kMetadataIndex, *metadata); array->set(kMetadataIndex, *metadata);
array->set(kInvocationCountIndex, Smi::kZero); array->set(kInvocationCountIndex, Smi::kZero);
int parameter_index = 0;
for (int i = 0; i < slot_count;) { for (int i = 0; i < slot_count;) {
FeedbackVectorSlot slot(i); FeedbackVectorSlot slot(i);
FeedbackVectorSlotKind kind = metadata->GetKind(slot); FeedbackVectorSlotKind kind = metadata->GetKind(slot);
...@@ -244,18 +202,8 @@ Handle<TypeFeedbackVector> TypeFeedbackVector::New( ...@@ -244,18 +202,8 @@ Handle<TypeFeedbackVector> TypeFeedbackVector::New(
int entry_size = TypeFeedbackMetadata::GetSlotSize(kind); int entry_size = TypeFeedbackMetadata::GetSlotSize(kind);
if (kind == FeedbackVectorSlotKind::CREATE_CLOSURE) { if (kind == FeedbackVectorSlotKind::CREATE_CLOSURE) {
// This fixed array is filled with undefined. // TODO(mvstanton): Root literal arrays in this location.
int length = metadata->GetParameter(parameter_index++); array->set(index, *factory->empty_literals_array(), SKIP_WRITE_BARRIER);
if (length == 0) {
// This is a native function literal. We can always point to
// the empty literals array here.
array->set(index, *factory->empty_literals_array(), SKIP_WRITE_BARRIER);
} else {
// TODO(mvstanton): Create the array.
// Handle<FixedArray> value = factory->NewFixedArray(length);
// array->set(index, *value);
array->set(index, *factory->empty_literals_array(), SKIP_WRITE_BARRIER);
}
} }
i += entry_size; i += entry_size;
} }
......
...@@ -31,8 +31,6 @@ enum class FeedbackVectorSlotKind { ...@@ -31,8 +31,6 @@ enum class FeedbackVectorSlotKind {
INTERPRETER_BINARYOP_IC, INTERPRETER_BINARYOP_IC,
INTERPRETER_COMPARE_IC, INTERPRETER_COMPARE_IC,
STORE_DATA_PROPERTY_IN_LITERAL_IC, STORE_DATA_PROPERTY_IN_LITERAL_IC,
// This kind of slot has an integer parameter associated with it.
CREATE_CLOSURE, CREATE_CLOSURE,
// This is a general purpose slot that occupies one feedback vector element. // This is a general purpose slot that occupies one feedback vector element.
GENERAL, GENERAL,
...@@ -60,8 +58,7 @@ class FeedbackVectorSpecBase { ...@@ -60,8 +58,7 @@ class FeedbackVectorSpecBase {
return AddSlot(FeedbackVectorSlotKind::LOAD_GLOBAL_IC); return AddSlot(FeedbackVectorSlotKind::LOAD_GLOBAL_IC);
} }
FeedbackVectorSlot AddCreateClosureSlot(int size) { FeedbackVectorSlot AddCreateClosureSlot() {
This()->append_parameter(size);
return AddSlot(FeedbackVectorSlotKind::CREATE_CLOSURE); return AddSlot(FeedbackVectorSlotKind::CREATE_CLOSURE);
} }
...@@ -108,7 +105,7 @@ class FeedbackVectorSpecBase { ...@@ -108,7 +105,7 @@ class FeedbackVectorSpecBase {
class StaticFeedbackVectorSpec class StaticFeedbackVectorSpec
: public FeedbackVectorSpecBase<StaticFeedbackVectorSpec> { : public FeedbackVectorSpecBase<StaticFeedbackVectorSpec> {
public: public:
StaticFeedbackVectorSpec() : slot_count_(0), parameters_count_(0) {} StaticFeedbackVectorSpec() : slot_count_(0) {}
int slots() const { return slot_count_; } int slots() const { return slot_count_; }
...@@ -117,13 +114,6 @@ class StaticFeedbackVectorSpec ...@@ -117,13 +114,6 @@ class StaticFeedbackVectorSpec
return kinds_[slot]; 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: private:
friend class FeedbackVectorSpecBase<StaticFeedbackVectorSpec>; friend class FeedbackVectorSpecBase<StaticFeedbackVectorSpec>;
...@@ -132,26 +122,17 @@ class StaticFeedbackVectorSpec ...@@ -132,26 +122,17 @@ class StaticFeedbackVectorSpec
kinds_[slot_count_++] = kind; kinds_[slot_count_++] = kind;
} }
void append_parameter(int parameter) {
DCHECK(parameters_count_ < kMaxLength);
parameters_[parameters_count_++] = parameter;
}
static const int kMaxLength = 12; static const int kMaxLength = 12;
int slot_count_; int slot_count_;
FeedbackVectorSlotKind kinds_[kMaxLength]; FeedbackVectorSlotKind kinds_[kMaxLength];
int parameters_count_;
int parameters_[kMaxLength];
}; };
class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> { class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> {
public: public:
explicit FeedbackVectorSpec(Zone* zone) explicit FeedbackVectorSpec(Zone* zone) : slot_kinds_(zone) {
: slot_kinds_(zone), parameters_(zone) {
slot_kinds_.reserve(16); slot_kinds_.reserve(16);
parameters_.reserve(8);
} }
int slots() const { return static_cast<int>(slot_kinds_.size()); } int slots() const { return static_cast<int>(slot_kinds_.size()); }
...@@ -160,10 +141,6 @@ class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> { ...@@ -160,10 +141,6 @@ class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> {
return static_cast<FeedbackVectorSlotKind>(slot_kinds_.at(slot)); 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: private:
friend class FeedbackVectorSpecBase<FeedbackVectorSpec>; friend class FeedbackVectorSpecBase<FeedbackVectorSpec>;
...@@ -171,10 +148,7 @@ class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> { ...@@ -171,10 +148,7 @@ class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> {
slot_kinds_.push_back(static_cast<unsigned char>(kind)); slot_kinds_.push_back(static_cast<unsigned char>(kind));
} }
void append_parameter(int parameter) { parameters_.push_back(parameter); }
ZoneVector<unsigned char> slot_kinds_; ZoneVector<unsigned char> slot_kinds_;
ZoneVector<int> parameters_;
}; };
...@@ -190,15 +164,11 @@ class TypeFeedbackMetadata : public FixedArray { ...@@ -190,15 +164,11 @@ class TypeFeedbackMetadata : public FixedArray {
static inline TypeFeedbackMetadata* cast(Object* obj); static inline TypeFeedbackMetadata* cast(Object* obj);
static const int kSlotsCountIndex = 0; static const int kSlotsCountIndex = 0;
static const int kParametersTableIndex = 1; static const int kReservedIndexCount = 1;
static const int kReservedIndexCount = 2;
// Returns number of feedback vector elements used by given slot kind. // Returns number of feedback vector elements used by given slot kind.
static inline int GetSlotSize(FeedbackVectorSlotKind 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 SpecDiffersFrom(const FeedbackVectorSpec* other_spec) const;
bool DiffersFrom(const TypeFeedbackMetadata* other_metadata) const; bool DiffersFrom(const TypeFeedbackMetadata* other_metadata) const;
...@@ -211,9 +181,6 @@ class TypeFeedbackMetadata : public FixedArray { ...@@ -211,9 +181,6 @@ class TypeFeedbackMetadata : public FixedArray {
// Returns slot kind for given slot. // Returns slot kind for given slot.
FeedbackVectorSlotKind GetKind(FeedbackVectorSlot slot) const; 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> template <typename Spec>
static Handle<TypeFeedbackMetadata> New(Isolate* isolate, const Spec* spec); static Handle<TypeFeedbackMetadata> New(Isolate* isolate, const Spec* spec);
...@@ -282,8 +249,6 @@ class TypeFeedbackVector : public FixedArray { ...@@ -282,8 +249,6 @@ class TypeFeedbackVector : public FixedArray {
// Returns slot kind for given slot. // Returns slot kind for given slot.
FeedbackVectorSlotKind GetKind(FeedbackVectorSlot slot) const; FeedbackVectorSlotKind GetKind(FeedbackVectorSlot slot) const;
// Returns parameter corresponding to given slot or -1.
int GetParameter(FeedbackVectorSlot slot) const;
static Handle<TypeFeedbackVector> New(Isolate* isolate, static Handle<TypeFeedbackVector> New(Isolate* isolate,
Handle<TypeFeedbackMetadata> metadata); Handle<TypeFeedbackMetadata> metadata);
......
...@@ -99,7 +99,7 @@ TEST(VectorStructure) { ...@@ -99,7 +99,7 @@ TEST(VectorStructure) {
{ {
FeedbackVectorSpec spec(&zone); FeedbackVectorSpec spec(&zone);
spec.AddGeneralSlot(); spec.AddGeneralSlot();
spec.AddCreateClosureSlot(5); spec.AddCreateClosureSlot();
spec.AddGeneralSlot(); spec.AddGeneralSlot();
vector = NewTypeFeedbackVector(isolate, &spec); vector = NewTypeFeedbackVector(isolate, &spec);
FeedbackVectorHelper helper(vector); FeedbackVectorHelper helper(vector);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment