1// Copyright 2017 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "src/vector-slot-pair.h"
6
7#include "src/feedback-vector.h"
8
9namespace v8 {
10namespace internal {
11
12VectorSlotPair::VectorSlotPair() = default;
13
14int VectorSlotPair::index() const {
15 return vector_.is_null() ? -1 : FeedbackVector::GetIndex(slot_);
16}
17
18bool operator==(VectorSlotPair const& lhs, VectorSlotPair const& rhs) {
19 return lhs.slot() == rhs.slot() &&
20 lhs.vector().location() == rhs.vector().location() &&
21 lhs.ic_state() == rhs.ic_state();
22}
23
24bool operator!=(VectorSlotPair const& lhs, VectorSlotPair const& rhs) {
25 return !(lhs == rhs);
26}
27
28std::ostream& operator<<(std::ostream& os, const VectorSlotPair& p) {
29 if (p.IsValid()) {
30 return os << "VectorSlotPair(" << p.slot() << ", "
31 << InlineCacheState2String(p.ic_state()) << ")";
32 }
33 return os << "VectorSlotPair(INVALID)";
34}
35
36size_t hash_value(VectorSlotPair const& p) {
37 return base::hash_combine(p.slot(), p.vector().location(), p.ic_state());
38}
39
40} // namespace internal
41} // namespace v8
42