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 {
void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec,
FeedbackVectorSlotCache* cache) {
// The + 1 is because we need an array with room for the literals
// as well as the feedback vector.
literal_feedback_slot_ =
spec->AddCreateClosureSlot(materialized_literal_count_ + 1);
literal_feedback_slot_ = spec->AddCreateClosureSlot();
}
FeedbackVectorSlot LiteralFeedbackSlot() const {
......@@ -2873,12 +2870,9 @@ class NativeFunctionLiteral final : public Expression {
void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec,
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
// to always return the same slot for this case.
literal_feedback_slot_ = spec->AddCreateClosureSlot(0);
literal_feedback_slot_ = spec->AddCreateClosureSlot();
}
private:
......
......@@ -729,10 +729,6 @@ void TypeFeedbackMetadata::TypeFeedbackMetadataPrint(
FeedbackVectorSlot slot = iter.Next();
FeedbackVectorSlotKind kind = iter.kind();
os << "\n Slot " << slot << " " << kind;
if (TypeFeedbackMetadata::SlotRequiresParameter(kind)) {
int parameter_value = this->GetParameter(parameter_index++);
os << " [" << parameter_value << "]";
}
}
os << "\n";
}
......@@ -807,12 +803,7 @@ void TypeFeedbackVector::TypeFeedbackVectorPrint(std::ostream& os) { // NOLINT
os << Code::ICState2String(nexus.StateFromFeedback());
break;
}
case FeedbackVectorSlotKind::CREATE_CLOSURE: {
// TODO(mvstanton): Integrate this into the iterator.
int parameter_value = metadata()->GetParameter(parameter_index++);
os << "[" << parameter_value << "]";
break;
}
case FeedbackVectorSlotKind::CREATE_CLOSURE:
case FeedbackVectorSlotKind::GENERAL:
break;
case FeedbackVectorSlotKind::INVALID:
......
......@@ -63,31 +63,6 @@ int TypeFeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind kind) {
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 {
return length() == kReservedIndexCount;
}
......
......@@ -37,11 +37,6 @@ FeedbackVectorSlotKind TypeFeedbackMetadata::GetKind(
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,
FeedbackVectorSlotKind kind) {
int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt());
......@@ -96,18 +91,6 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate,
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
// pointed to by both a SharedFunctionInfo and indirectly by closures through
// the TypeFeedbackVector. The serializer uses the COW map type to decide
......@@ -125,7 +108,6 @@ bool TypeFeedbackMetadata::SpecDiffersFrom(
}
int slots = slot_count();
int parameter_index = 0;
for (int i = 0; i < slots;) {
FeedbackVectorSlot slot(i);
FeedbackVectorSlotKind kind = GetKind(slot);
......@@ -134,14 +116,6 @@ bool TypeFeedbackMetadata::SpecDiffersFrom(
if (kind != other_spec->GetKind(i)) {
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;
}
return false;
......@@ -154,7 +128,6 @@ bool TypeFeedbackMetadata::DiffersFrom(
}
int slots = slot_count();
int parameter_index = 0;
for (int i = 0; i < slots;) {
FeedbackVectorSlot slot(i);
FeedbackVectorSlotKind kind = GetKind(slot);
......@@ -162,13 +135,6 @@ bool TypeFeedbackMetadata::DiffersFrom(
if (GetKind(slot) != other_metadata->GetKind(slot)) {
return true;
}
if (SlotRequiresParameter(kind)) {
if (GetParameter(parameter_index) !=
other_metadata->GetParameter(parameter_index)) {
return true;
}
parameter_index++;
}
i += entry_size;
}
return false;
......@@ -213,13 +179,6 @@ FeedbackVectorSlotKind TypeFeedbackVector::GetKind(
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
Handle<TypeFeedbackVector> TypeFeedbackVector::New(
Isolate* isolate, Handle<TypeFeedbackMetadata> metadata) {
......@@ -236,7 +195,6 @@ Handle<TypeFeedbackVector> TypeFeedbackVector::New(
array->set_map_no_write_barrier(isolate->heap()->type_feedback_vector_map());
array->set(kMetadataIndex, *metadata);
array->set(kInvocationCountIndex, Smi::kZero);
int parameter_index = 0;
for (int i = 0; i < slot_count;) {
FeedbackVectorSlot slot(i);
FeedbackVectorSlotKind kind = metadata->GetKind(slot);
......@@ -244,18 +202,8 @@ Handle<TypeFeedbackVector> TypeFeedbackVector::New(
int entry_size = TypeFeedbackMetadata::GetSlotSize(kind);
if (kind == FeedbackVectorSlotKind::CREATE_CLOSURE) {
// This fixed array is filled with undefined.
int length = metadata->GetParameter(parameter_index++);
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);
}
// TODO(mvstanton): Root literal arrays in this location.
array->set(index, *factory->empty_literals_array(), SKIP_WRITE_BARRIER);
}
i += entry_size;
}
......
......@@ -31,8 +31,6 @@ enum class FeedbackVectorSlotKind {
INTERPRETER_BINARYOP_IC,
INTERPRETER_COMPARE_IC,
STORE_DATA_PROPERTY_IN_LITERAL_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,
......@@ -60,8 +58,7 @@ class FeedbackVectorSpecBase {
return AddSlot(FeedbackVectorSlotKind::LOAD_GLOBAL_IC);
}
FeedbackVectorSlot AddCreateClosureSlot(int size) {
This()->append_parameter(size);
FeedbackVectorSlot AddCreateClosureSlot() {
return AddSlot(FeedbackVectorSlotKind::CREATE_CLOSURE);
}
......@@ -108,7 +105,7 @@ class FeedbackVectorSpecBase {
class StaticFeedbackVectorSpec
: public FeedbackVectorSpecBase<StaticFeedbackVectorSpec> {
public:
StaticFeedbackVectorSpec() : slot_count_(0), parameters_count_(0) {}
StaticFeedbackVectorSpec() : slot_count_(0) {}
int slots() const { return slot_count_; }
......@@ -117,13 +114,6 @@ 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>;
......@@ -132,26 +122,17 @@ 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), parameters_(zone) {
explicit FeedbackVectorSpec(Zone* zone) : slot_kinds_(zone) {
slot_kinds_.reserve(16);
parameters_.reserve(8);
}
int slots() const { return static_cast<int>(slot_kinds_.size()); }
......@@ -160,10 +141,6 @@ 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>;
......@@ -171,10 +148,7 @@ 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_;
};
......@@ -190,15 +164,11 @@ class TypeFeedbackMetadata : public FixedArray {
static inline TypeFeedbackMetadata* cast(Object* obj);
static const int kSlotsCountIndex = 0;
static const int kParametersTableIndex = 1;
static const int kReservedIndexCount = 2;
static const int kReservedIndexCount = 1;
// 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;
......@@ -211,9 +181,6 @@ 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);
......@@ -282,8 +249,6 @@ 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);
......
......@@ -99,7 +99,7 @@ TEST(VectorStructure) {
{
FeedbackVectorSpec spec(&zone);
spec.AddGeneralSlot();
spec.AddCreateClosureSlot(5);
spec.AddCreateClosureSlot();
spec.AddGeneralSlot();
vector = NewTypeFeedbackVector(isolate, &spec);
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