Line data Source code
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 : // This is a special cell used to maintain both the link between a
17 : // closure and its feedback vector, as well as a way to count the
18 : // number of closures created for a certain function per native
19 : // context. There's at most one FeedbackCell for each function in
20 : // a native context.
21 : class FeedbackCell : public Struct {
22 : public:
23 : static int GetInitialInterruptBudget() {
24 5703729 : if (FLAG_lazy_feedback_allocation) {
25 0 : return FLAG_budget_for_feedback_vector_allocation;
26 : }
27 5703729 : return FLAG_interrupt_budget;
28 : }
29 :
30 : // [value]: value of the cell.
31 : DECL_ACCESSORS(value, HeapObject)
32 : DECL_INT32_ACCESSORS(interrupt_budget)
33 :
34 : DECL_CAST(FeedbackCell)
35 :
36 : // Dispatched behavior.
37 : DECL_PRINTER(FeedbackCell)
38 : DECL_VERIFIER(FeedbackCell)
39 :
40 : // Layout description.
41 : #define FEEDBACK_CELL_FIELDS(V) \
42 : V(kValueOffset, kTaggedSize) \
43 : /* Non-pointer fields */ \
44 : V(kInterruptBudgetOffset, kInt32Size) \
45 : /* Total size. */ \
46 : V(kUnalignedSize, 0)
47 :
48 : DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, FEEDBACK_CELL_FIELDS)
49 : #undef FEEDBACK_CELL_FIELDS
50 :
51 : static const int kSize = RoundUp<kObjectAlignment>(int{kUnalignedSize});
52 :
53 : inline void clear_padding();
54 :
55 : using BodyDescriptor =
56 : FixedBodyDescriptor<kValueOffset, kInterruptBudgetOffset, kSize>;
57 :
58 : OBJECT_CONSTRUCTORS(FeedbackCell, Struct);
59 : };
60 :
61 : } // namespace internal
62 : } // namespace v8
63 :
64 : #include "src/objects/object-macros-undef.h"
65 :
66 : #endif // V8_OBJECTS_FEEDBACK_CELL_H_
|