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_PROPERTY_CELL_H_
6 : #define V8_OBJECTS_PROPERTY_CELL_H_
7 :
8 : #include "src/objects/heap-object.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 : class PropertyCell : public HeapObject {
17 : public:
18 : // [name]: the name of the global property.
19 : DECL_ACCESSORS(name, Name)
20 : // [property_details]: details of the global property.
21 : DECL_ACCESSORS(property_details_raw, Object)
22 : // [value]: value of the global property.
23 : DECL_ACCESSORS(value, Object)
24 : // [dependent_code]: dependent code that depends on the type of the global
25 : // property.
26 : DECL_ACCESSORS(dependent_code, DependentCode)
27 :
28 : inline PropertyDetails property_details() const;
29 : inline void set_property_details(PropertyDetails details);
30 :
31 : PropertyCellConstantType GetConstantType();
32 :
33 : // Computes the new type of the cell's contents for the given value, but
34 : // without actually modifying the details.
35 : static PropertyCellType UpdatedType(Isolate* isolate,
36 : Handle<PropertyCell> cell,
37 : Handle<Object> value,
38 : PropertyDetails details);
39 : // Prepares property cell at given entry for receiving given value.
40 : // As a result the old cell could be invalidated and/or dependent code could
41 : // be deoptimized. Returns the prepared property cell.
42 : static Handle<PropertyCell> PrepareForValue(
43 : Isolate* isolate, Handle<GlobalDictionary> dictionary, int entry,
44 : Handle<Object> value, PropertyDetails details);
45 :
46 : static Handle<PropertyCell> InvalidateEntry(
47 : Isolate* isolate, Handle<GlobalDictionary> dictionary, int entry);
48 :
49 : static void SetValueWithInvalidation(Isolate* isolate,
50 : Handle<PropertyCell> cell,
51 : Handle<Object> new_value);
52 :
53 : DECL_CAST(PropertyCell)
54 :
55 : // Dispatched behavior.
56 : DECL_PRINTER(PropertyCell)
57 : DECL_VERIFIER(PropertyCell)
58 :
59 : // Layout description.
60 : #define PROPERTY_CELL_FIELDS(V) \
61 : V(kDetailsOffset, kTaggedSize) \
62 : V(kNameOffset, kTaggedSize) \
63 : V(kValueOffset, kTaggedSize) \
64 : V(kDependentCodeOffset, kTaggedSize) \
65 : /* Total size. */ \
66 : V(kSize, 0)
67 :
68 : DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, PROPERTY_CELL_FIELDS)
69 : #undef PROPERTY_CELL_FIELDS
70 :
71 : typedef FixedBodyDescriptor<kNameOffset, kSize, kSize> BodyDescriptor;
72 :
73 121990 : OBJECT_CONSTRUCTORS(PropertyCell, HeapObject);
74 : };
75 :
76 : } // namespace internal
77 : } // namespace v8
78 :
79 : #include "src/objects/object-macros-undef.h"
80 :
81 : #endif // V8_OBJECTS_PROPERTY_CELL_H_
|