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#ifndef V8_COMPILER_FEEDBACK_SOURCE_H_ 61cb0ef41Sopenharmony_ci#define V8_COMPILER_FEEDBACK_SOURCE_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/compiler/heap-refs.h" 91cb0ef41Sopenharmony_ci#include "src/objects/feedback-vector.h" 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cinamespace v8 { 121cb0ef41Sopenharmony_cinamespace internal { 131cb0ef41Sopenharmony_cinamespace compiler { 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_cistruct FeedbackSource { 161cb0ef41Sopenharmony_ci FeedbackSource() { DCHECK(!IsValid()); } 171cb0ef41Sopenharmony_ci V8_EXPORT_PRIVATE FeedbackSource(Handle<FeedbackVector> vector_, 181cb0ef41Sopenharmony_ci FeedbackSlot slot_); 191cb0ef41Sopenharmony_ci FeedbackSource(FeedbackVectorRef vector_, FeedbackSlot slot_); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci bool IsValid() const { return !vector.is_null() && !slot.IsInvalid(); } 221cb0ef41Sopenharmony_ci int index() const; 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci Handle<FeedbackVector> vector; 251cb0ef41Sopenharmony_ci FeedbackSlot slot; 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci struct Hash { 281cb0ef41Sopenharmony_ci size_t operator()(FeedbackSource const& source) const { 291cb0ef41Sopenharmony_ci return base::hash_combine(source.vector.address(), source.slot); 301cb0ef41Sopenharmony_ci } 311cb0ef41Sopenharmony_ci }; 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci struct Equal { 341cb0ef41Sopenharmony_ci bool operator()(FeedbackSource const& lhs, 351cb0ef41Sopenharmony_ci FeedbackSource const& rhs) const { 361cb0ef41Sopenharmony_ci return lhs.vector.equals(rhs.vector) && lhs.slot == rhs.slot; 371cb0ef41Sopenharmony_ci } 381cb0ef41Sopenharmony_ci }; 391cb0ef41Sopenharmony_ci}; 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_cibool operator==(FeedbackSource const&, FeedbackSource const&); 421cb0ef41Sopenharmony_cibool operator!=(FeedbackSource const&, FeedbackSource const&); 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, 451cb0ef41Sopenharmony_ci FeedbackSource const&); 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ci} // namespace compiler 481cb0ef41Sopenharmony_ci} // namespace internal 491cb0ef41Sopenharmony_ci} // namespace v8 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci#endif // V8_COMPILER_FEEDBACK_SOURCE_H_ 52