[FeedbackVector] Remove FeedbackVectorSpecBase

The case that required it is no longer in the tree.

Change-Id: Ie4c82f2799c381a5a5f2f57e7e3255ebb69f02b6
Reviewed-on: https://chromium-review.googlesource.com/893262
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Michael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51018}
This commit is contained in:
Mike Stanton 2018-01-31 15:29:45 +01:00 committed by Commit Bot
parent b5835ced4e
commit 9f1c497344
4 changed files with 37 additions and 94 deletions

View File

@ -2552,9 +2552,7 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
share->set_script(*undefined_value(), SKIP_WRITE_BARRIER);
share->set_debug_info(Smi::kZero, SKIP_WRITE_BARRIER);
share->set_function_identifier(*undefined_value(), SKIP_WRITE_BARRIER);
StaticFeedbackVectorSpec empty_spec;
Handle<FeedbackMetadata> feedback_metadata =
FeedbackMetadata::New(isolate(), &empty_spec);
Handle<FeedbackMetadata> feedback_metadata = FeedbackMetadata::New(isolate());
share->set_feedback_metadata(*feedback_metadata, SKIP_WRITE_BARRIER);
share->set_function_literal_id(FunctionLiteral::kIdTypeInvalid);
#if V8_SFI_HAS_UNIQUE_ID

View File

