• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef V8_COMPILER_FEEDBACK_SOURCE_H_
6 #define V8_COMPILER_FEEDBACK_SOURCE_H_
7 
8 #include "src/compiler/heap-refs.h"
9 #include "src/objects/feedback-vector.h"
10 
11 namespace v8 {
12 namespace internal {
13 namespace compiler {
14 
15 struct FeedbackSource {
FeedbackSourceFeedbackSource16   FeedbackSource() { DCHECK(!IsValid()); }
17   V8_EXPORT_PRIVATE FeedbackSource(Handle<FeedbackVector> vector_,
18                                    FeedbackSlot slot_);
19   FeedbackSource(FeedbackVectorRef vector_, FeedbackSlot slot_);
20 
IsValidFeedbackSource21   bool IsValid() const { return !vector.is_null() && !slot.IsInvalid(); }
22   int index() const;
23 
24   Handle<FeedbackVector> vector;
25   FeedbackSlot slot;
26 
27   struct Hash {
operatorFeedbackSource::Hash28     size_t operator()(FeedbackSource const& source) const {
29       return base::hash_combine(source.vector.address(), source.slot);
30     }
31   };
32 
33   struct Equal {
operatorFeedbackSource::Equal34     bool operator()(FeedbackSource const& lhs,
35                     FeedbackSource const& rhs) const {
36       return lhs.vector.equals(rhs.vector) && lhs.slot == rhs.slot;
37     }
38   };
39 };
40 
41 bool operator==(FeedbackSource const&, FeedbackSource const&);
42 bool operator!=(FeedbackSource const&, FeedbackSource const&);
43 
44 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
45                                            FeedbackSource const&);
46 
47 }  // namespace compiler
48 }  // namespace internal
49 }  // namespace v8
50 
51 #endif  // V8_COMPILER_FEEDBACK_SOURCE_H_
52