5#ifndef V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
6#define V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
22namespace interpreter {
25#define SINGLETON_CONSTANT_ENTRY_TYPES(V) \
26 V(AsyncIteratorSymbol, async_iterator_symbol) \
27 V(ClassFieldsSymbol, class_fields_symbol) \
28 V(EmptyObjectBoilerplateDescription, empty_object_boilerplate_description) \
29 V(EmptyArrayBoilerplateDescription, empty_array_boilerplate_description) \
30 V(EmptyFixedArray, empty_fixed_array) \
31 V(IteratorSymbol, iterator_symbol) \
32 V(InterpreterTrampolineSymbol, interpreter_trampoline_symbol) \
45 static const size_t k16BitCapacity = (1u << 2 *
kBitsPerByte) - k8BitCapacity;
48 static const size_t k32BitCapacity =
49 kMaxUInt32 - k16BitCapacity - k8BitCapacity + 1;
54 template <
typename IsolateT>
61 template <typename IsolateT>
71 size_t Insert(
double number);
75 size_t Insert(const
Scope* scope);
76#define INSERT_ENTRY(NAME, ...) size_t Insert##NAME();
83 size_t InsertDeferred();
88 size_t InsertJumpTable(
size_t size);
91 void SetDeferredAt(
size_t index, Handle<Object>
object);
95 void SetJumpTableSmi(
size_t index, Tagged<Smi> smi);
100 OperandSize CreateReservedEntry(
101 OperandSize minimum_operand_size = OperandSize::kNone);
105 size_t CommitReservedEntry(OperandSize operand_size, Tagged<Smi> value);
108 void DiscardReservedEntry(OperandSize operand_size);
117 enum class Tag : uint8_t;
122 : heap_number_(heap_number), tag_(
Tag::kHeapNumber) {}
124 : raw_string_(raw_string), tag_(
Tag::kRawString) {}
126 : cons_string_(cons_string), tag_(
Tag::kConsString) {}
130#define CONSTRUCT_ENTRY(NAME, LOWER_NAME) \
131 static Entry NAME() { return Entry(Tag::k##NAME); }
133#undef CONSTRUCT_ENTRY
138 return Entry(Tag::kUninitializedJumpTableSmi);
144 return tag_ == Tag::kUninitializedJumpTableSmi ||
145 tag_ == Tag::kJumpTableSmi;
155 DCHECK_EQ(tag_, Tag::kUninitializedJumpTableSmi);
156 tag_ = Tag::kJumpTableSmi;
160 template <
typename IsolateT>
176 enum class Tag : uint8_t {
185 kUninitializedJumpTableSmi,
187#define ENTRY_TAG(NAME, ...) k##NAME,
198 index_t AllocateIndex(Entry constant_entry);
199 index_t AllocateIndexArray(Entry constant_entry,
size_t size);
210 size_t Allocate(
Entry entry,
size_t count = 1);
211 Entry& At(
size_t index);
212 const Entry& At(
size_t index)
const;
215 template <
typename IsolateT>
216 void CheckAllElementsAreUnique(IsolateT* isolate)
const;
219 inline size_t available()
const {
return capacity() - reserved() -
size(); }
220 inline size_t reserved()
const {
return reserved_; }
221 inline size_t capacity()
const {
return capacity_; }
222 inline size_t size()
const {
return constants_.size(); }
224 inline size_t max_index()
const {
return start_index_ + capacity() - 1; }
247#define SINGLETON_ENTRY_FIELD(NAME, LOWER_NAME) int LOWER_NAME##_ = -1;
249#undef SINGLETON_ENTRY_FIELD
void SetJumpTableSmi(Tagged< Smi > smi)
static Entry UninitializedJumpTableSmi()
Entry(const AstRawString *raw_string)
IndirectHandle< Object > handle_
Entry(double heap_number)
void SetDeferred(Handle< Object > handle)
const AstRawString * raw_string_
const AstConsString * cons_string_
Entry(const AstConsString *cons_string)
Entry(const Scope *scope)
bool IsJumpTableEntry() const
ZoneMap< double, index_t > heap_number_map_
ZoneMap< Tagged< Smi >, index_t > smi_map_
base::TemplateHashMapImpl< intptr_t, index_t, base::KeyEqualityMatcher< intptr_t >, ZoneAllocationPolicy > constants_map_
ZoneVector< std::pair< Tagged< Smi >, index_t > > smi_pairs_
#define INSERT_ENTRY(NAME, LOWER_NAME)
#define ENTRY_TAG(NAME,...)
#define SINGLETON_ENTRY_FIELD(NAME, LOWER_NAME)
#define SINGLETON_CONSTANT_ENTRY_TYPES(V)
#define CONSTRUCT_ENTRY(NAME, LOWER_NAME)
DeclarationScope * scope_
#define EXPORT_TEMPLATE_DECLARE(export)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
constexpr int kBitsPerByte
constexpr uint32_t kMaxUInt32
#define DCHECK_EQ(v1, v2)
#define V8_EXPORT_PRIVATE
ConstantArraySlice(const ConstantArraySlice &)=delete
OperandSize operand_size_
OperandSize operand_size() const
ConstantArraySlice & operator=(const ConstantArraySlice &)=delete
ZoneVector< Entry > constants_
size_t start_index() const
const size_t start_index_
WasmOrphanedGlobalHandle * handle_