• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 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_OBJECTS_FEEDBACK_CELL_H_
6 #define V8_OBJECTS_FEEDBACK_CELL_H_
7 
8 #include "src/objects/struct.h"
9 
10 // Has to be the last include (doesn't have include guards):
11 #include "src/objects/object-macros.h"
12 
13 namespace v8 {
14 namespace internal {
15 
16 #include "torque-generated/src/objects/feedback-cell-tq.inc"
17 
18 // This is a special cell used to maintain both the link between a
19 // closure and its feedback vector, as well as a way to count the
20 // number of closures created for a certain function per native
21 // context. There's at most one FeedbackCell for each function in
22 // a native context.
23 class FeedbackCell : public TorqueGeneratedFeedbackCell<FeedbackCell, Struct> {
24  public:
25   // Dispatched behavior.
26   DECL_PRINTER(FeedbackCell)
27 
28   static const int kUnalignedSize = kSize;
29   static const int kAlignedSize = RoundUp<kObjectAlignment>(int{kSize});
30 
31   using TorqueGeneratedFeedbackCell<FeedbackCell, Struct>::value;
32   using TorqueGeneratedFeedbackCell<FeedbackCell, Struct>::set_value;
33 
34   DECL_RELEASE_ACQUIRE_ACCESSORS(value, HeapObject)
35 
36   inline void clear_padding();
37   inline void reset_feedback_vector(
38       base::Optional<std::function<void(HeapObject object, ObjectSlot slot,
39                                         HeapObject target)>>
40           gc_notify_updated_slot = base::nullopt);
41   inline void SetInitialInterruptBudget();
42 
43   // The closure count is encoded in the cell's map, which distinguishes
44   // between zero, one, or many closures. This function records a new closure
45   // creation by updating the map.
46   inline void IncrementClosureCount(Isolate* isolate);
47 
48   using BodyDescriptor =
49       FixedBodyDescriptor<kValueOffset, kInterruptBudgetOffset, kAlignedSize>;
50 
51   TQ_OBJECT_CONSTRUCTORS(FeedbackCell)
52 };
53 
54 }  // namespace internal
55 }  // namespace v8
56 
57 #include "src/objects/object-macros-undef.h"
58 
59 #endif  // V8_OBJECTS_FEEDBACK_CELL_H_
60