v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
literal-objects.h
Go to the documentation of this file.
1// Copyright 2017 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_LITERAL_OBJECTS_H_
6#define V8_OBJECTS_LITERAL_OBJECTS_H_
7
11#include "src/objects/struct.h"
12
13// Has to be the last include (doesn't have include guards):
15
16namespace v8 {
17namespace internal {
18
19class ClassLiteral;
20class StructBodyDescriptor;
21
22#include "torque-generated/src/objects/literal-objects-tq.inc"
23
25 public:
28 static constexpr RootIndex kMapRootIndex =
29 RootIndex::kObjectBoilerplateDescriptionMap;
30 static constexpr bool kLengthEqualsCapacity = true;
31
33 TaggedMember<Smi> backing_store_size_;
35 });
36};
37
38// ObjectBoilerplateDescription is a list of properties consisting of name
39// value pairs. In addition to the properties, it provides the projected number
40// of properties in the backing store. This number includes properties with
41// computed names that are not in the list.
43 : public TaggedArrayBase<ObjectBoilerplateDescription,
44 ObjectBoilerplateDescriptionShape> {
47 public:
49
50 template <class IsolateT>
52 IsolateT* isolate, int boilerplate, int all_properties, int index_keys,
53 bool has_seen_proto, AllocationType allocation = AllocationType::kYoung);
54
55 // ObjectLiteral::Flags for nested object literals.
56 inline int flags() const;
57 inline void set_flags(int value);
58
59 // Number of boilerplate properties and properties with computed names.
60 inline int backing_store_size() const;
62
63 inline int boilerplate_properties_count() const;
64
65 inline Tagged<Object> name(int index) const;
66 inline Tagged<Object> value(int index) const;
67
68 inline void set_key_value(int index, Tagged<Object> key,
69 Tagged<Object> value);
70
73
74 class BodyDescriptor;
75
76 private:
77 static constexpr int kElementsPerEntry = 2;
78 static constexpr int NameIndex(int i) { return i * kElementsPerEntry; }
79 static constexpr int ValueIndex(int i) { return i * kElementsPerEntry + 1; }
80};
81
83 : public TorqueGeneratedArrayBoilerplateDescription<
84 ArrayBoilerplateDescription, Struct> {
85 public:
86 inline ElementsKind elements_kind() const;
88
89 inline bool is_empty() const;
90
91 // Dispatched behavior.
93 void BriefPrintDetails(std::ostream& os);
94
96
97 private:
99};
100
102 public:
103 // Dispatched behavior.
104 void BriefPrintDetails(std::ostream& os);
105
108 DECL_INT_ACCESSORS(flags)
109
112
113#define FIELD_LIST(V) \
114 V(kDataOffset, kTrustedPointerSize) \
115 V(kSourceOffset, kTaggedSize) \
116 V(kFlagsOffset, kTaggedSize) \
117 V(kHeaderSize, 0) \
118 V(kSize, 0)
119 DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, FIELD_LIST)
120#undef FIELD_LIST
121
125
126 private:
128};
129
130class ClassBoilerplate : public Struct {
132
133 public:
135
137#define COMPUTED_ENTRY_BIT_FIELDS(V, _) \
138 V(ValueKindBits, ValueKind, 2, _) \
139 V(KeyIndexBits, unsigned, 29, _)
141#undef COMPUTED_ENTRY_BIT_FIELDS
142 };
143
147 // The index of a first dynamic argument passed to Runtime::kDefineClass
148 // function. The dynamic arguments are consist of method closures and
149 // computed property names.
151 };
152
153 static const int kMinimumClassPropertiesCount = 6;
155
156 template <typename IsolateT>
158 IsolateT* isolate, ClassLiteral* expr,
160
161 DECL_INT_ACCESSORS(arguments_count)
162 DECL_ACCESSORS(static_properties_template, Tagged<Object>)
164 DECL_ACCESSORS(static_computed_properties, Tagged<FixedArray>)
166 DECL_ACCESSORS(instance_elements_template, Tagged<Object>)
168
169 template <typename IsolateT, typename Dictionary>
170 static void AddToPropertiesTemplate(IsolateT* isolate,
171 Handle<Dictionary> dictionary,
172 Handle<Name> name, int key_index,
173 ValueKind value_kind, Tagged<Smi> value);
174
175 template <typename IsolateT>
176 static void AddToElementsTemplate(IsolateT* isolate,
177 Handle<NumberDictionary> dictionary,
178 uint32_t key, int key_index,
179 ValueKind value_kind, Tagged<Smi> value);
180
181#define FIELD_LIST(V) \
182 V(kArgumentsCountOffset, kTaggedSize) \
183 V(kStaticPropertiesTemplateOffset, kTaggedSize) \
184 V(kStaticElementsTemplateOffset, kTaggedSize) \
185 V(kStaticComputedPropertiesOffset, kTaggedSize) \
186 V(kInstancePropertiesTemplateOffset, kTaggedSize) \
187 V(kInstanceElementsTemplateOffset, kTaggedSize) \
188 V(kInstanceComputedPropertiesOffset, kTaggedSize) \
189 V(kUnalignedHeaderSize, OBJECT_POINTER_PADDING(kUnalignedHeaderSize)) \
190 V(kHeaderSize, 0) \
191 V(kSize, 0)
192 DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, FIELD_LIST)
193#undef FIELD_LIST
194
197
199};
200
201} // namespace internal
202} // namespace v8
203
204#include "src/objects/object-macros-undef.h"
205
206#endif // V8_OBJECTS_LITERAL_OBJECTS_H_
#define DEFINE_BIT_FIELDS(LIST_MACRO)
Definition bit-field.h:126
Builtins::Kind kind
Definition builtins.cc:40
static const int kMinimumPrototypePropertiesCount
static void AddToPropertiesTemplate(IsolateT *isolate, Handle< Dictionary > dictionary, Handle< Name > name, int key_index, ValueKind value_kind, Tagged< Smi > value)
static const int kMinimumClassPropertiesCount
static void AddToElementsTemplate(IsolateT *isolate, Handle< NumberDictionary > dictionary, uint32_t key, int key_index, ValueKind value_kind, Tagged< Smi > value)
static Handle< ClassBoilerplate > New(IsolateT *isolate, ClassLiteral *expr, AllocationType allocation=AllocationType::kYoung)
OBJECT_CONSTRUCTORS(ClassBoilerplate, Struct)
V8_ARRAY_EXTRA_FIELDS({ TaggedMember< Smi > backing_store_size_;TaggedMember< Smi > flags_;})
void set_backing_store_size(int backing_store_size)
static Handle< ObjectBoilerplateDescription > New(IsolateT *isolate, int boilerplate, int all_properties, int index_keys, bool has_seen_proto, AllocationType allocation=AllocationType::kYoung)
void set_key_value(int index, Tagged< Object > key, Tagged< Object > value)
OBJECT_CONSTRUCTORS(RegExpBoilerplateDescription, Struct)
JSRegExp::Flags flags_
#define COMPUTED_ENTRY_BIT_FIELDS(V, _)
#define FIELD_LIST(V)
kStaticElementsTemplateOffset kInstancePropertiesTemplateOffset instance_computed_properties
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in name
Definition flags.cc:2086
kStaticElementsTemplateOffset instance_properties_template
return value
Definition map-inl.h:893
V8HeapCompressionSchemeImpl< MainCage > V8HeapCompressionScheme
Definition globals.h:1137
#define DECL_ACCESSORS(name,...)
#define DECL_TRUSTED_POINTER_ACCESSORS(name, type)
#define DECL_VERIFIER(Name)
#define DECL_PRINTER(Name)
#define DECL_INT_ACCESSORS(name)
#define TQ_OBJECT_CONSTRUCTORS(Type)
#define DEFINE_FIELD_OFFSET_CONSTANTS(StartOffset, LIST_MACRO)
Definition utils.h:242