Commit 7d61ddfa authored by ishell's avatar ishell Committed by Commit bot

[ic] Remove names table from type feedback metadata.

BUG=chromium:576312, v8:5561

Review-Url: https://codereview.chromium.org/2515233002
Cr-Commit-Position: refs/heads/master@{#41130}
parent 1834ab72
......@@ -211,7 +211,7 @@ void VariableProxy::AssignFeedbackVectorSlots(Isolate* isolate,
static_cast<int>(reinterpret_cast<intptr_t>(entry->value)));
return;
}
variable_feedback_slot_ = spec->AddLoadGlobalICSlot(var()->name());
variable_feedback_slot_ = spec->AddLoadGlobalICSlot();
cache->Put(var(), variable_feedback_slot_);
} else {
variable_feedback_slot_ = spec->AddLoadICSlot();
......
......@@ -546,13 +546,6 @@ void ObjectStatsCollector::RecordSharedFunctionInfoDetails(
if (!feedback_metadata->is_empty()) {
RecordFixedArrayHelper(sfi, feedback_metadata,
TYPE_FEEDBACK_METADATA_SUB_TYPE, 0);
Object* names =
feedback_metadata->get(TypeFeedbackMetadata::kNamesTableIndex);
if (!names->IsSmi()) {
UnseededNumberDictionary* names = UnseededNumberDictionary::cast(
feedback_metadata->get(TypeFeedbackMetadata::kNamesTableIndex));
RecordHashTableHelper(sfi, names, TYPE_FEEDBACK_METADATA_SUB_TYPE);
}
}
if (!sfi->OptimizedCodeMapIsCleared()) {
......
......@@ -686,16 +686,11 @@ void FeedbackVectorSpecBase<Derived>::FeedbackVectorSpecPrint(
return;
}
for (int slot = 0, name_index = 0; slot < slot_count;) {
for (int slot = 0; slot < slot_count;) {
FeedbackVectorSlotKind kind = This()->GetKind(slot);
int entry_size = TypeFeedbackMetadata::GetSlotSize(kind);
DCHECK_LT(0, entry_size);
os << "\n Slot #" << slot << " " << kind;
if (TypeFeedbackMetadata::SlotRequiresName(kind)) {
os << ", " << Brief(*This()->GetName(name_index++));
}
slot += entry_size;
}
os << "\n";
......@@ -723,9 +718,6 @@ void TypeFeedbackMetadata::TypeFeedbackMetadataPrint(
FeedbackVectorSlot slot = iter.Next();
FeedbackVectorSlotKind kind = iter.kind();
os << "\n Slot " << slot << " " << kind;
if (TypeFeedbackMetadata::SlotRequiresName(kind)) {
os << ", " << Brief(iter.name());
}
}
os << "\n";
}
......@@ -752,9 +744,6 @@ void TypeFeedbackVector::TypeFeedbackVectorPrint(std::ostream& os) { // NOLINT
FeedbackVectorSlotKind kind = iter.kind();
os << "\n Slot " << slot << " " << kind;
if (TypeFeedbackMetadata::SlotRequiresName(kind)) {
os << ", " << Brief(iter.name());
}
os << " ";
switch (kind) {
case FeedbackVectorSlotKind::LOAD_IC: {
......
......@@ -62,29 +62,6 @@ int TypeFeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind kind) {
return 2;
}
bool TypeFeedbackMetadata::SlotRequiresName(FeedbackVectorSlotKind kind) {
switch (kind) {
case FeedbackVectorSlotKind::LOAD_GLOBAL_IC:
return true;
case FeedbackVectorSlotKind::CALL_IC:
case FeedbackVectorSlotKind::LOAD_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::GENERAL:
case FeedbackVectorSlotKind::INVALID:
return false;
case FeedbackVectorSlotKind::KINDS_NUMBER:
break;
}
UNREACHABLE();
return false;
}
bool TypeFeedbackVector::is_empty() const {
return length() == kReservedIndexCount;
}
......
......@@ -37,17 +37,6 @@ FeedbackVectorSlotKind TypeFeedbackMetadata::GetKind(
return VectorICComputer::decode(data, slot.ToInt());
}
String* TypeFeedbackMetadata::GetName(FeedbackVectorSlot slot) const {
DCHECK(SlotRequiresName(GetKind(slot)));
UnseededNumberDictionary* names =
UnseededNumberDictionary::cast(get(kNamesTableIndex));
int entry = names->FindEntry(GetIsolate(), slot.ToInt());
CHECK_NE(UnseededNumberDictionary::kNotFound, entry);
Object* name = names->ValueAt(entry);
DCHECK(name->IsString());
return String::cast(name);
}
void TypeFeedbackMetadata::SetKind(FeedbackVectorSlot slot,
FeedbackVectorSlotKind kind) {
int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt());
......@@ -97,31 +86,10 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate,
Handle<TypeFeedbackMetadata> metadata =
Handle<TypeFeedbackMetadata>::cast(array);
// Add names to NamesTable.
const int name_count = spec->name_count();
Handle<UnseededNumberDictionary> names;
if (name_count) {
names = UnseededNumberDictionary::New(isolate, name_count, TENURED);
}
int name_index = 0;
for (int i = 0; i < slot_count; i++) {
FeedbackVectorSlotKind kind = spec->GetKind(i);
metadata->SetKind(FeedbackVectorSlot(i), kind);
if (SlotRequiresName(kind)) {
Handle<String> name = spec->GetName(name_index);
DCHECK(!name.is_null());
Handle<UnseededNumberDictionary> new_names =
UnseededNumberDictionary::AtNumberPut(names, i, name);
DCHECK_EQ(*new_names, *names);
names = new_names;
name_index++;
}
}
DCHECK_EQ(name_count, name_index);
metadata->set(kNamesTableIndex,
name_count ? static_cast<Object*>(*names) : Smi::kZero);
// It's important that the TypeFeedbackMetadata have a COW map, since it's
// pointed to by both a SharedFunctionInfo and indirectly by closures through
......@@ -141,7 +109,6 @@ bool TypeFeedbackMetadata::SpecDiffersFrom(
}
int slots = slot_count();
int name_index = 0;
for (int i = 0; i < slots;) {
FeedbackVectorSlot slot(i);
FeedbackVectorSlotKind kind = GetKind(slot);
......@@ -150,14 +117,6 @@ bool TypeFeedbackMetadata::SpecDiffersFrom(
if (kind != other_spec->GetKind(i)) {
return true;
}
if (SlotRequiresName(kind)) {
String* name = GetName(slot);
DCHECK(name != GetHeap()->empty_string());
String* other_name = *other_spec->GetName(name_index++);
if (name != other_name) {
return true;
}
}
i += entry_size;
}
return false;
......@@ -177,11 +136,6 @@ bool TypeFeedbackMetadata::DiffersFrom(
if (GetKind(slot) != other_metadata->GetKind(slot)) {
return true;
}
if (SlotRequiresName(kind)) {
if (GetName(slot) != other_metadata->GetName(slot)) {
return true;
}
}
i += entry_size;
}
return false;
......@@ -222,11 +176,6 @@ FeedbackVectorSlotKind TypeFeedbackVector::GetKind(
return metadata()->GetKind(slot);
}
String* TypeFeedbackVector::GetName(FeedbackVectorSlot slot) const {
DCHECK(!is_empty());
return metadata()->GetName(slot);
}
// static
Handle<TypeFeedbackVector> TypeFeedbackVector::New(
Isolate* isolate, Handle<TypeFeedbackMetadata> metadata) {
......
......@@ -53,8 +53,7 @@ class FeedbackVectorSpecBase {
return AddSlot(FeedbackVectorSlotKind::LOAD_IC);
}
FeedbackVectorSlot AddLoadGlobalICSlot(Handle<String> name) {
This()->append_name(name);
FeedbackVectorSlot AddLoadGlobalICSlot() {
return AddSlot(FeedbackVectorSlotKind::LOAD_GLOBAL_IC);
}
......@@ -97,7 +96,7 @@ class FeedbackVectorSpecBase {
class StaticFeedbackVectorSpec
: public FeedbackVectorSpecBase<StaticFeedbackVectorSpec> {
public:
StaticFeedbackVectorSpec() : slot_count_(0), name_count_(0) {}
StaticFeedbackVectorSpec() : slot_count_(0) {}
int slots() const { return slot_count_; }
......@@ -106,13 +105,6 @@ class StaticFeedbackVectorSpec
return kinds_[slot];
}
int name_count() const { return name_count_; }
Handle<String> GetName(int index) const {
DCHECK(index >= 0 && index < name_count_);
return names_[index];
}
private:
friend class FeedbackVectorSpecBase<StaticFeedbackVectorSpec>;
......@@ -121,25 +113,17 @@ class StaticFeedbackVectorSpec
kinds_[slot_count_++] = kind;
}
void append_name(Handle<String> name) {
DCHECK(name_count_ < kMaxLength);
names_[name_count_++] = name;
}
static const int kMaxLength = 12;
int slot_count_;
FeedbackVectorSlotKind kinds_[kMaxLength];
int name_count_;
Handle<String> names_[kMaxLength];
};
class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> {
public:
explicit FeedbackVectorSpec(Zone* zone) : slot_kinds_(zone), names_(zone) {
explicit FeedbackVectorSpec(Zone* zone) : slot_kinds_(zone) {
slot_kinds_.reserve(16);
names_.reserve(8);
}
int slots() const { return static_cast<int>(slot_kinds_.size()); }
......@@ -148,10 +132,6 @@ class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> {
return static_cast<FeedbackVectorSlotKind>(slot_kinds_.at(slot));
}
int name_count() const { return static_cast<int>(names_.size()); }
Handle<String> GetName(int index) const { return names_.at(index); }
private:
friend class FeedbackVectorSpecBase<FeedbackVectorSpec>;
......@@ -159,10 +139,7 @@ class FeedbackVectorSpec : public FeedbackVectorSpecBase<FeedbackVectorSpec> {
slot_kinds_.push_back(static_cast<unsigned char>(kind));
}
void append_name(Handle<String> name) { names_.push_back(name); }
ZoneVector<unsigned char> slot_kinds_;
ZoneVector<Handle<String>> names_;
};
......@@ -177,8 +154,7 @@ class TypeFeedbackMetadata : public FixedArray {
static inline TypeFeedbackMetadata* cast(Object* obj);
static const int kSlotsCountIndex = 0;
static const int kNamesTableIndex = 1;
static const int kReservedIndexCount = 2;
static const int kReservedIndexCount = 1;
static const int kNameTableEntrySize = 2;
static const int kNameTableSlotIndex = 0;
......@@ -187,9 +163,6 @@ class TypeFeedbackMetadata : public FixedArray {
// Returns number of feedback vector elements used by given slot kind.
static inline int GetSlotSize(FeedbackVectorSlotKind kind);
// Defines if slots of given kind require "name".
static inline bool SlotRequiresName(FeedbackVectorSlotKind kind);
bool SpecDiffersFrom(const FeedbackVectorSpec* other_spec) const;
bool DiffersFrom(const TypeFeedbackMetadata* other_metadata) const;
......@@ -202,9 +175,6 @@ class TypeFeedbackMetadata : public FixedArray {
// Returns slot kind for given slot.
FeedbackVectorSlotKind GetKind(FeedbackVectorSlot slot) const;
// Returns name for given slot.
String* GetName(FeedbackVectorSlot slot) const;
template <typename Spec>
static Handle<TypeFeedbackMetadata> New(Isolate* isolate, const Spec* spec);
......@@ -273,8 +243,6 @@ class TypeFeedbackVector : public FixedArray {
// Returns slot kind for given slot.
FeedbackVectorSlotKind GetKind(FeedbackVectorSlot slot) const;
// Returns name corresponding to given slot or an empty string.
String* GetName(FeedbackVectorSlot slot) const;
static Handle<TypeFeedbackVector> New(Isolate* isolate,
Handle<TypeFeedbackMetadata> metadata);
......@@ -371,11 +339,6 @@ class TypeFeedbackMetadataIterator {
// Returns entry size of the last slot returned by Next().
inline int entry_size() const;
String* name() const {
DCHECK(TypeFeedbackMetadata::SlotRequiresName(kind()));
return metadata()->GetName(cur_slot_);
}
private:
TypeFeedbackMetadata* metadata() const {
return !metadata_handle_.is_null() ? *metadata_handle_ : metadata_;
......
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