5#ifndef V8_HEAP_FACTORY_BASE_H_
6#define V8_HEAP_FACTORY_BASE_H_
18#include "torque-generated/class-forward-declarations.h"
30template <
typename T,
typename Base>
56template <
typename Impl>
67template <
typename Impl>
68class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) TorqueGeneratedFactory {
73#include "torque-generated/factory.inc"
101template <
typename Impl>
102class FactoryBase :
public TorqueGeneratedFactory<Impl> {
111#define ROOT_ACCESSOR(Type, name, CamelName) inline Handle<Type> name();
118 template <AllocationType allocation = AllocationType::kYoung>
119 inline Handle<Number> NewNumber(
double value);
120 template <AllocationType allocation = AllocationType::kYoung>
121 inline Handle<Number> NewNumberFromInt(int32_t value);
122 template <AllocationType allocation = AllocationType::kYoung>
123 inline Handle<Number> NewNumberFromUint(uint32_t value);
124 template <AllocationType allocation = AllocationType::kYoung>
125 inline DirectHandle<Number> NewNumberFromSize(
size_t value);
126 template <AllocationType allocation = AllocationType::kYoung>
127 inline DirectHandle<Number> NewNumberFromInt64(int64_t value);
128 template <AllocationType allocation = AllocationType::kYoung>
129 inline Handle<HeapNumber> NewHeapNumber(
double value);
130 template <AllocationType allocation = AllocationType::kYoung>
131 inline Handle<HeapNumber> NewHeapNumberFromBits(uint64_t bits);
132 template <AllocationType allocation = AllocationType::kYoung>
133 inline Handle<HeapNumber> NewHeapNumberWithHoleNaN();
135 template <AllocationType allocation = AllocationType::kYoung>
136 inline Handle<HeapNumber> NewHeapInt32(int32_t value);
138 template <AllocationType allocation>
139 Handle<HeapNumber> NewHeapNumber();
141 Handle<Struct> NewStruct(InstanceType type,
142 AllocationType allocation = AllocationType::kYoung);
145 Handle<AccessorPair> NewAccessorPair();
148 Handle<FixedArray> NewFixedArray(
149 int length, AllocationType allocation = AllocationType::kYoung);
152 Handle<TrustedFixedArray> NewTrustedFixedArray(
153 int length, AllocationType allocation = AllocationType::kTrusted);
156 Handle<ProtectedFixedArray> NewProtectedFixedArray(
int length);
160 Handle<FixedArray> NewFixedArrayWithMap(
161 DirectHandle<Map> map,
int length,
162 AllocationType allocation = AllocationType::kYoung);
165 Handle<FixedArray> NewFixedArrayWithHoles(
166 int length, AllocationType allocation = AllocationType::kYoung);
169 DirectHandle<FixedArray> NewFixedArrayWithZeroes(
170 int length, AllocationType allocation = AllocationType::kYoung);
175 Handle<FixedArrayBase> NewFixedDoubleArray(
176 int length, AllocationType allocation = AllocationType::kYoung);
180 Handle<WeakFixedArray> NewWeakFixedArrayWithMap(
181 Tagged<Map> map,
int length,
182 AllocationType allocation = AllocationType::kYoung);
187 Handle<WeakFixedArray> NewWeakFixedArray(
188 int length, AllocationType allocation = AllocationType::kYoung);
192 Handle<TrustedWeakFixedArray> NewTrustedWeakFixedArray(
int length);
196 Handle<ProtectedWeakFixedArray> NewProtectedWeakFixedArray(
int length);
199 Handle<ByteArray> NewByteArray(
200 int length, AllocationType allocation = AllocationType::kYoung);
203 Handle<TrustedByteArray> NewTrustedByteArray(
204 int length, AllocationType allocation_type = AllocationType::kTrusted);
206 DirectHandle<DeoptimizationLiteralArray> NewDeoptimizationLiteralArray(
208 DirectHandle<DeoptimizationFrameTranslation>
209 NewDeoptimizationFrameTranslation(
int length);
211 Handle<BytecodeArray> NewBytecodeArray(
212 int length,
const uint8_t* raw_bytecodes,
int frame_size,
214 DirectHandle<TrustedFixedArray> constant_pool,
215 DirectHandle<TrustedByteArray> handler_table,
216 AllocationType allocation = AllocationType::kTrusted);
218 DirectHandle<BytecodeWrapper> NewBytecodeWrapper(
219 AllocationType allocation = AllocationType::kOld);
223 Handle<ObjectBoilerplateDescription> NewObjectBoilerplateDescription(
224 int boilerplate,
int all_properties,
int index_keys,
bool has_seen_proto);
227 Handle<ArrayBoilerplateDescription> NewArrayBoilerplateDescription(
228 ElementsKind elements_kind, DirectHandle<FixedArrayBase> constant_values);
230 DirectHandle<RegExpDataWrapper> NewRegExpDataWrapper();
232 DirectHandle<RegExpBoilerplateDescription> NewRegExpBoilerplateDescription(
233 DirectHandle<RegExpData> data, DirectHandle<String> source,
237 Handle<TemplateObjectDescription> NewTemplateObjectDescription(
238 DirectHandle<FixedArray> raw_strings,
239 DirectHandle<FixedArray> cooked_strings);
241 Handle<Script> NewScript(
242 DirectHandle<UnionOf<String, Undefined>> source,
243 ScriptEventType event_type = ScriptEventType::kCreate);
244 Handle<Script> NewScriptWithId(
245 DirectHandle<UnionOf<String, Undefined>> source,
int script_id,
246 ScriptEventType event_type = ScriptEventType::kCreate);
248 DirectHandle<SloppyArgumentsElements> NewSloppyArgumentsElements(
249 int length, DirectHandle<Context> context,
250 DirectHandle<FixedArray> arguments,
251 AllocationType allocation = AllocationType::kYoung);
252 DirectHandle<ArrayList> NewArrayList(
253 int size, AllocationType allocation = AllocationType::kYoung);
255 Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral(
256 FunctionLiteral*
literal, DirectHandle<Script> script,
bool is_toplevel);
260 Handle<SharedFunctionInfo> CloneSharedFunctionInfo(
261 DirectHandle<SharedFunctionInfo> other);
263 DirectHandle<SharedFunctionInfoWrapper> NewSharedFunctionInfoWrapper(
264 DirectHandle<SharedFunctionInfo> sfi);
266 Handle<PreparseData> NewPreparseData(
int data_length,
int children_length);
268 DirectHandle<UncompiledDataWithoutPreparseData>
269 NewUncompiledDataWithoutPreparseData(Handle<String> inferred_name,
270 int32_t start_position,
271 int32_t end_position);
273 DirectHandle<UncompiledDataWithPreparseData>
274 NewUncompiledDataWithPreparseData(Handle<String> inferred_name,
275 int32_t start_position,
276 int32_t end_position, Handle<PreparseData>);
278 DirectHandle<UncompiledDataWithoutPreparseDataWithJob>
279 NewUncompiledDataWithoutPreparseDataWithJob(Handle<String> inferred_name,
280 int32_t start_position,
281 int32_t end_position);
283 DirectHandle<UncompiledDataWithPreparseDataAndJob>
284 NewUncompiledDataWithPreparseDataAndJob(Handle<String> inferred_name,
285 int32_t start_position,
286 int32_t end_position,
287 Handle<PreparseData>);
290 Handle<FeedbackMetadata> NewFeedbackMetadata(
291 int slot_count,
int create_closure_slot_count,
292 AllocationType allocation = AllocationType::kOld);
294 Handle<CoverageInfo> NewCoverageInfo(
const ZoneVector<SourceRange>& slots);
297 bool convert_encoding =
false);
299 bool convert_encoding =
false);
301 template <
class StringTableKey>
312 int length, uint32_t raw_hash_field);
314 int length, uint32_t raw_hash_field);
318 Handle<String> LookupSingleCharacterStringFromCode(uint16_t code);
325 const char* str,
AllocationType allocation = AllocationType::kYoung) {
326 return NewStringFromOneByte(base::OneByteVector(str), allocation)
331 std::string_view str,
333 return NewStringFromOneByte(base::OneByteVector(str.data(), str.length()),
346 template <
template <
typename>
typename HandleType>
349 HandleType<String> left, HandleType<String> right,
354 bool one_byte,
AllocationType allocation = AllocationType::kYoung);
373 uint32_t length,
AllocationType allocation = AllocationType::kYoung);
382 int number_of_descriptors,
int slack = 0,
388 int at_least_space_for = kSwissNameDictionaryInitialCapacity,
399 AllocationType RefineAllocationTypeForInPlaceInternalizableString(
402#ifdef V8_ENABLE_LEAPTIERING
405 JSDispatchTable::Space* space);
410 static constexpr int kNumberToStringBufferSize = 32;
419 template <
typename StructType>
442 Handle<String> MakeOrFindTwoCharacterString(uint16_t c1, uint16_t c2);
444 template <
typename SeqStringT>
449 Impl*
impl() {
return static_cast<Impl*
>(
this); }
457 friend TorqueGeneratedFactory<Impl>;
458 template <
class Derived,
class Shape,
class Super>
460 template <
class Derived,
class Shape,
class Super>
V8_WARN_UNUSED_RESULT HandleType< String >::MaybeType NewConsString(HandleType< String > left, HandleType< String > right, AllocationType allocation=AllocationType::kYoung)
Handle< String > NewStringFromAsciiChecked(const char *str, AllocationType allocation=AllocationType::kYoung)
Handle< String > NewStringFromAsciiChecked(std::string_view str, AllocationType allocation=AllocationType::kYoung)
Handle< String > InternalizeString(base::Vector< const uint8_t > string, bool convert_encoding=false)
ReadOnlyRoots read_only_roots()
#define EXPORT_TEMPLATE_DECLARE(export)
#define ROOT_ACCESSOR(Type, name, CamelName)
FunctionLiteral * literal
#define MUTABLE_ROOT_LIST(V)
#define READ_ONLY_ROOT_LIST(V)
#define V8_EXPORT_PRIVATE
Address instruction_start
unsigned int inlined_bytecode_size
MaybeHandle< InstructionStream > instruction_stream
int32_t unwinding_info_offset
MaybeHandle< DeoptimizationData > deoptimization_data
MaybeHandle< TrustedByteArray > bytecode_offset_table
MaybeHandle< TrustedObject > bytecode_or_interpreter_data
bool is_context_specialized
MaybeHandle< TrustedByteArray > source_position_table
BytecodeOffset osr_offset
int32_t builtin_jump_table_info_offset
#define V8_WARN_UNUSED_RESULT
std::unique_ptr< ValueMirror > key