v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
compilation-dependencies.h
Go to the documentation of this file.
1// Copyright 2015 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_COMPILER_COMPILATION_DEPENDENCIES_H_
6#define V8_COMPILER_COMPILATION_DEPENDENCIES_H_
7
11
12namespace v8 {
13namespace internal {
14namespace compiler {
15
27
29
30// Collects and installs dependencies of the code that is being generated.
32 public:
34
35 V8_WARN_UNUSED_RESULT bool Commit(Handle<Code> code);
36
37 // Return the initial map of {function} and record the assumption that it
38 // stays the initial map.
39 MapRef DependOnInitialMap(JSFunctionRef function);
40
41 // Return the "prototype" property of the given function and record the
42 // assumption that it doesn't change.
43 HeapObjectRef DependOnPrototypeProperty(JSFunctionRef function);
44
45 // Record the assumption that {map} stays stable.
46 void DependOnStableMap(MapRef map);
47
48 // Record the assumption that slack tracking for {map} doesn't change during
49 // compilation. This gives no guarantees about slack tracking changes after
50 // the compilation is finished (ie, it Validates the dependency, but doesn't
51 // Install anything).
52 void DependOnNoSlackTrackingChange(MapRef map);
53
54 // Depend on the fact that accessing property |property_name| from
55 // |receiver_map| yields the constant value |constant|, which is held by
56 // |holder|. Therefore, must be invalidated if |property_name| is added to any
57 // of the objects between receiver and |holder| on the prototype chain, b) any
58 // of the objects on the prototype chain up to |holder| change prototypes, or
59 // c) the value of |property_name| in |holder| changes.
60 // If PropertyKind is kData, |constant| is the value of the property in
61 // question. In case of PropertyKind::kAccessor, |constant| is the accessor
62 // function (i.e., getter or setter) itself, not the overall AccessorPair.
63 void DependOnConstantInDictionaryPrototypeChain(MapRef receiver_map,
64 NameRef property_name,
65 ObjectRef constant,
67
68 // Return the pretenure mode of {site} and record the assumption that it does
69 // not change.
70 AllocationType DependOnPretenureMode(AllocationSiteRef site);
71
72 // Return a field's constness and, if kConst, record the assumption that it
73 // remains kConst. The field is identified by the arguments.
74 //
75 // For arrays, arguments objects and value wrappers, only consider the field
76 // kConst if the map is stable (and register stability dependency in that
77 // case). This is to ensure that fast elements kind transitions cannot be
78 // used to mutate fields without deoptimization of the dependent code.
79 PropertyConstness DependOnFieldConstness(MapRef map, MapRef owner,
80 InternalIndex descriptor);
81 CompilationDependency const* FieldConstnessDependencyOffTheRecord(
82 MapRef map, MapRef owner, InternalIndex descriptor);
83
84 // Record the assumption that neither {cell}'s {CellType} changes, nor the
85 // {IsReadOnly()} flag of {cell}'s {PropertyDetails}.
86 void DependOnGlobalProperty(PropertyCellRef cell);
87
88 // Record a property assumption in the script context slot.
89 bool DependOnScriptContextSlotProperty(
90 ContextRef script_context, size_t index,
92
93 // Record the assumption that respective contexts do not have context
94 // extension, if true.
95 bool DependOnEmptyContextExtension(ScopeInfoRef scope_info);
96
97 // Return the validity of the given protector and, if true, record the
98 // assumption that the protector remains valid.
99 bool DependOnProtector(PropertyCellRef cell);
100
101 // Convenience wrappers around {DependOnProtector}.
102 bool DependOnArrayBufferDetachingProtector();
103 bool DependOnArrayIteratorProtector();
104 bool DependOnArraySpeciesProtector();
105 bool DependOnNoElementsProtector();
106 bool DependOnPromiseHookProtector();
107 bool DependOnPromiseSpeciesProtector();
108 bool DependOnPromiseThenProtector();
109 bool DependOnMegaDOMProtector();
110 bool DependOnNoProfilingProtector();
111 bool DependOnNoUndetectableObjectsProtector();
112 bool DependOnStringWrapperToPrimitiveProtector();
113 bool DependOnTypedArrayLengthProtector();
114
115 // Record the assumption that {site}'s {ElementsKind} doesn't change.
116 void DependOnElementsKind(AllocationSiteRef site);
117
118 // Check that an object slot will not change during compilation.
119 void DependOnObjectSlotValue(HeapObjectRef object, int offset,
120 ObjectRef value);
121
122 void DependOnOwnConstantElement(JSObjectRef holder, uint32_t index,
123 ObjectRef element);
124
125 // Record the assumption that the {value} read from {holder} at {index} on the
126 // background thread is the correct value for a given property.
127 void DependOnOwnConstantDataProperty(JSObjectRef holder, MapRef map,
128 FieldIndex index, ObjectRef value);
129 void DependOnOwnConstantDoubleProperty(JSObjectRef holder, MapRef map,
130 FieldIndex index, Float64 value);
131
132 // Record the assumption that the {value} read from {holder} at {index} on the
133 // background thread is the correct value for a given dictionary property.
134 void DependOnOwnConstantDictionaryProperty(JSObjectRef holder,
135 InternalIndex index,
136 ObjectRef value);
137
138 // For each given map, depend on the stability of (the maps of) all prototypes
139 // up to (and including) the {last_prototype}.
140 void DependOnStablePrototypeChains(
141 ZoneVector<MapRef> const& receiver_maps, WhereToStart start,
142 OptionalJSObjectRef last_prototype = OptionalJSObjectRef());
143
144 // For the given map, depend on the stability of (the maps of) all prototypes
145 // up to (and including) the {last_prototype}.
146 void DependOnStablePrototypeChain(
147 MapRef receiver_maps, WhereToStart start,
148 OptionalJSObjectRef last_prototype = OptionalJSObjectRef());
149
150 // Like DependOnElementsKind but also applies to all nested allocation sites.
151 void DependOnElementsKinds(AllocationSiteRef site);
152
153 void DependOnConsistentJSFunctionView(JSFunctionRef function);
154
155 // Predict the final instance size for {function}'s initial map and record
156 // the assumption that this prediction is correct. In addition, register
157 // the initial map dependency. This method returns the {function}'s the
158 // predicted minimum slack instance size count (wrapped together with
159 // the corresponding in-object property count for convenience).
160 SlackTrackingPrediction DependOnInitialMapInstanceSizePrediction(
161 JSFunctionRef function);
162
163 // Records {dependency} if not null.
164 void RecordDependency(CompilationDependency const* dependency);
165
166 // The methods below allow for gathering dependencies without actually
167 // recording them. They can be recorded at a later time via RecordDependency
168 // (or they can be ignored).
169
170 // Gather the assumption that {target_map} can be transitioned to, i.e., that
171 // it does not become deprecated.
172 CompilationDependency const* TransitionDependencyOffTheRecord(
173 MapRef target_map) const;
174
175 // Gather the assumption that the field representation of a field does not
176 // change. The field is identified by the arguments.
177 CompilationDependency const* FieldRepresentationDependencyOffTheRecord(
178 MapRef map, MapRef owner, InternalIndex descriptor,
179 Representation representation) const;
180
181 // Gather the assumption that the field type of a field does not change. The
182 // field is identified by the arguments.
183 CompilationDependency const* FieldTypeDependencyOffTheRecord(
184 MapRef map, MapRef owner, InternalIndex descriptor,
185 ObjectRef /* Contains a FieldType underneath. */ type) const;
186
187#ifdef DEBUG
188 static bool IsFieldRepresentationDependencyOnMap(
189 const CompilationDependency* dep, const Handle<Map>& receiver_map);
190#endif // DEBUG
191
193 size_t operator()(const CompilationDependency* dep) const;
194 };
196 bool operator()(const CompilationDependency* lhs,
197 const CompilationDependency* rhs) const;
198 };
199
200 private:
201 bool PrepareInstall();
202 bool PrepareInstallPredictable();
203
207
208 Zone* const zone_;
211};
212
213} // namespace compiler
214} // namespace internal
215} // namespace v8
216
217#endif // V8_COMPILER_COMPILATION_DEPENDENCIES_H_
Builtins::Kind kind
Definition builtins.cc:40
SlackTrackingPrediction(MapRef initial_map, int instance_size)
int start
JSHeapBroker * broker
int32_t offset
#define V8_EXPORT
Definition v8config.h:800
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671