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 7namespace v8 { 8namespace internal { 9namespace compiler { 10 11FeedbackSource::FeedbackSource(Handle<FeedbackVector> vector_, 12 FeedbackSlot slot_) 13 : vector(vector_), slot(slot_) { 14 DCHECK(!slot.IsInvalid()); 15} 16 17FeedbackSource::FeedbackSource(FeedbackVectorRef vector_, FeedbackSlot slot_) 18 : FeedbackSource(vector_.object(), slot_) {} 19 20int FeedbackSource::index() const { 21 CHECK(IsValid()); 22 return FeedbackVector::GetIndex(slot); 23} 24 25bool operator==(FeedbackSource const& lhs, FeedbackSource const& rhs) { 26 return FeedbackSource::Equal()(lhs, rhs); 27} 28 29bool operator!=(FeedbackSource const& lhs, FeedbackSource const& rhs) { 30 return !(lhs == rhs); 31} 32 33std::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