1 // Copyright 2019 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/compiler/feedback-source.h"
6
7 namespace v8 {
8 namespace internal {
9 namespace compiler {
10
FeedbackSource(Handle<FeedbackVector> vector_,FeedbackSlot slot_)11 FeedbackSource::FeedbackSource(Handle<FeedbackVector> vector_,
12 FeedbackSlot slot_)
13 : vector(vector_), slot(slot_) {
14 DCHECK(!slot.IsInvalid());
15 }
16
FeedbackSource(FeedbackVectorRef vector_,FeedbackSlot slot_)17 FeedbackSource::FeedbackSource(FeedbackVectorRef vector_, FeedbackSlot slot_)
18 : FeedbackSource(vector_.object(), slot_) {}
19
index() const20 int FeedbackSource::index() const {
21 CHECK(IsValid());
22 return FeedbackVector::GetIndex(slot);
23 }
24
operator ==(FeedbackSource const & lhs,FeedbackSource const & rhs)25 bool operator==(FeedbackSource const& lhs, FeedbackSource const& rhs) {
26 return FeedbackSource::Equal()(lhs, rhs);
27 }
28
operator !=(FeedbackSource const & lhs,FeedbackSource const & rhs)29 bool operator!=(FeedbackSource const& lhs, FeedbackSource const& rhs) {
30 return !(lhs == rhs);
31 }
32
operator <<(std::ostream & os,const FeedbackSource & p)33 std::ostream& operator<<(std::ostream& os, const FeedbackSource& p) {
34 if (p.IsValid()) {
35 return os << "FeedbackSource(" << p.slot << ")";
36 }
37 return os << "FeedbackSource(INVALID)";
38 }
39
40 } // namespace compiler
41 } // namespace internal
42 } // namespace v8
43