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 #include "torque-generated/field-offsets.h" 10 11 // Has to be the last include (doesn't have include guards): 12 #include "src/objects/object-macros.h" 13 14 namespace v8 { 15 namespace internal { 16 17 class PropertyCell : public HeapObject { 18 public: 19 // [name]: the name of the global property. 20 DECL_ACCESSORS(name, Name) 21 // [property_details]: details of the global property. 22 DECL_ACCESSORS(property_details_raw, Smi) 23 // [value]: value of the global property. 24 DECL_ACCESSORS(value, Object) 25 // [dependent_code]: dependent code that depends on the type of the global 26 // property. 27 DECL_ACCESSORS(dependent_code, DependentCode) 28 29 inline PropertyDetails property_details() const; 30 inline void set_property_details(PropertyDetails details); 31 32 PropertyCellConstantType GetConstantType(); 33 34 // Computes the new type of a previously uninitialized cell for the given 35 // value. 36 static PropertyCellType TypeForUninitializedCell(Isolate* isolate, 37 Handle<Object> value); 38 // Computes the new type of the cell's contents for the given value, but 39 // without actually modifying the details. 40 static PropertyCellType UpdatedType(Isolate* isolate, 41 Handle<PropertyCell> cell, 42 Handle<Object> value, 43 PropertyDetails details); 44 45 // Prepares property cell at given entry for receiving given value. 46 // As a result the old cell could be invalidated and/or dependent code could 47 // be deoptimized. Returns the prepared property cell. 48 static Handle<PropertyCell> PrepareForValue( 49 Isolate* isolate, Handle<GlobalDictionary> dictionary, 50 InternalIndex entry, Handle<Object> value, PropertyDetails details); 51 52 void ClearAndInvalidate(ReadOnlyRoots roots); 53 static Handle<PropertyCell> InvalidateAndReplaceEntry( 54 Isolate* isolate, Handle<GlobalDictionary> dictionary, 55 InternalIndex entry); 56 57 static void SetValueWithInvalidation(Isolate* isolate, const char* cell_name, 58 Handle<PropertyCell> cell, 59 Handle<Object> new_value); 60 61 DECL_CAST(PropertyCell) 62 63 // Dispatched behavior. 64 DECL_PRINTER(PropertyCell) 65 DECL_VERIFIER(PropertyCell) 66 67 DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, 68 TORQUE_GENERATED_PROPERTY_CELL_FIELDS) 69 70 using BodyDescriptor = FixedBodyDescriptor<kNameOffset, kSize, kSize>; 71 72 OBJECT_CONSTRUCTORS(PropertyCell, HeapObject); 73 }; 74 75 } // namespace internal 76 } // namespace v8 77 78 #include "src/objects/object-macros-undef.h" 79 80 #endif // V8_OBJECTS_PROPERTY_CELL_H_ 81