vector-slot-pair.cc 1.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/vector-slot-pair.h"

#include "src/feedback-vector.h"

namespace v8 {
namespace internal {

12
VectorSlotPair::VectorSlotPair() = default;
13 14 15 16 17 18 19

int VectorSlotPair::index() const {
  return vector_.is_null() ? -1 : FeedbackVector::GetIndex(slot_);
}

bool operator==(VectorSlotPair const& lhs, VectorSlotPair const& rhs) {
  return lhs.slot() == rhs.slot() &&
20 21
         lhs.vector().location() == rhs.vector().location() &&
         lhs.ic_state() == rhs.ic_state();
22 23 24 25 26 27
}

bool operator!=(VectorSlotPair const& lhs, VectorSlotPair const& rhs) {
  return !(lhs == rhs);
}

28 29 30 31
std::ostream& operator<<(std::ostream& os, const VectorSlotPair& p) {
  if (p.IsValid()) {
    return os << "VectorSlotPair(" << p.slot() << ", "
              << InlineCacheState2String(p.ic_state()) << ")";
32 33 34 35
  }
  return os << "VectorSlotPair(INVALID)";
}

36
size_t hash_value(VectorSlotPair const& p) {
37
  return base::hash_combine(p.slot(), p.vector().location(), p.ic_state());
38 39 40 41
}

}  // namespace internal
}  // namespace v8