chromium/v8/src/heap/factory-base.cc

// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/heap/factory-base.h"

#include "src/ast/ast-source-ranges.h"
#include "src/ast/ast.h"
#include "src/common/assert-scope.h"
#include "src/common/globals.h"
#include "src/execution/local-isolate.h"
#include "src/handles/handles-inl.h"
#include "src/heap/factory.h"
#include "src/heap/heap-inl.h"
#include "src/heap/large-page-metadata-inl.h"
#include "src/heap/local-factory-inl.h"
#include "src/heap/mutable-page-metadata.h"
#include "src/heap/read-only-heap.h"
#include "src/logging/local-logger.h"
#include "src/logging/log.h"
#include "src/objects/arguments-inl.h"
#include "src/objects/instance-type.h"
#include "src/objects/js-regexp-inl.h"
#include "src/objects/literal-objects-inl.h"
#include "src/objects/module-inl.h"
#include "src/objects/oddball.h"
#include "src/objects/shared-function-info-inl.h"
#include "src/objects/shared-function-info.h"
#include "src/objects/source-text-module.h"
#include "src/objects/string-inl.h"
#include "src/objects/string.h"
#include "src/objects/swiss-name-dictionary-inl.h"
#include "src/objects/template-objects-inl.h"
#include "src/roots/roots.h"

