11cb0ef41Sopenharmony_ci// Copyright 2019 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#include "src/compiler/feedback-source.h"
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_cinamespace v8 {
81cb0ef41Sopenharmony_cinamespace internal {
91cb0ef41Sopenharmony_cinamespace compiler {
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciFeedbackSource::FeedbackSource(Handle<FeedbackVector> vector_,
121cb0ef41Sopenharmony_ci                               FeedbackSlot slot_)
131cb0ef41Sopenharmony_ci    : vector(vector_), slot(slot_) {
141cb0ef41Sopenharmony_ci  DCHECK(!slot.IsInvalid());
151cb0ef41Sopenharmony_ci}
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ciFeedbackSource::FeedbackSource(FeedbackVectorRef vector_, FeedbackSlot slot_)
181cb0ef41Sopenharmony_ci    : FeedbackSource(vector_.object(), slot_) {}
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciint FeedbackSource::index() const {
211cb0ef41Sopenharmony_ci  CHECK(IsValid());
221cb0ef41Sopenharmony_ci  return FeedbackVector::GetIndex(slot);
231cb0ef41Sopenharmony_ci}
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_cibool operator==(FeedbackSource const& lhs, FeedbackSource const& rhs) {
261cb0ef41Sopenharmony_ci  return FeedbackSource::Equal()(lhs, rhs);
271cb0ef41Sopenharmony_ci}
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_cibool operator!=(FeedbackSource const& lhs, FeedbackSource const& rhs) {
301cb0ef41Sopenharmony_ci  return !(lhs == rhs);
311cb0ef41Sopenharmony_ci}
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, const FeedbackSource& p) {
341cb0ef41Sopenharmony_ci  if (p.IsValid()) {
351cb0ef41Sopenharmony_ci    return os << "FeedbackSource(" << p.slot << ")";
361cb0ef41Sopenharmony_ci  }
371cb0ef41Sopenharmony_ci  return os << "FeedbackSource(INVALID)";
381cb0ef41Sopenharmony_ci}
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci}  // namespace compiler
411cb0ef41Sopenharmony_ci}  // namespace internal
421cb0ef41Sopenharmony_ci}  // namespace v8
43