summaryrefslogtreecommitdiff
path: root/deps/v8/src/vector-slot-pair.cc
blob: 9a1d13c697233f4fd4574b12ff90722d5fb8404d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// 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 {

VectorSlotPair::VectorSlotPair() = default;

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() &&
         lhs.vector().location() == rhs.vector().location() &&
         lhs.ic_state() == rhs.ic_state();
}

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

std::ostream& operator<<(std::ostream& os, const VectorSlotPair& p) {
  if (p.IsValid()) {
    return os << "VectorSlotPair(" << p.slot() << ", "
              << InlineCacheState2String(p.ic_state()) << ")";
  }
  return os << "VectorSlotPair(INVALID)";
}

size_t hash_value(VectorSlotPair const& p) {
  return base::hash_combine(p.slot(), p.vector().location(), p.ic_state());
}

}  // namespace internal
}  // namespace v8