namespace v8 {
namespace internal {

template <typename Impl>
template <AllocationType allocation>
Handle<HeapNumber> FactoryBase<Impl>::NewHeapNumber() {}

template V8_EXPORT_PRIVATE Handle<HeapNumber>
FactoryBase<Factory>::NewHeapNumber<AllocationType::kYoung>();
template V8_EXPORT_PRIVATE Handle<HeapNumber>
FactoryBase<Factory>::NewHeapNumber<AllocationType::kOld>();
template V8_EXPORT_PRIVATE Handle<HeapNumber>
FactoryBase<Factory>::NewHeapNumber<AllocationType::kReadOnly>();
template V8_EXPORT_PRIVATE Handle<HeapNumber>
FactoryBase<Factory>::NewHeapNumber<AllocationType::kSharedOld>();

template V8_EXPORT_PRIVATE Handle<HeapNumber>
FactoryBase<LocalFactory>::NewHeapNumber<AllocationType::kOld>();

template <typename Impl>
Handle<Struct> FactoryBase<Impl>::NewStruct(InstanceType type,
                                            AllocationType allocation) {}

template <typename Impl>
Handle<AccessorPair> FactoryBase<Impl>::NewAccessorPair() {}

template <typename Impl>
Handle<Code> FactoryBase<Impl>::NewCode(const NewCodeOptions& options) {}

template <typename Impl>
Handle<CodeWrapper> FactoryBase<Impl>::NewCodeWrapper() {}

template <typename Impl>
Handle<FixedArray> FactoryBase<Impl>::NewFixedArray(int length,
                                                    AllocationType allocation) {}

template <typename Impl>
Handle<TrustedFixedArray> FactoryBase<Impl>::NewTrustedFixedArray(
    int length, AllocationType allocation) {}

template <typename Impl>
Handle<ProtectedFixedArray> FactoryBase<Impl>::NewProtectedFixedArray(
    int length) {}

template <typename Impl>
Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithMap(
    DirectHandle<Map> map, int length, AllocationType allocation) {}

template <typename Impl>
Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithHoles(
    int length, AllocationType allocation) {}

template <typename Impl>
Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithFiller(
    DirectHandle<Map> map, int length, DirectHandle<HeapObject> filler,
    AllocationType allocation) {}

template <typename Impl>
Handle<FixedArray> FactoryBase<Impl>::NewFixedArrayWithZeroes(
    int length, AllocationType allocation) {}

template <typename Impl>
Handle<FixedArrayBase> FactoryBase<Impl>::NewFixedDoubleArray(
    int length, AllocationType allocation) {}

template <typename Impl>
Handle<WeakFixedArray> FactoryBase<Impl>::NewWeakFixedArrayWithMap(
    Tagged<Map> map, int length, AllocationType allocation) {}

template <typename Impl>
Handle<WeakFixedArray> FactoryBase<Impl>::NewWeakFixedArray(
    int length, AllocationType allocation) {}

template <typename Impl>
Handle<TrustedWeakFixedArray> FactoryBase<Impl>::NewTrustedWeakFixedArray(
    int length) {}

template <typename Impl>
Handle<ByteArray> FactoryBase<Impl>::NewByteArray(int length,
                                                  AllocationType allocation) {}

template <typename Impl>
Handle<TrustedByteArray> FactoryBase<Impl>::NewTrustedByteArray(
    int length, AllocationType allocation_type) {}

template <typename Impl>
Handle<DeoptimizationLiteralArray>
FactoryBase<Impl>::NewDeoptimizationLiteralArray(int length) {}

template <typename Impl>
Handle<DeoptimizationFrameTranslation>
FactoryBase<Impl>::NewDeoptimizationFrameTranslation(int length) {}

template <typename Impl>
Handle<BytecodeArray> FactoryBase<Impl>::NewBytecodeArray(
    int length, const uint8_t* raw_bytecodes, int frame_size,
    uint16_t parameter_count, uint16_t max_arguments,
    DirectHandle<TrustedFixedArray> constant_pool,
    DirectHandle<TrustedByteArray> handler_table, AllocationType allocation) {}

template <typename Impl>
Handle<BytecodeWrapper> FactoryBase<Impl>::NewBytecodeWrapper(
    AllocationType allocation) {}

template <typename Impl>
Handle<Script> FactoryBase<Impl>::NewScript(
    DirectHandle<UnionOf<String, Undefined>> source,
    ScriptEventType script_event_type) {}

template <typename Impl>
Handle<Script> FactoryBase<Impl>::NewScriptWithId(
    DirectHandle<UnionOf<String, Undefined>> source, int script_id,
    ScriptEventType script_event_type) {}

template <typename Impl>
Handle<SloppyArgumentsElements> FactoryBase<Impl>::NewSloppyArgumentsElements(
    int length, DirectHandle<Context> context,
    DirectHandle<FixedArray> arguments, AllocationType allocation) {}

template <typename Impl>
Handle<ArrayList> FactoryBase<Impl>::NewArrayList(int size,
                                                  AllocationType allocation) {}

template <typename Impl>
Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfoForLiteral(
    FunctionLiteral* literal, DirectHandle<Script> script, bool is_toplevel) {}

template <typename Impl>
Handle<SharedFunctionInfo> FactoryBase<Impl>::CloneSharedFunctionInfo(
    DirectHandle<SharedFunctionInfo> other) {}

template <typename Impl>
Handle<SharedFunctionInfoWrapper>
FactoryBase<Impl>::NewSharedFunctionInfoWrapper(
    DirectHandle<SharedFunctionInfo> sfi) {}

template <typename Impl>
Handle<PreparseData> FactoryBase<Impl>::NewPreparseData(int data_length,
                                                        int children_length) {}

template <typename Impl>
Handle<UncompiledDataWithoutPreparseData>
FactoryBase<Impl>::NewUncompiledDataWithoutPreparseData(
    Handle<String> inferred_name, int32_t start_position,
    int32_t end_position) {}

template <typename Impl>
Handle<UncompiledDataWithPreparseData>
FactoryBase<Impl>::NewUncompiledDataWithPreparseData(
    Handle<String> inferred_name, int32_t start_position, int32_t end_position,
    Handle<PreparseData> preparse_data) {}

template <typename Impl>
Handle<UncompiledDataWithoutPreparseDataWithJob>
FactoryBase<Impl>::NewUncompiledDataWithoutPreparseDataWithJob(
    Handle<String> inferred_name, int32_t start_position,
    int32_t end_position) {}

template <typename Impl>
Handle<UncompiledDataWithPreparseDataAndJob>
FactoryBase<Impl>::NewUncompiledDataWithPreparseDataAndJob(
    Handle<String> inferred_name, int32_t start_position, int32_t end_position,
    Handle<PreparseData> preparse_data) {}

template <typename Impl>
Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo(
    MaybeDirectHandle<String> maybe_name,
    MaybeDirectHandle<HeapObject> maybe_function_data, Builtin builtin,
    FunctionKind kind) {}

template <typename Impl>
Handle<ObjectBoilerplateDescription>
FactoryBase<Impl>::NewObjectBoilerplateDescription(int boilerplate,
                                                   int all_properties,
                                                   int index_keys,
                                                   bool has_seen_proto) {}

template <typename Impl>
Handle<ArrayBoilerplateDescription>
FactoryBase<Impl>::NewArrayBoilerplateDescription(
    ElementsKind elements_kind, DirectHandle<FixedArrayBase> constant_values) {}

template <typename Impl>
Handle<RegExpDataWrapper> FactoryBase<Impl>::NewRegExpDataWrapper() {}

template <typename Impl>
Handle<RegExpBoilerplateDescription>
FactoryBase<Impl>::NewRegExpBoilerplateDescription(
    DirectHandle<RegExpData> data, DirectHandle<String> source,
    Tagged<Smi> flags) {}

template <typename Impl>
Handle<TemplateObjectDescription>
FactoryBase<Impl>::NewTemplateObjectDescription(
    DirectHandle<FixedArray> raw_strings,
    DirectHandle<FixedArray> cooked_strings) {}

template <typename Impl>
Handle<FeedbackMetadata> FactoryBase<Impl>::NewFeedbackMetadata(
    int slot_count, int create_closure_slot_count, AllocationType allocation) {}

template <typename Impl>
Handle<CoverageInfo> FactoryBase<Impl>::NewCoverageInfo(
    const ZoneVector<SourceRange>& slots) {}

template <typename Impl>
Handle<String> FactoryBase<Impl>::MakeOrFindTwoCharacterString(uint16_t c1,
                                                               uint16_t c2) {}

template <typename Impl>
template <class StringTableKey>
Handle<String> FactoryBase<Impl>::InternalizeStringWithKey(
    StringTableKey* key) {}

template EXPORT_TEMPLATE_DEFINE()
    Handle<String> FactoryBase<Factory>::InternalizeStringWithKey(
        OneByteStringKey* key);
template EXPORT_TEMPLATE_DEFINE()
    Handle<String> FactoryBase<Factory>::InternalizeStringWithKey(
        TwoByteStringKey* key);
template EXPORT_TEMPLATE_DEFINE()
    Handle<String> FactoryBase<Factory>::InternalizeStringWithKey(
        SeqOneByteSubStringKey* key);
template EXPORT_TEMPLATE_DEFINE()
    Handle<String> FactoryBase<Factory>::InternalizeStringWithKey(
        SeqTwoByteSubStringKey* key);

template EXPORT_TEMPLATE_DEFINE()
    Handle<String> FactoryBase<LocalFactory>::InternalizeStringWithKey(
        OneByteStringKey* key);
template EXPORT_TEMPLATE_DEFINE()
    Handle<String> FactoryBase<LocalFactory>::InternalizeStringWithKey(
        TwoByteStringKey* key);

template <typename Impl>
Handle<String> FactoryBase<Impl>::InternalizeString(
    base::Vector<const uint8_t> string, bool convert_encoding) {}

template <typename Impl>
Handle<String> FactoryBase<Impl>::InternalizeString(
    base::Vector<const uint16_t> string, bool convert_encoding) {}

template <typename Impl>
Handle<SeqOneByteString> FactoryBase<Impl>::NewOneByteInternalizedString(
    base::Vector<const uint8_t> str, uint32_t raw_hash_field) {}

template <typename Impl>
Handle<SeqTwoByteString> FactoryBase<Impl>::NewTwoByteInternalizedString(
    base::Vector<const base::uc16> str, uint32_t raw_hash_field) {}

template <typename Impl>
Handle<SeqOneByteString>
FactoryBase<Impl>::NewOneByteInternalizedStringFromTwoByte(
    base::Vector<const base::uc16> str, uint32_t raw_hash_field) {}

template <typename Impl>
template <typename SeqStringT>
MaybeHandle<SeqStringT> FactoryBase<Impl>::NewRawStringWithMap(
    int length, Tagged<Map> map, AllocationType allocation) {}

template <typename Impl>
MaybeHandle<SeqOneByteString> FactoryBase<Impl>::NewRawOneByteString(
    int length, AllocationType allocation) {}

template <typename Impl>
MaybeHandle<SeqTwoByteString> FactoryBase<Impl>::NewRawTwoByteString(
    int length, AllocationType allocation) {}

template <typename Impl>
MaybeHandle<SeqOneByteString> FactoryBase<Impl>::NewRawSharedOneByteString(
    int length) {}

template <typename Impl>
MaybeHandle<SeqTwoByteString> FactoryBase<Impl>::NewRawSharedTwoByteString(
    int length) {}

template <typename Impl>
MaybeHandle<String> FactoryBase<Impl>::NewConsString(
    Handle<String> left, Handle<String> right, AllocationType allocation) {}

template <typename Impl>
Handle<String> FactoryBase<Impl>::NewConsString(DirectHandle<String> left,
                                                DirectHandle<String> right,
                                                int length, bool one_byte,
                                                AllocationType allocation) {}

template <typename Impl>
Handle<String> FactoryBase<Impl>::LookupSingleCharacterStringFromCode(
    uint16_t code) {}

template <typename Impl>
MaybeHandle<String> FactoryBase<Impl>::NewStringFromOneByte(
    base::Vector<const uint8_t> string, AllocationType allocation) {}
namespace {

template <typename Impl>
V8_INLINE Handle<String> CharToString(FactoryBase<Impl>* factory,
                                      const char* string,
                                      NumberCacheMode mode) {}

}  // namespace

template <typename Impl>
Handle<String> FactoryBase<Impl>::NumberToString(DirectHandle<Object> number,
                                                 NumberCacheMode mode) {}

template <typename Impl>
Handle<String> FactoryBase<Impl>::HeapNumberToString(
    DirectHandle<HeapNumber> number, double value, NumberCacheMode mode) {}

template <typename Impl>
inline Handle<String> FactoryBase<Impl>::SmiToString(Tagged<Smi> number,
                                                     NumberCacheMode mode) {}

template <typename Impl>
Handle<FreshlyAllocatedBigInt> FactoryBase<Impl>::NewBigInt(
    int length, AllocationType allocation) {}

template <typename Impl>
Handle<ScopeInfo> FactoryBase<Impl>::NewScopeInfo(int length,
                                                  AllocationType type) {}

template <typename Impl>
Handle<SourceTextModuleInfo> FactoryBase<Impl>::NewSourceTextModuleInfo() {}

template <typename Impl>
Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo(
    AllocationType allocation) {}

template <typename Impl>
Handle<DescriptorArray> FactoryBase<Impl>::NewDescriptorArray(
    int number_of_descriptors, int slack, AllocationType allocation) {}

template <typename Impl>
Handle<ClassPositions> FactoryBase<Impl>::NewClassPositions(int start,
                                                            int end) {}

template <typename Impl>
Handle<SeqOneByteString>
FactoryBase<Impl>::AllocateRawOneByteInternalizedString(
    int length, uint32_t raw_hash_field) {}

template <typename Impl>
Handle<SeqTwoByteString>
FactoryBase<Impl>::AllocateRawTwoByteInternalizedString(
    int length, uint32_t raw_hash_field) {}

template <typename Impl>
Tagged<HeapObject> FactoryBase<Impl>::AllocateRawArray(
    int size, AllocationType allocation) {}

template <typename Impl>
Tagged<HeapObject> FactoryBase<Impl>::AllocateRawFixedArray(
    int length, AllocationType allocation) {}

template <typename Impl>
Tagged<HeapObject> FactoryBase<Impl>::AllocateRawWeakArrayList(
    int capacity, AllocationType allocation) {}

template <typename Impl>
Tagged<HeapObject> FactoryBase<Impl>::NewWithImmortalMap(
    Tagged<Map> map, AllocationType allocation) {}

template <typename Impl>
Tagged<HeapObject> FactoryBase<Impl>::AllocateRawWithImmortalMap(
    int size, AllocationType allocation, Tagged<Map> map,
    AllocationAlignment alignment) {}

template <typename Impl>
Tagged<HeapObject> FactoryBase<Impl>::AllocateRaw(
    int size, AllocationType allocation, AllocationAlignment alignment) {}

template <typename Impl>
Handle<SwissNameDictionary>
FactoryBase<Impl>::NewSwissNameDictionaryWithCapacity(
    int capacity, AllocationType allocation) {}

template <typename Impl>
Handle<SwissNameDictionary> FactoryBase<Impl>::NewSwissNameDictionary(
    int at_least_space_for, AllocationType allocation) {}

template <typename Impl>
Handle<FunctionTemplateRareData>
FactoryBase<Impl>::NewFunctionTemplateRareData() {}

template <typename Impl>
MaybeDirectHandle<Map> FactoryBase<Impl>::GetInPlaceInternalizedStringMap(
    Tagged<Map> from_string_map) {}

template <typename Impl>
AllocationType
FactoryBase<Impl>::RefineAllocationTypeForInPlaceInternalizableString(
    AllocationType allocation, Tagged<Map> string_map) {}

// Instantiate FactoryBase for the two variants we want.
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) FactoryBase<Factory>;
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
    FactoryBase<LocalFactory>;

}  // namespace internal
}  // namespace v8