v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
handler-configuration.h
Go to the documentation of this file.
1// Copyright 2016 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_IC_HANDLER_CONFIGURATION_H_
6#define V8_IC_HANDLER_CONFIGURATION_H_
7
10#include "src/heap/heap.h"
14#include "src/objects/objects.h"
15#include "src/utils/utils.h"
16
17// Has to be the last include (doesn't have include guards):
19
20namespace v8 {
21namespace internal {
22
23class JSProxy;
24
25enum class WasmValueType {
26 kI8,
27 kI16,
28 kI32,
29 kU32, // Used only for loading WasmArray length.
30 kI64,
31 kF32,
32 kF64,
33 kS128,
34
35 kRef,
37
39};
40
41// A set of bit fields representing Smi handlers for loads and a HeapObject
42// that represents load handlers that can't be encoded in a Smi.
43// TODO(ishell): move to load-handler.h
44V8_OBJECT class LoadHandler final : public DataHandler {
45 public:
48
66
67 // Defines whether access rights check should be done on lookup start object.
68 // Applicable to named property kinds only when loading value from prototype
69 // chain. Ignored when loading from lookup start object.
71
72 // Defines whether a lookup should be done on lookup start object before
73 // proceeding to the prototype chain. Applicable to named property kinds only
74 // when loading value from prototype chain. Ignored when loading from lookup
75 // start object.
78
79 //
80 // Encoding when KindBits contains kNativeDataProperty.
81 //
82
83 // Index of a value entry in the descriptor array.
86 // Make sure we don't overflow the smi.
88
89 //
90 // Encoding when KindBits contains kField.
91 //
93
94 //
95 // Encoding when KindBits contains kField and IsWasmStructBits is 0.
96 //
99 // +1 here is to cover all possible JSObject header sizes.
102 // Make sure we don't overflow the smi.
104
105 //
106 // Encoding when KindBits contains kField and IsWasmStructBits is 1.
107 //
110 // Make sure we don't overflow the smi.
112
113 //
114 // Encoding when KindBits contains kElement or kIndexedString.
115 //
117
118 //
119 // Encoding when KindBits contains kElement.
120 //
122
123 //
124 // Encoding when KindBits contains kElement and IsWasmArrayBits is 0.
125 //
129 // Make sure we don't overflow the smi.
131
132 //
133 // Encoding when KindBits contains kElement and IsWasmArrayBits is 1.
134 //
136 // Make sure we don't overflow the smi.
138
139 //
140 // Encoding when KindBits contains kModuleExport.
141 //
143 unsigned,
146
147 // Decodes kind from Smi-handler.
149
150 // Creates a Smi-handler for loading a property from a slow object.
151 static inline Handle<Smi> LoadNormal(Isolate* isolate);
152
153 // Creates a Smi-handler for loading a property from a global object.
154 static inline Handle<Smi> LoadGlobal(Isolate* isolate);
155
156 // Creates a Smi-handler for loading a property from an object with an
157 // interceptor.
158 static inline Handle<Smi> LoadInterceptor(Isolate* isolate);
159
160 // Creates a Smi-handler for loading a property from an object.
161 static inline Handle<Smi> LoadSlow(Isolate* isolate);
162
163 // Creates a Smi-handler for loading a field from fast object.
164 static inline Handle<Smi> LoadField(Isolate* isolate, FieldIndex field_index);
165
166 // Creates a Smi-handler for loading a cached constant from fast
167 // prototype object.
168 static inline Handle<Smi> LoadConstantFromPrototype(Isolate* isolate);
169
170 // Creates a Smi-handler for calling a getter on a fast object.
172
173 // Creates a Smi-handler for calling a getter on a proxy.
174 static inline Handle<Smi> LoadProxy(Isolate* isolate);
175
176 // Creates a Smi-handler for loading a native data property from fast object.
177 static inline Handle<Smi> LoadNativeDataProperty(Isolate* isolate,
178 int descriptor);
179
180 // Creates a Smi-handler for calling a native getter on a fast object.
181 static inline Handle<Smi> LoadApiGetter(Isolate* isolate);
182
183 // Creates a Smi-handler for loading a Module export.
184 // |index| is the index to the "value" slot in the Module's "exports"
185 // dictionary.
186 static inline Handle<Smi> LoadModuleExport(Isolate* isolate, int index);
187
188 static inline DirectHandle<Smi> LoadWasmStructField(Isolate* isolate,
189 WasmValueType type,
190 int offset);
191 static inline DirectHandle<Smi> LoadWasmArrayElement(Isolate* isolate,
192 WasmValueType type);
193
194 // Creates a data handler that represents a load of a non-existent property.
195 // {holder} is the object from which the property is loaded. If no holder is
196 // needed (e.g., for "nonexistent"), null_value() may be passed in.
197 static Handle<Object> LoadFullChain(Isolate* isolate,
198 DirectHandle<Map> receiver_map,
199 const MaybeObjectDirectHandle& holder,
201
202 // Creates a data handler that represents a prototype chain check followed
203 // by given Smi-handler that encoded a load from the holder.
205 Isolate* isolate, DirectHandle<Map> receiver_map,
209
210 // Creates a Smi-handler for loading a non-existent property. Works only as
211 // a part of prototype chain check.
212 static inline Handle<Smi> LoadNonExistent(Isolate* isolate);
213
214 // Creates a Smi-handler for loading an element.
215 static inline Handle<Smi> LoadElement(Isolate* isolate,
216 ElementsKind elements_kind,
217 bool is_js_array,
218 KeyedAccessLoadMode load_mode);
219
220 // Creates a Smi-handler for loading from a String.
221 static inline Handle<Smi> LoadIndexedString(Isolate* isolate,
222 KeyedAccessLoadMode load_mode);
223
224 // Decodes the KeyedAccessLoadMode from a {handler}.
226 Tagged<MaybeObject> handler);
227
228 // Returns true iff the handler can be used in the "holder != lookup start
229 // object" case.
231
232#if defined(OBJECT_PRINT)
233 static void PrintHandler(Tagged<Object> handler, std::ostream& os);
234#endif // defined(OBJECT_PRINT)
236
237// A set of bit fields representing Smi handlers for stores and a HeapObject
238// that represents store handlers that can't be encoded in a Smi.
239// TODO(ishell): move to store-handler.h
240V8_OBJECT class StoreHandler final : public DataHandler {
241 public:
244
245 enum class Kind {
246 kField,
253 kNormal,
255 kSlow,
256 kProxy,
257 kKindsNumber // Keep last
258 };
260
261 // Applicable to kGlobalProxy, kProxy kinds.
262
263 // Defines whether access rights check should be done on lookup start object.
265
266 // Defines whether a lookup should be done on lookup start object before
267 // proceeding to the prototype chain. Applicable to named property kinds only
268 // when storing through prototype chain. Ignored when storing to holder.
271
272 // Applicable to kField, kAccessor and kNativeDataProperty.
273
274 // Index of a value entry in the descriptor array.
277
278 //
279 // Encoding when KindBits contains kStoreSlow.
280 //
283
284 //
285 // Encoding when KindBits contains kField.
286 //
289 // +1 here is to cover all possible JSObject header sizes.
292 // Make sure we don't overflow the smi.
294
295 // Creates a Smi-handler for storing a field to fast object.
296 static inline Handle<Smi> StoreField(Isolate* isolate, int descriptor,
297 FieldIndex field_index,
298 PropertyConstness constness,
299 Representation representation);
300
301 // Creates a Smi-handler for storing a field to a JSSharedStruct.
303 Isolate* isolate, int descriptor, FieldIndex field_index,
304 Representation representation);
305
306 // Create a store transition handler which doesn't check prototype chain.
308 Handle<Map> transition_map);
309
310 // Create a store transition handler with prototype chain validity cell check.
312 Handle<Map> transition_map);
313
314 // Creates a Smi-handler for storing a native data property on a fast object.
315 static inline Handle<Smi> StoreNativeDataProperty(Isolate* isolate,
316 int descriptor);
317
318 // Creates a Smi-handler for calling a setter on a fast object.
320
321 // Creates a Smi-handler for calling a native setter on a fast object.
322 static inline DirectHandle<Smi> StoreApiSetter(Isolate* isolate);
323
325 Isolate* isolate, DirectHandle<Map> receiver_map,
329
331 Isolate* isolate, DirectHandle<Map> receiver_map,
332 DirectHandle<Map> transition, KeyedAccessStoreMode store_mode,
333 MaybeDirectHandle<UnionOf<Smi, Cell>> prev_validity_cell =
335
336 static Handle<Object> StoreProxy(Isolate* isolate,
337 DirectHandle<Map> receiver_map,
338 Handle<JSProxy> proxy,
340
341 // Creates a handler for storing a property to the property cell of a global
342 // object.
344
345 // Creates a Smi-handler for storing a property to a global proxy object.
346 static inline DirectHandle<Smi> StoreGlobalProxy(Isolate* isolate);
347
348 // Creates a Smi-handler for storing a property to a slow object.
349 static inline Handle<Smi> StoreNormal(Isolate* isolate);
350
351 // Creates a Smi-handler for storing a property to an interceptor.
352 static inline Handle<Smi> StoreInterceptor(Isolate* isolate);
353
355 Isolate* isolate, KeyedAccessStoreMode mode);
356 static inline Handle<Code> StoreFastElementBuiltin(Isolate* isolate,
359 Isolate* isolate, KeyedAccessStoreMode mode);
360
361 // Creates a Smi-handler for storing a property.
362 static inline Handle<Smi> StoreSlow(
363 Isolate* isolate,
365
366 // Creates a Smi-handler for storing a property on a proxy.
367 static inline Handle<Smi> StoreProxy(Isolate* isolate);
368 static inline Tagged<Smi> StoreProxy();
369
370 // Decodes the KeyedAccessStoreMode from a {handler}.
372 Tagged<MaybeObject> handler);
373
374#if defined(OBJECT_PRINT)
375 static void PrintHandler(Tagged<Object> handler, std::ostream& os);
376#endif // defined(OBJECT_PRINT)
377
378 private:
379 static inline Handle<Smi> StoreField(Isolate* isolate, Kind kind,
380 int descriptor, FieldIndex field_index,
381 Representation representation);
383
384inline const char* WasmValueType2String(WasmValueType type);
385
386std::ostream& operator<<(std::ostream& os, WasmValueType type);
387
388} // namespace internal
389} // namespace v8
390
392
393#endif // V8_IC_HANDLER_CONFIGURATION_H_
Builtins::Kind kind
Definition builtins.cc:40
static constexpr int kLastUsedBit
Definition bit-field.h:42
Tagged< UnionOf< Smi, Code > > smi_handler() const
static Handle< Smi > LoadSlow(Isolate *isolate)
static DirectHandle< Smi > LoadAccessorFromPrototype(Isolate *isolate)
static Kind GetHandlerKind(Tagged< Smi > smi_handler)
static Handle< Smi > LoadNativeDataProperty(Isolate *isolate, int descriptor)
static Handle< Smi > LoadConstantFromPrototype(Isolate *isolate)
static Handle< Smi > LoadProxy(Isolate *isolate)
static Handle< Smi > LoadNormal(Isolate *isolate)
static Handle< Smi > LoadField(Isolate *isolate, FieldIndex field_index)
static Handle< Smi > LoadNonExistent(Isolate *isolate)
static bool CanHandleHolderNotLookupStart(Tagged< Object > handler)
static Handle< Smi > LoadInterceptor(Isolate *isolate)
static KeyedAccessLoadMode GetKeyedAccessLoadMode(Tagged< MaybeObject > handler)
static Handle< Object > LoadFromPrototype(Isolate *isolate, DirectHandle< Map > receiver_map, DirectHandle< JSReceiver > holder, Tagged< Smi > smi_handler, MaybeObjectDirectHandle maybe_data1=MaybeObjectDirectHandle(), MaybeObjectDirectHandle maybe_data2=MaybeObjectDirectHandle())
static Handle< Smi > LoadModuleExport(Isolate *isolate, int index)
static DirectHandle< Smi > LoadWasmArrayElement(Isolate *isolate, WasmValueType type)
static Handle< Smi > LoadIndexedString(Isolate *isolate, KeyedAccessLoadMode load_mode)
static DirectHandle< Smi > LoadWasmStructField(Isolate *isolate, WasmValueType type, int offset)
static Handle< Smi > LoadApiGetter(Isolate *isolate)
static Handle< Smi > LoadElement(Isolate *isolate, ElementsKind elements_kind, bool is_js_array, KeyedAccessLoadMode load_mode)
static Handle< Smi > LoadGlobal(Isolate *isolate)
static Handle< Object > LoadFullChain(Isolate *isolate, DirectHandle< Map > receiver_map, const MaybeObjectDirectHandle &holder, Handle< Smi > smi_handler)
static Handle< Smi > StoreNormal(Isolate *isolate)
static Handle< Object > StoreThroughPrototype(Isolate *isolate, DirectHandle< Map > receiver_map, DirectHandle< JSReceiver > holder, Tagged< Smi > smi_handler, MaybeObjectDirectHandle maybe_data1=MaybeObjectDirectHandle(), MaybeObjectDirectHandle maybe_data2=MaybeObjectDirectHandle())
static Handle< Smi > StoreSlow(Isolate *isolate, KeyedAccessStoreMode store_mode=KeyedAccessStoreMode::kInBounds)
static KeyedAccessStoreMode GetKeyedAccessStoreMode(Tagged< MaybeObject > handler)
static Handle< Smi > StoreSharedStructField(Isolate *isolate, int descriptor, FieldIndex field_index, Representation representation)
static Handle< Smi > StoreNativeDataProperty(Isolate *isolate, int descriptor)
static Handle< Smi > StoreField(Isolate *isolate, int descriptor, FieldIndex field_index, PropertyConstness constness, Representation representation)
static DirectHandle< Smi > StoreGlobalProxy(Isolate *isolate)
static Handle< Code > StoreFastElementBuiltin(Isolate *isolate, KeyedAccessStoreMode mode)
static DirectHandle< Smi > StoreApiSetter(Isolate *isolate)
static MaybeObjectHandle StoreGlobal(Handle< PropertyCell > cell)
static DirectHandle< Smi > StoreAccessorFromPrototype(Isolate *isolate)
static MaybeObjectHandle StoreTransition(Isolate *isolate, Handle< Map > transition_map)
static Handle< Smi > StoreInterceptor(Isolate *isolate)
static Handle< Code > StoreSloppyArgumentsBuiltin(Isolate *isolate, KeyedAccessStoreMode mode)
static MaybeObjectHandle StoreOwnTransition(Isolate *isolate, Handle< Map > transition_map)
static Handle< Object > StoreElementTransition(Isolate *isolate, DirectHandle< Map > receiver_map, DirectHandle< Map > transition, KeyedAccessStoreMode store_mode, MaybeDirectHandle< UnionOf< Smi, Cell > > prev_validity_cell=kNullMaybeHandle)
static DirectHandle< Code > ElementsTransitionAndStoreBuiltin(Isolate *isolate, KeyedAccessStoreMode mode)
int32_t offset
TNode< Object > receiver
constexpr NullMaybeHandleType kNullMaybeHandle
std::ostream & operator<<(std::ostream &os, AtomicMemoryOrder order)
v8::internal::LoadHandler V8_OBJECT_END
typename detail::FlattenUnionHelper< Union<>, Ts... >::type UnionOf
Definition union.h:123
const int kSmiValueSize
const char * WasmValueType2String(WasmValueType type)
#define DECL_VERIFIER(Name)
#define V8_OBJECT
#define DECL_PRINTER(Name)