v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
property-cell.h
Go to the documentation of this file.
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
10
11// Has to be the last include (doesn't have include guards):
13
14namespace v8 {
15namespace internal {
16
17class FixedArray;
18class WeakFixedArray;
19
20#include "torque-generated/src/objects/property-cell-tq.inc"
21
23 : public TorqueGeneratedPropertyCell<PropertyCell, HeapObject> {
24 public:
25 // [name]: the name of the global property.
27
28 // [property_details]: details of the global property.
34
35 // [value]: value of the global property.
38
39 // [dependent_code]: code that depends on the type of the global property.
41
42 // Changes the value and/or property details.
43 // For global properties:
44 inline void Transition(PropertyDetails new_details,
45 DirectHandle<Object> new_value);
46 // For protectors:
48
49 static PropertyCellType InitialType(Isolate* isolate, Tagged<Object> value);
50
51 // Computes the new type of the cell's contents for the given value, but
52 // without actually modifying the details.
53 static PropertyCellType UpdatedType(Isolate* isolate,
54 Tagged<PropertyCell> cell,
55 Tagged<Object> value,
56 PropertyDetails details);
57
58 // Prepares property cell at given entry for receiving given value and sets
59 // that value. As a result the old cell could be invalidated and/or dependent
60 // code could be deoptimized. Returns the (possibly new) property cell.
62 Isolate* isolate, DirectHandle<GlobalDictionary> dictionary,
63 InternalIndex entry, DirectHandle<Object> value, PropertyDetails details);
64
65 void ClearAndInvalidate(Isolate* isolate);
67 Isolate* isolate, DirectHandle<GlobalDictionary> dictionary,
68 InternalIndex entry, PropertyDetails new_details,
69 DirectHandle<Object> new_value);
70
71 // Whether or not the {details} and {value} fit together. This is an
72 // approximation with false positives.
73 static bool CheckDataIsCompatible(PropertyDetails details,
74 Tagged<Object> value);
75
78
79 using BodyDescriptor = FixedBodyDescriptor<kNameOffset, kSize, kSize>;
80
82
83 private:
84 friend class Factory;
85
86 DECL_SETTER(name, Tagged<Name>)
91
92#ifdef DEBUG
93 // Whether the property cell can transition to the given state. This is an
94 // approximation with false positives.
95 bool CanTransitionTo(PropertyDetails new_details,
96 Tagged<Object> new_value) const;
97#endif // DEBUG
98};
99
101 : public TorqueGeneratedContextSidePropertyCell<ContextSidePropertyCell,
102 HeapObject> {
103 public:
104 // Keep in sync with property-cell.tq.
105 // This enum tracks a property of a ScriptContext slot.
106 // The property determines how the slot's value can be accessed and modified.
107 enum Property {
108 kOther = 0, // The slot holds an arbitrary tagged value. kOther is a sink
109 // state and cannot transition to any other state.
110 kConst = 1, // The slot holds a constant value. kConst can transition to
111 // any other state.
112 kSmi = 2, // The slot holds a Smi. kSmi can transition to kMutableInt32,
113 // kMutableHeapNumber, or kOther.
115 3, // // The slot holds a HeapNumber that can be mutated in-place by
116 // optimized code. This HeapNumber should never leak from the slot.
117 // It contains a Int32 value as double. kMutableInt32 can transition
118 // to kMutableHeapNumber or kOther.
120 4, // The slot holds a HeapNumber that can be mutated in-place by
121 // optimized code. This HeapNumber should never leak from the slot.
122 // kMutableHeapNumber can only transition to kOther.
123 };
124
134
136 int value = smi.value();
137 DCHECK_GE(value, 0);
139 return static_cast<Property>(value);
140 }
141
142 inline Property context_side_property() const;
143
144 // [context_side_property_raw]: details of the context slot property.
145 DECL_RELEASE_ACQUIRE_ACCESSORS(context_side_property_raw, Tagged<Smi>)
146
147 // [dependent_code]: code that depends on the constness of the value.
149
152
154 FixedBodyDescriptor<kDependentCodeOffset, kSize, kSize>;
155
157
158 private:
159 friend class Factory;
160};
161
162} // namespace internal
163} // namespace v8
164
165#include "src/objects/object-macros-undef.h"
166
167#endif // V8_OBJECTS_PROPERTY_CELL_H_
static Property FromSmi(Tagged< Smi > smi)
static Tagged< Smi > MutableHeapNumber()
PropertyDetails property_details() const
static PropertyCellType InitialType(Isolate *isolate, Tagged< Object > value)
Definition objects.cc:6440
void ClearAndInvalidate(Isolate *isolate)
Definition objects.cc:6398
static Handle< PropertyCell > PrepareForAndSetValue(Isolate *isolate, DirectHandle< GlobalDictionary > dictionary, InternalIndex entry, DirectHandle< Object > value, PropertyDetails details)
Definition objects.cc:6473
static bool CheckDataIsCompatible(PropertyDetails details, Tagged< Object > value)
Definition objects.cc:6525
static Handle< PropertyCell > InvalidateAndReplaceEntry(Isolate *isolate, DirectHandle< GlobalDictionary > dictionary, InternalIndex entry, PropertyDetails new_details, DirectHandle< Object > new_value)
Definition objects.cc:6408
void UpdatePropertyDetailsExceptCellType(PropertyDetails details)
static PropertyCellType UpdatedType(Isolate *isolate, Tagged< PropertyCell > cell, Tagged< Object > value, PropertyDetails details)
Definition objects.cc:6447
static constexpr Tagged< Smi > FromInt(int value)
Definition smi.h:38
return value
Definition map-inl.h:893
#define DECL_ACCESSORS(name,...)
#define DECL_GETTER(name,...)
#define DECL_ACQUIRE_GETTER(name,...)
#define DECL_VERIFIER(Name)
#define DECL_RELEASE_SETTER(name,...)
#define DECL_PRINTER(Name)
#define DECL_RELEASE_ACQUIRE_ACCESSORS(name,...)
#define TQ_OBJECT_CONSTRUCTORS(Type)
#define DECL_SETTER(name,...)
#define DCHECK_LE(v1, v2)
Definition logging.h:490
#define DCHECK_GE(v1, v2)
Definition logging.h:488