@ -12,35 +12,23 @@
namespace v8 {
namespace internal {
template <typename Derived>
FeedbackSlot FeedbackVectorSpecBase<Derived>::AddSlot(FeedbackSlotKind kind) {
int slot = This()->slots();
FeedbackSlot FeedbackVectorSpec::AddSlot(FeedbackSlotKind kind) {
int slot = slots();
int entries_per_slot = FeedbackMetadata::GetSlotSize(kind);
This()->append(kind);
append(kind);
for (int i = 1; i < entries_per_slot; i++) {
This()->append(FeedbackSlotKind::kInvalid);
append(FeedbackSlotKind::kInvalid);
}
return FeedbackSlot(slot);
}
template FeedbackSlot FeedbackVectorSpecBase<FeedbackVectorSpec>::AddSlot(
FeedbackSlotKind kind);
template FeedbackSlot FeedbackVectorSpecBase<StaticFeedbackVectorSpec>::AddSlot(
FeedbackSlotKind kind);
template <typename Derived>
FeedbackSlot FeedbackVectorSpecBase<Derived>::AddTypeProfileSlot() {
FeedbackSlot FeedbackVectorSpec::AddTypeProfileSlot() {
FeedbackSlot slot = AddSlot(FeedbackSlotKind::kTypeProfile);
CHECK_EQ(FeedbackVectorSpec::kTypeProfileSlotIndex,
FeedbackVector::GetIndex(slot));
return slot;
}
template FeedbackSlot
FeedbackVectorSpecBase<FeedbackVectorSpec>::AddTypeProfileSlot();
template FeedbackSlot
FeedbackVectorSpecBase<StaticFeedbackVectorSpec>::AddTypeProfileSlot();
bool FeedbackVectorSpec::HasTypeProfileSlot() const {
FeedbackSlot slot =
FeedbackVector::ToSlot(FeedbackVectorSpec::kTypeProfileSlotIndex);
@ -77,18 +65,12 @@ void FeedbackMetadata::SetKind(FeedbackSlot slot, FeedbackSlotKind kind) {
set(index, Smi::FromInt(new_data));
}
template Handle<FeedbackMetadata> FeedbackMetadata::New(
Isolate* isolate, const StaticFeedbackVectorSpec* spec);
template Handle<FeedbackMetadata> FeedbackMetadata::New(
Isolate* isolate, const FeedbackVectorSpec* spec);
// static
template <typename Spec>
Handle<FeedbackMetadata> FeedbackMetadata::New(Isolate* isolate,
const Spec* spec) {
const FeedbackVectorSpec* spec) {
Factory* factory = isolate->factory();
const int slot_count = spec->slots();
const int slot_count = spec == nullptr ? 0 : spec->slots();
const int slot_kinds_length = VectorICComputer::word_count(slot_count);
const int length = slot_kinds_length + kReservedIndexCount;
if (length == kReservedIndexCount) {
@ -96,6 +78,7 @@ Handle<FeedbackMetadata> FeedbackMetadata::New(Isolate* isolate,
}
#ifdef DEBUG
for (int i = 0; i < slot_count;) {
DCHECK(spec);
FeedbackSlotKind kind = spec->GetKind(FeedbackSlot(i));
int entry_size = FeedbackMetadata::GetSlotSize(kind);
for (int j = 1; j < entry_size; j++) {
@ -116,6 +99,7 @@ Handle<FeedbackMetadata> FeedbackMetadata::New(Isolate* isolate,
Handle<FeedbackMetadata> metadata = Handle<FeedbackMetadata>::cast(array);
for (int i = 0; i < slot_count; i++) {
DCHECK(spec);
FeedbackSlot slot(i);
FeedbackSlotKind kind = spec->GetKind(slot);
metadata->SetKind(slot, kind);

View File

@ -300,9 +300,25 @@ class FeedbackVector : public HeapObject {
DISALLOW_IMPLICIT_CONSTRUCTORS(FeedbackVector);
};
template <typename Derived>
class V8_EXPORT_PRIVATE FeedbackVectorSpecBase {
class V8_EXPORT_PRIVATE FeedbackVectorSpec {
public:
explicit FeedbackVectorSpec(Zone* zone) : slot_kinds_(zone) {
slot_kinds_.reserve(16);
}
int slots() const { return static_cast<int>(slot_kinds_.size()); }
FeedbackSlotKind GetKind(FeedbackSlot slot) const {
return static_cast<FeedbackSlotKind>(slot_kinds_.at(slot.ToInt()));
}
bool HasTypeProfileSlot() const;
// If used, the TypeProfileSlot is always added as the first slot and its
// index is constant. If other slots are added before the TypeProfileSlot,
// this number changes.
static const int kTypeProfileSlotIndex = 0;
FeedbackSlot AddCallICSlot() { return AddSlot(FeedbackSlotKind::kCall); }
FeedbackSlot AddLoadICSlot() {
@ -380,58 +396,6 @@ class V8_EXPORT_PRIVATE FeedbackVectorSpecBase {
private:
FeedbackSlot AddSlot(FeedbackSlotKind kind);
Derived* This() { return static_cast<Derived*>(this); }
};
class StaticFeedbackVectorSpec
: public FeedbackVectorSpecBase<StaticFeedbackVectorSpec> {
public:
StaticFeedbackVectorSpec() : slot_count_(0) {}
int slots() const { return slot_count_; }
FeedbackSlotKind GetKind(FeedbackSlot slot) const {
DCHECK(slot.ToInt() >= 0 && slot.ToInt() < slot_count_);
return kinds_[slot.ToInt()];
}
private:
friend class FeedbackVectorSpecBase<StaticFeedbackVectorSpec>;
void append(FeedbackSlotKind kind) {
DCHECK_LT(slot_count_, kMaxLength);
kinds_[slot_count_++] = kind;
}
static const int kMaxLength = 12;
int slot_count_;
FeedbackSlotKind kinds_[kMaxLength];
};
class V8_EXPORT_PRIVATE FeedbackVectorSpec
: public FeedbackVectorSpecBase<FeedbackVectorSpec> {
public:
explicit FeedbackVectorSpec(Zone* zone) : slot_kinds_(zone) {
slot_kinds_.reserve(16);
}
int slots() const { return static_cast<int>(slot_kinds_.size()); }
FeedbackSlotKind GetKind(FeedbackSlot slot) const {
return static_cast<FeedbackSlotKind>(slot_kinds_.at(slot.ToInt()));
}
bool HasTypeProfileSlot() const;
// If used, the TypeProfileSlot is always added as the first slot and its
// index is constant. If other slots are added before the TypeProfileSlot,
// this number changes.
static const int kTypeProfileSlotIndex = 0;
private:
friend class FeedbackVectorSpecBase<FeedbackVectorSpec>;
void append(FeedbackSlotKind kind) {
slot_kinds_.push_back(static_cast<unsigned char>(kind));
}
@ -466,8 +430,9 @@ class FeedbackMetadata : public FixedArray {
// Returns slot kind for given slot.
FeedbackSlotKind GetKind(FeedbackSlot slot) const;
template <typename Spec>
static Handle<FeedbackMetadata> New(Isolate* isolate, const Spec* spec);
// If {spec} is null, then it is considered empty.
static Handle<FeedbackMetadata> New(Isolate* isolate,
const FeedbackVectorSpec* spec = nullptr);
#ifdef OBJECT_PRINT
// For gdb debugging.

View File

@ -688,20 +688,16 @@ void TransitionArray::TransitionArrayPrint(std::ostream& os) { // NOLINT
os << "\n";
}
template void FeedbackVectorSpecBase<StaticFeedbackVectorSpec>::Print();
template void FeedbackVectorSpecBase<FeedbackVectorSpec>::Print();
template <typename Derived>
void FeedbackVectorSpecBase<Derived>::Print() {
void FeedbackVectorSpec::Print() {
OFStream os(stdout);
FeedbackVectorSpecPrint(os);
os << std::flush;
}
template <typename Derived>
void FeedbackVectorSpecBase<Derived>::FeedbackVectorSpecPrint(
std::ostream& os) { // NOLINT
int slot_count = This()->slots();
void FeedbackVectorSpec::FeedbackVectorSpecPrint(std::ostream& os) { // NOLINT
int slot_count = slots();
os << " - slot_count: " << slot_count;
if (slot_count == 0) {
os << " (empty)\n";
@ -709,7 +705,7 @@ void FeedbackVectorSpecBase<Derived>::FeedbackVectorSpecPrint(
}
for (int slot = 0; slot < slot_count;) {
FeedbackSlotKind kind = This()->GetKind(FeedbackSlot(slot));
FeedbackSlotKind kind = GetKind(FeedbackSlot(slot));
int entry_size = FeedbackMetadata::GetSlotSize(kind);
DCHECK_LT(0, entry_size);
os << "\n Slot #" << slot << " " << kind;