LCOV - code coverage report
Current view: top level - src/heap - factory.h (source / functions) Hit Total Coverage
Test: app.info Lines: 15 15 100.0 %
Date: 2019-01-20 Functions: 26 26 100.0 %

          Line data    Source code
       1             : // Copyright 2014 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_HEAP_FACTORY_H_
       6             : #define V8_HEAP_FACTORY_H_
       7             : 
       8             : // Clients of this interface shouldn't depend on lots of heap internals.
       9             : // Do not include anything from src/heap here!
      10             : #include "src/builtins/builtins.h"
      11             : #include "src/globals.h"
      12             : #include "src/handles.h"
      13             : #include "src/heap/heap.h"
      14             : #include "src/maybe-handles.h"
      15             : #include "src/messages.h"
      16             : #include "src/objects/code.h"
      17             : #include "src/objects/dictionary.h"
      18             : #include "src/objects/hash-table.h"
      19             : #include "src/objects/js-array.h"
      20             : #include "src/objects/js-regexp.h"
      21             : #include "src/objects/ordered-hash-table.h"
      22             : #include "src/objects/string.h"
      23             : 
      24             : namespace v8 {
      25             : namespace internal {
      26             : 
      27             : // Forward declarations.
      28             : class AliasedArgumentsEntry;
      29             : class ObjectBoilerplateDescription;
      30             : class BreakPoint;
      31             : class BreakPointInfo;
      32             : class CallableTask;
      33             : class CallbackTask;
      34             : class CallHandlerInfo;
      35             : class Expression;
      36             : class EmbedderDataArray;
      37             : class ArrayBoilerplateDescription;
      38             : class CoverageInfo;
      39             : class DebugInfo;
      40             : class EnumCache;
      41             : class FreshlyAllocatedBigInt;
      42             : class Isolate;
      43             : class JSDataView;
      44             : class JSGeneratorObject;
      45             : class JSMap;
      46             : class JSMapIterator;
      47             : class JSModuleNamespace;
      48             : class JSPromise;
      49             : class JSProxy;
      50             : class JSSet;
      51             : class JSSetIterator;
      52             : class JSTypedArray;
      53             : class JSWeakMap;
      54             : class LoadHandler;
      55             : class ModuleInfo;
      56             : class NativeContext;
      57             : class NewFunctionArgs;
      58             : class PreparseData;
      59             : class PromiseResolveThenableJobTask;
      60             : class RegExpMatchInfo;
      61             : class ScriptContextTable;
      62             : class StackFrameInfo;
      63             : class StoreHandler;
      64             : class TemplateObjectDescription;
      65             : class UncompiledDataWithoutPreparseData;
      66             : class UncompiledDataWithPreparseData;
      67             : class WasmExportedFunctionData;
      68             : class WeakFactoryCleanupJobTask;
      69             : struct SourceRange;
      70             : template <typename T>
      71             : class ZoneVector;
      72             : enum class SharedFlag : uint32_t;
      73             : 
      74             : enum FunctionMode {
      75             :   kWithNameBit = 1 << 0,
      76             :   kWithHomeObjectBit = 1 << 1,
      77             :   kWithWritablePrototypeBit = 1 << 2,
      78             :   kWithReadonlyPrototypeBit = 1 << 3,
      79             :   kWithPrototypeBits = kWithWritablePrototypeBit | kWithReadonlyPrototypeBit,
      80             : 
      81             :   // Without prototype.
      82             :   FUNCTION_WITHOUT_PROTOTYPE = 0,
      83             :   METHOD_WITH_NAME = kWithNameBit,
      84             :   METHOD_WITH_HOME_OBJECT = kWithHomeObjectBit,
      85             :   METHOD_WITH_NAME_AND_HOME_OBJECT = kWithNameBit | kWithHomeObjectBit,
      86             : 
      87             :   // With writable prototype.
      88             :   FUNCTION_WITH_WRITEABLE_PROTOTYPE = kWithWritablePrototypeBit,
      89             :   FUNCTION_WITH_NAME_AND_WRITEABLE_PROTOTYPE =
      90             :       kWithWritablePrototypeBit | kWithNameBit,
      91             :   FUNCTION_WITH_HOME_OBJECT_AND_WRITEABLE_PROTOTYPE =
      92             :       kWithWritablePrototypeBit | kWithHomeObjectBit,
      93             :   FUNCTION_WITH_NAME_AND_HOME_OBJECT_AND_WRITEABLE_PROTOTYPE =
      94             :       kWithWritablePrototypeBit | kWithNameBit | kWithHomeObjectBit,
      95             : 
      96             :   // With readonly prototype.
      97             :   FUNCTION_WITH_READONLY_PROTOTYPE = kWithReadonlyPrototypeBit,
      98             :   FUNCTION_WITH_NAME_AND_READONLY_PROTOTYPE =
      99             :       kWithReadonlyPrototypeBit | kWithNameBit,
     100             : };
     101             : 
     102             : // Interface for handle based allocation.
     103             : class V8_EXPORT_PRIVATE Factory {
     104             :  public:
     105             :   Handle<Oddball> NewOddball(Handle<Map> map, const char* to_string,
     106             :                              Handle<Object> to_number, const char* type_of,
     107             :                              byte kind,
     108             :                              PretenureFlag pretenure = TENURED_READ_ONLY);
     109             : 
     110             :   // Marks self references within code generation.
     111             :   Handle<Oddball> NewSelfReferenceMarker(PretenureFlag pretenure = TENURED);
     112             : 
     113             :   // Allocates a fixed array-like object with given map and initialized with
     114             :   // undefined values.
     115             :   template <typename T = FixedArray>
     116             :   Handle<T> NewFixedArrayWithMap(RootIndex map_root_index, int length,
     117             :                                  PretenureFlag pretenure = NOT_TENURED);
     118             : 
     119             :   // Allocates a weak fixed array-like object with given map and initialized
     120             :   // with undefined values.
     121             :   template <typename T = WeakFixedArray>
     122             :   Handle<T> NewWeakFixedArrayWithMap(RootIndex map_root_index, int length,
     123             :                                      PretenureFlag pretenure = NOT_TENURED);
     124             : 
     125             :   // Allocates a fixed array initialized with undefined values.
     126             :   Handle<FixedArray> NewFixedArray(int length,
     127             :                                    PretenureFlag pretenure = NOT_TENURED);
     128             : 
     129             :   // Allocates a fixed array which may contain in-place weak references. The
     130             :   // array is initialized with undefined values
     131             :   Handle<WeakFixedArray> NewWeakFixedArray(
     132             :       int length, PretenureFlag pretenure = NOT_TENURED);
     133             : 
     134             :   // Allocates a property array initialized with undefined values.
     135             :   Handle<PropertyArray> NewPropertyArray(int length,
     136             :                                          PretenureFlag pretenure = NOT_TENURED);
     137             :   // Tries allocating a fixed array initialized with undefined values.
     138             :   // In case of an allocation failure (OOM) an empty handle is returned.
     139             :   // The caller has to manually signal an
     140             :   // v8::internal::Heap::FatalProcessOutOfMemory typically by calling
     141             :   // NewFixedArray as a fallback.
     142             :   V8_WARN_UNUSED_RESULT
     143             :   MaybeHandle<FixedArray> TryNewFixedArray(
     144             :       int length, PretenureFlag pretenure = NOT_TENURED);
     145             : 
     146             :   // Allocate a new fixed array with non-existing entries (the hole).
     147             :   Handle<FixedArray> NewFixedArrayWithHoles(
     148             :       int length, PretenureFlag pretenure = NOT_TENURED);
     149             : 
     150             :   // Allocates an uninitialized fixed array. It must be filled by the caller.
     151             :   Handle<FixedArray> NewUninitializedFixedArray(
     152             :       int length, PretenureFlag pretenure = NOT_TENURED);
     153             : 
     154             :   // Allocates a feedback vector whose slots are initialized with undefined
     155             :   // values.
     156             :   Handle<FeedbackVector> NewFeedbackVector(
     157             :       Handle<SharedFunctionInfo> shared, PretenureFlag pretenure = NOT_TENURED);
     158             : 
     159             :   // Allocates a clean embedder data array with given capacity.
     160             :   Handle<EmbedderDataArray> NewEmbedderDataArray(
     161             :       int length, PretenureFlag pretenure = NOT_TENURED);
     162             : 
     163             :   // Allocates a fixed array for name-value pairs of boilerplate properties and
     164             :   // calculates the number of properties we need to store in the backing store.
     165             :   Handle<ObjectBoilerplateDescription> NewObjectBoilerplateDescription(
     166             :       int boilerplate, int all_properties, int index_keys, bool has_seen_proto);
     167             : 
     168             :   // Allocate a new uninitialized fixed double array.
     169             :   // The function returns a pre-allocated empty fixed array for length = 0,
     170             :   // so the return type must be the general fixed array class.
     171             :   Handle<FixedArrayBase> NewFixedDoubleArray(
     172             :       int length, PretenureFlag pretenure = NOT_TENURED);
     173             : 
     174             :   // Allocate a new fixed double array with hole values.
     175             :   Handle<FixedArrayBase> NewFixedDoubleArrayWithHoles(
     176             :       int size, PretenureFlag pretenure = NOT_TENURED);
     177             : 
     178             :   // Allocates a FeedbackMedata object and zeroes the data section.
     179             :   Handle<FeedbackMetadata> NewFeedbackMetadata(int slot_count,
     180             :                                                PretenureFlag tenure = TENURED);
     181             : 
     182             :   Handle<FrameArray> NewFrameArray(int number_of_frames,
     183             :                                    PretenureFlag pretenure = NOT_TENURED);
     184             : 
     185             :   Handle<OrderedHashSet> NewOrderedHashSet();
     186             :   Handle<OrderedHashMap> NewOrderedHashMap();
     187             :   Handle<OrderedNameDictionary> NewOrderedNameDictionary();
     188             : 
     189             :   Handle<SmallOrderedHashSet> NewSmallOrderedHashSet(
     190             :       int capacity = SmallOrderedHashSet::kMinCapacity,
     191             :       PretenureFlag pretenure = NOT_TENURED);
     192             :   Handle<SmallOrderedHashMap> NewSmallOrderedHashMap(
     193             :       int capacity = SmallOrderedHashMap::kMinCapacity,
     194             :       PretenureFlag pretenure = NOT_TENURED);
     195             :   Handle<SmallOrderedNameDictionary> NewSmallOrderedNameDictionary(
     196             :       int capacity = SmallOrderedHashMap::kMinCapacity,
     197             :       PretenureFlag pretenure = NOT_TENURED);
     198             : 
     199             :   // Create a new PrototypeInfo struct.
     200             :   Handle<PrototypeInfo> NewPrototypeInfo();
     201             : 
     202             :   // Create a new EnumCache struct.
     203             :   Handle<EnumCache> NewEnumCache(Handle<FixedArray> keys,
     204             :                                  Handle<FixedArray> indices);
     205             : 
     206             :   // Create a new Tuple2 struct.
     207             :   Handle<Tuple2> NewTuple2(Handle<Object> value1, Handle<Object> value2,
     208             :                            PretenureFlag pretenure);
     209             : 
     210             :   // Create a new Tuple3 struct.
     211             :   Handle<Tuple3> NewTuple3(Handle<Object> value1, Handle<Object> value2,
     212             :                            Handle<Object> value3, PretenureFlag pretenure);
     213             : 
     214             :   // Create a new ArrayBoilerplateDescription struct.
     215             :   Handle<ArrayBoilerplateDescription> NewArrayBoilerplateDescription(
     216             :       ElementsKind elements_kind, Handle<FixedArrayBase> constant_values);
     217             : 
     218             :   // Create a new TemplateObjectDescription struct.
     219             :   Handle<TemplateObjectDescription> NewTemplateObjectDescription(
     220             :       Handle<FixedArray> raw_strings, Handle<FixedArray> cooked_strings);
     221             : 
     222             :   // Create a pre-tenured empty AccessorPair.
     223             :   Handle<AccessorPair> NewAccessorPair();
     224             : 
     225             :   // Finds the internalized copy for string in the string table.
     226             :   // If not found, a new string is added to the table and returned.
     227             :   Handle<String> InternalizeUtf8String(Vector<const char> str);
     228    14452590 :   Handle<String> InternalizeUtf8String(const char* str) {
     229    14452590 :     return InternalizeUtf8String(CStrVector(str));
     230             :   }
     231             : 
     232             :   Handle<String> InternalizeOneByteString(Vector<const uint8_t> str);
     233             :   Handle<String> InternalizeOneByteString(Handle<SeqOneByteString>, int from,
     234             :                                           int length);
     235             : 
     236             :   Handle<String> InternalizeTwoByteString(Vector<const uc16> str);
     237             : 
     238             :   template <class StringTableKey>
     239             :   Handle<String> InternalizeStringWithKey(StringTableKey* key);
     240             : 
     241             :   // Internalized strings are created in the old generation (data space).
     242             :   inline Handle<String> InternalizeString(Handle<String> string);
     243             : 
     244             :   inline Handle<Name> InternalizeName(Handle<Name> name);
     245             : 
     246             :   // String creation functions.  Most of the string creation functions take
     247             :   // a Heap::PretenureFlag argument to optionally request that they be
     248             :   // allocated in the old generation.  The pretenure flag defaults to
     249             :   // DONT_TENURE.
     250             :   //
     251             :   // Creates a new String object.  There are two String encodings: one-byte and
     252             :   // two-byte.  One should choose between the three string factory functions
     253             :   // based on the encoding of the string buffer that the string is
     254             :   // initialized from.
     255             :   //   - ...FromOneByte initializes the string from a buffer that is Latin1
     256             :   //     encoded (it does not check that the buffer is Latin1 encoded) and
     257             :   //     the result will be Latin1 encoded.
     258             :   //   - ...FromUtf8 initializes the string from a buffer that is UTF-8
     259             :   //     encoded.  If the characters are all ASCII characters, the result
     260             :   //     will be Latin1 encoded, otherwise it will converted to two-byte.
     261             :   //   - ...FromTwoByte initializes the string from a buffer that is two-byte
     262             :   //     encoded.  If the characters are all Latin1 characters, the result
     263             :   //     will be converted to Latin1, otherwise it will be left as two-byte.
     264             :   //
     265             :   // One-byte strings are pretenured when used as keys in the SourceCodeCache.
     266             :   V8_WARN_UNUSED_RESULT MaybeHandle<String> NewStringFromOneByte(
     267             :       Vector<const uint8_t> str, PretenureFlag pretenure = NOT_TENURED);
     268             : 
     269             :   template <size_t N>
     270        2591 :   inline Handle<String> NewStringFromStaticChars(
     271             :       const char (&str)[N], PretenureFlag pretenure = NOT_TENURED) {
     272             :     DCHECK(N == StrLength(str) + 1);
     273             :     return NewStringFromOneByte(StaticCharVector(str), pretenure)
     274        5182 :         .ToHandleChecked();
     275             :   }
     276             : 
     277    37795542 :   inline Handle<String> NewStringFromAsciiChecked(
     278             :       const char* str, PretenureFlag pretenure = NOT_TENURED) {
     279             :     return NewStringFromOneByte(OneByteVector(str), pretenure)
     280    75591086 :         .ToHandleChecked();
     281             :   }
     282             : 
     283             :   // UTF8 strings are pretenured when used for regexp literal patterns and
     284             :   // flags in the parser.
     285             :   V8_WARN_UNUSED_RESULT MaybeHandle<String> NewStringFromUtf8(
     286             :       Vector<const char> str, PretenureFlag pretenure = NOT_TENURED);
     287             : 
     288             :   V8_WARN_UNUSED_RESULT MaybeHandle<String> NewStringFromUtf8SubString(
     289             :       Handle<SeqOneByteString> str, int begin, int end,
     290             :       PretenureFlag pretenure = NOT_TENURED);
     291             : 
     292             :   V8_WARN_UNUSED_RESULT MaybeHandle<String> NewStringFromTwoByte(
     293             :       Vector<const uc16> str, PretenureFlag pretenure = NOT_TENURED);
     294             : 
     295             :   V8_WARN_UNUSED_RESULT MaybeHandle<String> NewStringFromTwoByte(
     296             :       const ZoneVector<uc16>* str, PretenureFlag pretenure = NOT_TENURED);
     297             : 
     298             :   Handle<JSStringIterator> NewJSStringIterator(Handle<String> string);
     299             : 
     300             :   // Allocates an internalized string in old space based on the character
     301             :   // stream.
     302             :   Handle<String> NewInternalizedStringFromUtf8(Vector<const char> str,
     303             :                                                int chars, uint32_t hash_field);
     304             : 
     305             :   Handle<String> NewOneByteInternalizedString(Vector<const uint8_t> str,
     306             :                                               uint32_t hash_field);
     307             : 
     308             :   Handle<String> NewOneByteInternalizedSubString(
     309             :       Handle<SeqOneByteString> string, int offset, int length,
     310             :       uint32_t hash_field);
     311             : 
     312             :   Handle<String> NewTwoByteInternalizedString(Vector<const uc16> str,
     313             :                                               uint32_t hash_field);
     314             : 
     315             :   Handle<String> NewInternalizedStringImpl(Handle<String> string, int chars,
     316             :                                            uint32_t hash_field);
     317             : 
     318             :   // Compute the matching internalized string map for a string if possible.
     319             :   // Empty handle is returned if string is in new space or not flattened.
     320             :   V8_WARN_UNUSED_RESULT MaybeHandle<Map> InternalizedStringMapForString(
     321             :       Handle<String> string);
     322             : 
     323             :   // Creates an internalized copy of an external string. |string| must be
     324             :   // of type StringClass.
     325             :   template <class StringClass>
     326             :   Handle<StringClass> InternalizeExternalString(Handle<String> string);
     327             : 
     328             :   // Allocates and partially initializes an one-byte or two-byte String. The
     329             :   // characters of the string are uninitialized. Currently used in regexp code
     330             :   // only, where they are pretenured.
     331             :   V8_WARN_UNUSED_RESULT MaybeHandle<SeqOneByteString> NewRawOneByteString(
     332             :       int length, PretenureFlag pretenure = NOT_TENURED);
     333             :   V8_WARN_UNUSED_RESULT MaybeHandle<SeqTwoByteString> NewRawTwoByteString(
     334             :       int length, PretenureFlag pretenure = NOT_TENURED);
     335             : 
     336             :   // Creates a single character string where the character has given code.
     337             :   // A cache is used for Latin1 codes.
     338             :   Handle<String> LookupSingleCharacterStringFromCode(uint32_t code);
     339             : 
     340             :   // Create a new cons string object which consists of a pair of strings.
     341             :   V8_WARN_UNUSED_RESULT MaybeHandle<String> NewConsString(Handle<String> left,
     342             :                                                           Handle<String> right);
     343             : 
     344             :   V8_WARN_UNUSED_RESULT Handle<String> NewConsString(Handle<String> left,
     345             :                                                      Handle<String> right,
     346             :                                                      int length, bool one_byte);
     347             : 
     348             :   // Create or lookup a single characters tring made up of a utf16 surrogate
     349             :   // pair.
     350             :   Handle<String> NewSurrogatePairString(uint16_t lead, uint16_t trail);
     351             : 
     352             :   // Create a new string object which holds a proper substring of a string.
     353             :   Handle<String> NewProperSubString(Handle<String> str, int begin, int end);
     354             : 
     355             :   // Create a new string object which holds a substring of a string.
     356             :   inline Handle<String> NewSubString(Handle<String> str, int begin, int end);
     357             : 
     358             :   // Creates a new external String object.  There are two String encodings
     359             :   // in the system: one-byte and two-byte.  Unlike other String types, it does
     360             :   // not make sense to have a UTF-8 factory function for external strings,
     361             :   // because we cannot change the underlying buffer.  Note that these strings
     362             :   // are backed by a string resource that resides outside the V8 heap.
     363             :   V8_WARN_UNUSED_RESULT MaybeHandle<String> NewExternalStringFromOneByte(
     364             :       const ExternalOneByteString::Resource* resource);
     365             :   V8_WARN_UNUSED_RESULT MaybeHandle<String> NewExternalStringFromTwoByte(
     366             :       const ExternalTwoByteString::Resource* resource);
     367             :   // Create a new external string object for one-byte encoded native script.
     368             :   // It does not cache the resource data pointer.
     369             :   Handle<ExternalOneByteString> NewNativeSourceString(
     370             :       const ExternalOneByteString::Resource* resource);
     371             : 
     372             :   // Create a symbol in old or read-only space.
     373             :   Handle<Symbol> NewSymbol(PretenureFlag pretenure = TENURED);
     374             :   Handle<Symbol> NewPrivateSymbol(PretenureFlag pretenure = TENURED);
     375             :   Handle<Symbol> NewPrivateNameSymbol(Handle<String> name);
     376             : 
     377             :   // Create a global (but otherwise uninitialized) context.
     378             :   Handle<NativeContext> NewNativeContext();
     379             : 
     380             :   // Create a script context.
     381             :   Handle<Context> NewScriptContext(Handle<NativeContext> outer,
     382             :                                    Handle<ScopeInfo> scope_info);
     383             : 
     384             :   // Create an empty script context table.
     385             :   Handle<ScriptContextTable> NewScriptContextTable();
     386             : 
     387             :   // Create a module context.
     388             :   Handle<Context> NewModuleContext(Handle<Module> module,
     389             :                                    Handle<NativeContext> outer,
     390             :                                    Handle<ScopeInfo> scope_info);
     391             : 
     392             :   // Create a function or eval context.
     393             :   Handle<Context> NewFunctionContext(Handle<Context> outer,
     394             :                                      Handle<ScopeInfo> scope_info);
     395             : 
     396             :   // Create a catch context.
     397             :   Handle<Context> NewCatchContext(Handle<Context> previous,
     398             :                                   Handle<ScopeInfo> scope_info,
     399             :                                   Handle<Object> thrown_object);
     400             : 
     401             :   // Create a 'with' context.
     402             :   Handle<Context> NewWithContext(Handle<Context> previous,
     403             :                                  Handle<ScopeInfo> scope_info,
     404             :                                  Handle<JSReceiver> extension);
     405             : 
     406             :   Handle<Context> NewDebugEvaluateContext(Handle<Context> previous,
     407             :                                           Handle<ScopeInfo> scope_info,
     408             :                                           Handle<JSReceiver> extension,
     409             :                                           Handle<Context> wrapped,
     410             :                                           Handle<StringSet> whitelist);
     411             : 
     412             :   // Create a block context.
     413             :   Handle<Context> NewBlockContext(Handle<Context> previous,
     414             :                                   Handle<ScopeInfo> scope_info);
     415             : 
     416             :   // Create a context that's used by builtin functions.
     417             :   //
     418             :   // These are similar to function context but don't have a previous
     419             :   // context or any scope info. These are used to store spec defined
     420             :   // context values.
     421             :   Handle<Context> NewBuiltinContext(Handle<NativeContext> native_context,
     422             :                                     int length);
     423             : 
     424             :   Handle<Struct> NewStruct(InstanceType type,
     425             :                            PretenureFlag pretenure = NOT_TENURED);
     426             : 
     427             :   Handle<AliasedArgumentsEntry> NewAliasedArgumentsEntry(
     428             :       int aliased_context_slot);
     429             : 
     430             :   Handle<AccessorInfo> NewAccessorInfo();
     431             : 
     432             :   Handle<Script> NewScript(Handle<String> source,
     433             :                            PretenureFlag tenure = TENURED);
     434             :   Handle<Script> NewScriptWithId(Handle<String> source, int script_id,
     435             :                                  PretenureFlag tenure = TENURED);
     436             :   Handle<Script> CloneScript(Handle<Script> script);
     437             : 
     438             :   Handle<BreakPointInfo> NewBreakPointInfo(int source_position);
     439             :   Handle<BreakPoint> NewBreakPoint(int id, Handle<String> condition);
     440             :   Handle<StackFrameInfo> NewStackFrameInfo();
     441             :   Handle<SourcePositionTableWithFrameCache>
     442             :   NewSourcePositionTableWithFrameCache(
     443             :       Handle<ByteArray> source_position_table,
     444             :       Handle<SimpleNumberDictionary> stack_frame_cache);
     445             : 
     446             :   // Allocate various microtasks.
     447             :   Handle<CallableTask> NewCallableTask(Handle<JSReceiver> callable,
     448             :                                        Handle<Context> context);
     449             :   Handle<CallbackTask> NewCallbackTask(Handle<Foreign> callback,
     450             :                                        Handle<Foreign> data);
     451             :   Handle<PromiseResolveThenableJobTask> NewPromiseResolveThenableJobTask(
     452             :       Handle<JSPromise> promise_to_resolve, Handle<JSReceiver> then,
     453             :       Handle<JSReceiver> thenable, Handle<Context> context);
     454             :   Handle<WeakFactoryCleanupJobTask> NewWeakFactoryCleanupJobTask(
     455             :       Handle<JSWeakFactory> weak_factory);
     456             : 
     457             :   // Foreign objects are pretenured when allocated by the bootstrapper.
     458             :   Handle<Foreign> NewForeign(Address addr,
     459             :                              PretenureFlag pretenure = NOT_TENURED);
     460             : 
     461             :   Handle<ByteArray> NewByteArray(int length,
     462             :                                  PretenureFlag pretenure = NOT_TENURED);
     463             : 
     464             :   Handle<BytecodeArray> NewBytecodeArray(int length, const byte* raw_bytecodes,
     465             :                                          int frame_size, int parameter_count,
     466             :                                          Handle<FixedArray> constant_pool);
     467             : 
     468             :   Handle<FixedTypedArrayBase> NewFixedTypedArrayWithExternalPointer(
     469             :       int length, ExternalArrayType array_type, void* external_pointer,
     470             :       PretenureFlag pretenure = NOT_TENURED);
     471             : 
     472             :   Handle<FixedTypedArrayBase> NewFixedTypedArray(
     473             :       size_t length, size_t byte_length, ExternalArrayType array_type,
     474             :       bool initialize, PretenureFlag pretenure = NOT_TENURED);
     475             : 
     476             :   Handle<Cell> NewCell(Handle<Object> value);
     477             : 
     478             :   Handle<PropertyCell> NewPropertyCell(Handle<Name> name,
     479             :                                        PretenureFlag pretenure = TENURED);
     480             : 
     481             :   Handle<FeedbackCell> NewNoClosuresCell(Handle<HeapObject> value);
     482             :   Handle<FeedbackCell> NewOneClosureCell(Handle<HeapObject> value);
     483             :   Handle<FeedbackCell> NewManyClosuresCell(Handle<HeapObject> value);
     484             :   Handle<FeedbackCell> NewNoFeedbackCell();
     485             : 
     486             :   Handle<DescriptorArray> NewDescriptorArray(
     487             :       int number_of_entries, int slack = 0,
     488             :       PretenureFlag pretenure = NOT_TENURED);
     489             :   Handle<TransitionArray> NewTransitionArray(int number_of_transitions,
     490             :                                              int slack = 0);
     491             : 
     492             :   // Allocate a tenured AllocationSite. Its payload is null.
     493             :   Handle<AllocationSite> NewAllocationSite(bool with_weak_next);
     494             : 
     495             :   // Allocates and initializes a new Map.
     496             :   Handle<Map> NewMap(InstanceType type, int instance_size,
     497             :                      ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
     498             :                      int inobject_properties = 0);
     499             :   // Initializes the fields of a newly created Map. Exposed for tests and
     500             :   // heap setup; other code should just call NewMap which takes care of it.
     501             :   Map InitializeMap(Map map, InstanceType type, int instance_size,
     502             :                     ElementsKind elements_kind, int inobject_properties);
     503             : 
     504             :   // Allocate a block of memory in the given space (filled with a filler).
     505             :   // Used as a fall-back for generated code when the space is full.
     506             :   Handle<HeapObject> NewFillerObject(int size, bool double_align,
     507             :                                      AllocationSpace space);
     508             : 
     509             :   Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function);
     510             : 
     511             :   // Returns a deep copy of the JavaScript object.
     512             :   // Properties and elements are copied too.
     513             :   Handle<JSObject> CopyJSObject(Handle<JSObject> object);
     514             :   // Same as above, but also takes an AllocationSite to be appended in an
     515             :   // AllocationMemento.
     516             :   Handle<JSObject> CopyJSObjectWithAllocationSite(Handle<JSObject> object,
     517             :                                                   Handle<AllocationSite> site);
     518             : 
     519             :   Handle<FixedArray> CopyFixedArrayWithMap(Handle<FixedArray> array,
     520             :                                            Handle<Map> map);
     521             : 
     522             :   Handle<FixedArray> CopyFixedArrayAndGrow(
     523             :       Handle<FixedArray> array, int grow_by,
     524             :       PretenureFlag pretenure = NOT_TENURED);
     525             : 
     526             :   Handle<WeakFixedArray> CopyWeakFixedArrayAndGrow(
     527             :       Handle<WeakFixedArray> array, int grow_by,
     528             :       PretenureFlag pretenure = NOT_TENURED);
     529             : 
     530             :   Handle<WeakArrayList> CopyWeakArrayListAndGrow(
     531             :       Handle<WeakArrayList> array, int grow_by,
     532             :       PretenureFlag pretenure = NOT_TENURED);
     533             : 
     534             :   Handle<PropertyArray> CopyPropertyArrayAndGrow(
     535             :       Handle<PropertyArray> array, int grow_by,
     536             :       PretenureFlag pretenure = NOT_TENURED);
     537             : 
     538             :   Handle<FixedArray> CopyFixedArrayUpTo(Handle<FixedArray> array, int new_len,
     539             :                                         PretenureFlag pretenure = NOT_TENURED);
     540             : 
     541             :   Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array);
     542             : 
     543             :   // This method expects a COW array in new space, and creates a copy
     544             :   // of it in old space.
     545             :   Handle<FixedArray> CopyAndTenureFixedCOWArray(Handle<FixedArray> array);
     546             : 
     547             :   Handle<FixedDoubleArray> CopyFixedDoubleArray(Handle<FixedDoubleArray> array);
     548             : 
     549             :   Handle<FeedbackVector> CopyFeedbackVector(Handle<FeedbackVector> array);
     550             : 
     551             :   // Numbers (e.g. literals) are pretenured by the parser.
     552             :   // The return value may be a smi or a heap number.
     553             :   Handle<Object> NewNumber(double value, PretenureFlag pretenure = NOT_TENURED);
     554             : 
     555             :   Handle<Object> NewNumberFromInt(int32_t value,
     556             :                                   PretenureFlag pretenure = NOT_TENURED);
     557             :   Handle<Object> NewNumberFromUint(uint32_t value,
     558             :                                    PretenureFlag pretenure = NOT_TENURED);
     559             :   inline Handle<Object> NewNumberFromSize(
     560             :       size_t value, PretenureFlag pretenure = NOT_TENURED);
     561             :   inline Handle<Object> NewNumberFromInt64(
     562             :       int64_t value, PretenureFlag pretenure = NOT_TENURED);
     563             :   inline Handle<HeapNumber> NewHeapNumber(
     564             :       double value, PretenureFlag pretenure = NOT_TENURED);
     565             :   inline Handle<HeapNumber> NewHeapNumberFromBits(
     566             :       uint64_t bits, PretenureFlag pretenure = NOT_TENURED);
     567             : 
     568             :   // Creates heap number object with not yet set value field.
     569             :   Handle<HeapNumber> NewHeapNumber(PretenureFlag pretenure = NOT_TENURED);
     570             : 
     571             :   Handle<MutableHeapNumber> NewMutableHeapNumber(
     572             :       PretenureFlag pretenure = NOT_TENURED);
     573             :   inline Handle<MutableHeapNumber> NewMutableHeapNumber(
     574             :       double value, PretenureFlag pretenure = NOT_TENURED);
     575             :   inline Handle<MutableHeapNumber> NewMutableHeapNumberFromBits(
     576             :       uint64_t bits, PretenureFlag pretenure = NOT_TENURED);
     577             :   inline Handle<MutableHeapNumber> NewMutableHeapNumberWithHoleNaN(
     578             :       PretenureFlag pretenure = NOT_TENURED);
     579             : 
     580             :   // Allocates a new BigInt with {length} digits. Only to be used by
     581             :   // MutableBigInt::New*.
     582             :   Handle<FreshlyAllocatedBigInt> NewBigInt(
     583             :       int length, PretenureFlag pretenure = NOT_TENURED);
     584             : 
     585             :   Handle<JSObject> NewArgumentsObject(Handle<JSFunction> callee, int length);
     586             : 
     587             :   // Allocates and initializes a new JavaScript object based on a
     588             :   // constructor.
     589             :   // JS objects are pretenured when allocated by the bootstrapper and
     590             :   // runtime.
     591             :   Handle<JSObject> NewJSObject(Handle<JSFunction> constructor,
     592             :                                PretenureFlag pretenure = NOT_TENURED);
     593             :   // JSObject without a prototype.
     594             :   Handle<JSObject> NewJSObjectWithNullProto(
     595             :       PretenureFlag pretenure = NOT_TENURED);
     596             : 
     597             :   // Global objects are pretenured and initialized based on a constructor.
     598             :   Handle<JSGlobalObject> NewJSGlobalObject(Handle<JSFunction> constructor);
     599             : 
     600             :   // Allocates and initializes a new JavaScript object based on a map.
     601             :   // Passing an allocation site means that a memento will be created that
     602             :   // points to the site.
     603             :   // JS objects are pretenured when allocated by the bootstrapper and
     604             :   // runtime.
     605             :   Handle<JSObject> NewJSObjectFromMap(
     606             :       Handle<Map> map, PretenureFlag pretenure = NOT_TENURED,
     607             :       Handle<AllocationSite> allocation_site = Handle<AllocationSite>::null());
     608             :   Handle<JSObject> NewSlowJSObjectFromMap(
     609             :       Handle<Map> map,
     610             :       int number_of_slow_properties = NameDictionary::kInitialCapacity,
     611             :       PretenureFlag pretenure = NOT_TENURED);
     612             :   // Allocates and initializes a new JavaScript object with the given
     613             :   // {prototype} and {properties}. The newly created object will be
     614             :   // in dictionary properties mode. The {elements} can either be the
     615             :   // empty fixed array, in which case the resulting object will have
     616             :   // fast elements, or a NumberDictionary, in which case the resulting
     617             :   // object will have dictionary elements.
     618             :   Handle<JSObject> NewSlowJSObjectWithPropertiesAndElements(
     619             :       Handle<Object> prototype, Handle<NameDictionary> properties,
     620             :       Handle<FixedArrayBase> elements, PretenureFlag pretenure = NOT_TENURED);
     621             : 
     622             :   // JS arrays are pretenured when allocated by the parser.
     623             : 
     624             :   // Create a JSArray with a specified length and elements initialized
     625             :   // according to the specified mode.
     626             :   Handle<JSArray> NewJSArray(
     627             :       ElementsKind elements_kind, int length, int capacity,
     628             :       ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS,
     629             :       PretenureFlag pretenure = NOT_TENURED);
     630             : 
     631     1300449 :   Handle<JSArray> NewJSArray(
     632             :       int capacity, ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
     633             :       PretenureFlag pretenure = NOT_TENURED) {
     634     1300449 :     if (capacity != 0) {
     635             :       elements_kind = GetHoleyElementsKind(elements_kind);
     636             :     }
     637             :     return NewJSArray(elements_kind, 0, capacity,
     638     1300449 :                       INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure);
     639             :   }
     640             : 
     641             :   // Create a JSArray with the given elements.
     642             :   Handle<JSArray> NewJSArrayWithElements(Handle<FixedArrayBase> elements,
     643             :                                          ElementsKind elements_kind, int length,
     644             :                                          PretenureFlag pretenure = NOT_TENURED);
     645             : 
     646             :   inline Handle<JSArray> NewJSArrayWithElements(
     647             :       Handle<FixedArrayBase> elements,
     648             :       ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
     649             :       PretenureFlag pretenure = NOT_TENURED);
     650             : 
     651             :   void NewJSArrayStorage(
     652             :       Handle<JSArray> array, int length, int capacity,
     653             :       ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS);
     654             : 
     655             :   Handle<JSWeakMap> NewJSWeakMap();
     656             : 
     657             :   Handle<JSGeneratorObject> NewJSGeneratorObject(Handle<JSFunction> function);
     658             : 
     659             :   Handle<JSModuleNamespace> NewJSModuleNamespace();
     660             : 
     661             :   Handle<Module> NewModule(Handle<SharedFunctionInfo> code);
     662             : 
     663             :   Handle<JSArrayBuffer> NewJSArrayBuffer(SharedFlag shared,
     664             :                                          PretenureFlag pretenure = NOT_TENURED);
     665             : 
     666             :   static void TypeAndSizeForElementsKind(ElementsKind kind,
     667             :                                          ExternalArrayType* array_type,
     668             :                                          size_t* element_size);
     669             : 
     670             :   Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type,
     671             :                                        PretenureFlag pretenure = NOT_TENURED);
     672             : 
     673             :   Handle<JSTypedArray> NewJSTypedArray(ElementsKind elements_kind,
     674             :                                        PretenureFlag pretenure = NOT_TENURED);
     675             : 
     676             :   // Creates a new JSTypedArray with the specified buffer.
     677             :   Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type,
     678             :                                        Handle<JSArrayBuffer> buffer,
     679             :                                        size_t byte_offset, size_t length,
     680             :                                        PretenureFlag pretenure = NOT_TENURED);
     681             : 
     682             :   // Creates a new on-heap JSTypedArray.
     683             :   Handle<JSTypedArray> NewJSTypedArray(ElementsKind elements_kind,
     684             :                                        size_t number_of_elements,
     685             :                                        PretenureFlag pretenure = NOT_TENURED);
     686             : 
     687             :   Handle<JSDataView> NewJSDataView(Handle<JSArrayBuffer> buffer,
     688             :                                    size_t byte_offset, size_t byte_length);
     689             : 
     690             :   Handle<JSIteratorResult> NewJSIteratorResult(Handle<Object> value, bool done);
     691             :   Handle<JSAsyncFromSyncIterator> NewJSAsyncFromSyncIterator(
     692             :       Handle<JSReceiver> sync_iterator, Handle<Object> next);
     693             : 
     694             :   Handle<JSMap> NewJSMap();
     695             :   Handle<JSSet> NewJSSet();
     696             : 
     697             :   // Allocates a bound function.
     698             :   MaybeHandle<JSBoundFunction> NewJSBoundFunction(
     699             :       Handle<JSReceiver> target_function, Handle<Object> bound_this,
     700             :       Vector<Handle<Object>> bound_args);
     701             : 
     702             :   // Allocates a Harmony proxy.
     703             :   Handle<JSProxy> NewJSProxy(Handle<JSReceiver> target,
     704             :                              Handle<JSReceiver> handler);
     705             : 
     706             :   // Reinitialize an JSGlobalProxy based on a constructor.  The object
     707             :   // must have the same size as objects allocated using the
     708             :   // constructor.  The object is reinitialized and behaves as an
     709             :   // object that has been freshly allocated using the constructor.
     710             :   void ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> global,
     711             :                                  Handle<JSFunction> constructor);
     712             : 
     713             :   Handle<JSGlobalProxy> NewUninitializedJSGlobalProxy(int size);
     714             : 
     715             :   // Creates a new JSFunction according to the given args. This is the function
     716             :   // you'll probably want to use when creating a JSFunction from the runtime.
     717             :   Handle<JSFunction> NewFunction(const NewFunctionArgs& args);
     718             : 
     719             :   // For testing only. Creates a sloppy function without code.
     720             :   Handle<JSFunction> NewFunctionForTest(Handle<String> name);
     721             : 
     722             :   // Function creation from SharedFunctionInfo.
     723             : 
     724             :   Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
     725             :       Handle<Map> initial_map, Handle<SharedFunctionInfo> function_info,
     726             :       Handle<Context> context, Handle<FeedbackCell> feedback_cell,
     727             :       PretenureFlag pretenure = TENURED);
     728             : 
     729             :   Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
     730             :       Handle<SharedFunctionInfo> function_info, Handle<Context> context,
     731             :       Handle<FeedbackCell> feedback_cell, PretenureFlag pretenure = TENURED);
     732             : 
     733             :   Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
     734             :       Handle<Map> initial_map, Handle<SharedFunctionInfo> function_info,
     735             :       Handle<Context> context, PretenureFlag pretenure = TENURED);
     736             : 
     737             :   Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
     738             :       Handle<SharedFunctionInfo> function_info, Handle<Context> context,
     739             :       PretenureFlag pretenure = TENURED);
     740             : 
     741             :   // The choke-point for JSFunction creation. Handles allocation and
     742             :   // initialization. All other utility methods call into this.
     743             :   Handle<JSFunction> NewFunction(Handle<Map> map,
     744             :                                  Handle<SharedFunctionInfo> info,
     745             :                                  Handle<Context> context,
     746             :                                  PretenureFlag pretenure = TENURED);
     747             : 
     748             :   // Create a serialized scope info.
     749             :   Handle<ScopeInfo> NewScopeInfo(int length);
     750             : 
     751             :   Handle<ModuleInfo> NewModuleInfo();
     752             : 
     753             :   Handle<PreparseData> NewPreparseData(int data_length, int children_length);
     754             : 
     755             :   Handle<UncompiledDataWithoutPreparseData>
     756             :   NewUncompiledDataWithoutPreparseData(Handle<String> inferred_name,
     757             :                                        int32_t start_position,
     758             :                                        int32_t end_position,
     759             :                                        int32_t function_literal_id);
     760             : 
     761             :   Handle<UncompiledDataWithPreparseData> NewUncompiledDataWithPreparseData(
     762             :       Handle<String> inferred_name, int32_t start_position,
     763             :       int32_t end_position, int32_t function_literal_id, Handle<PreparseData>);
     764             : 
     765             :   // Create an External object for V8's external API.
     766             :   Handle<JSObject> NewExternal(void* value);
     767             : 
     768             :   // Creates a new CodeDataContainer for a Code object.
     769             :   Handle<CodeDataContainer> NewCodeDataContainer(int flags);
     770             : 
     771             :   // Allocates a new code object (fully initialized). All header fields of the
     772             :   // returned object are immutable and the code object is write protected.
     773             :   // The reference to the Code object is stored in self_reference.
     774             :   // This allows generated code to reference its own Code object
     775             :   // by containing this handle.
     776             :   Handle<Code> NewCode(const CodeDesc& desc, Code::Kind kind,
     777             :                        Handle<Object> self_reference,
     778             :                        int32_t builtin_index = Builtins::kNoBuiltinId,
     779             :                        MaybeHandle<ByteArray> maybe_source_position_table =
     780             :                            MaybeHandle<ByteArray>(),
     781             :                        MaybeHandle<DeoptimizationData> maybe_deopt_data =
     782             :                            MaybeHandle<DeoptimizationData>(),
     783             :                        Movability movability = kMovable,
     784             :                        bool is_turbofanned = false, int stack_slots = 0,
     785             :                        int safepoint_table_offset = 0,
     786             :                        int handler_table_offset = 0);
     787             : 
     788             :   // Like NewCode, this function allocates a new code object (fully
     789             :   // initialized). It may return an empty handle if the allocation does not
     790             :   // succeed.
     791             :   V8_WARN_UNUSED_RESULT MaybeHandle<Code> TryNewCode(
     792             :       const CodeDesc& desc, Code::Kind kind, Handle<Object> self_reference,
     793             :       int32_t builtin_index = Builtins::kNoBuiltinId,
     794             :       MaybeHandle<ByteArray> maybe_source_position_table =
     795             :           MaybeHandle<ByteArray>(),
     796             :       MaybeHandle<DeoptimizationData> maybe_deopt_data =
     797             :           MaybeHandle<DeoptimizationData>(),
     798             :       Movability movability = kMovable, bool is_turbofanned = false,
     799             :       int stack_slots = 0, int safepoint_table_offset = 0,
     800             :       int handler_table_offset = 0);
     801             : 
     802             :   // Allocates a new code object and initializes it as the trampoline to the
     803             :   // given off-heap entry point.
     804             :   Handle<Code> NewOffHeapTrampolineFor(Handle<Code> code,
     805             :                                        Address off_heap_entry);
     806             : 
     807             :   Handle<Code> CopyCode(Handle<Code> code);
     808             : 
     809             :   Handle<BytecodeArray> CopyBytecodeArray(Handle<BytecodeArray>);
     810             : 
     811             :   // Interface for creating error objects.
     812             :   Handle<Object> NewError(Handle<JSFunction> constructor,
     813             :                           Handle<String> message);
     814             : 
     815             :   Handle<Object> NewInvalidStringLengthError();
     816             : 
     817             :   inline Handle<Object> NewURIError();
     818             : 
     819             :   Handle<Object> NewError(Handle<JSFunction> constructor,
     820             :                           MessageTemplate template_index,
     821             :                           Handle<Object> arg0 = Handle<Object>(),
     822             :                           Handle<Object> arg1 = Handle<Object>(),
     823             :                           Handle<Object> arg2 = Handle<Object>());
     824             : 
     825             : #define DECLARE_ERROR(NAME)                                        \
     826             :   Handle<Object> New##NAME(MessageTemplate template_index,         \
     827             :                            Handle<Object> arg0 = Handle<Object>(), \
     828             :                            Handle<Object> arg1 = Handle<Object>(), \
     829             :                            Handle<Object> arg2 = Handle<Object>());
     830             :   DECLARE_ERROR(Error)
     831             :   DECLARE_ERROR(EvalError)
     832             :   DECLARE_ERROR(RangeError)
     833             :   DECLARE_ERROR(ReferenceError)
     834             :   DECLARE_ERROR(SyntaxError)
     835             :   DECLARE_ERROR(TypeError)
     836             :   DECLARE_ERROR(WasmCompileError)
     837             :   DECLARE_ERROR(WasmLinkError)
     838             :   DECLARE_ERROR(WasmRuntimeError)
     839             : #undef DECLARE_ERROR
     840             : 
     841             :   Handle<String> NumberToString(Handle<Object> number, bool check_cache = true);
     842             :   Handle<String> NumberToString(Smi number, bool check_cache = true);
     843             : 
     844             :   inline Handle<String> Uint32ToString(uint32_t value, bool check_cache = true);
     845             : 
     846             : #define ROOT_ACCESSOR(Type, name, CamelName) inline Handle<Type> name();
     847             :   ROOT_LIST(ROOT_ACCESSOR)
     848             : #undef ROOT_ACCESSOR
     849             : 
     850             :   // Allocates a new SharedFunctionInfo object.
     851             :   Handle<SharedFunctionInfo> NewSharedFunctionInfoForApiFunction(
     852             :       MaybeHandle<String> maybe_name,
     853             :       Handle<FunctionTemplateInfo> function_template_info, FunctionKind kind);
     854             : 
     855             :   Handle<SharedFunctionInfo> NewSharedFunctionInfoForBuiltin(
     856             :       MaybeHandle<String> name, int builtin_index,
     857             :       FunctionKind kind = kNormalFunction);
     858             : 
     859             :   Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral(
     860             :       FunctionLiteral* literal, Handle<Script> script, bool is_toplevel);
     861             : 
     862             :   static bool IsFunctionModeWithPrototype(FunctionMode function_mode) {
     863        1554 :     return (function_mode & kWithPrototypeBits) != 0;
     864             :   }
     865             : 
     866             :   static bool IsFunctionModeWithWritablePrototype(FunctionMode function_mode) {
     867         888 :     return (function_mode & kWithWritablePrototypeBit) != 0;
     868             :   }
     869             : 
     870             :   static bool IsFunctionModeWithName(FunctionMode function_mode) {
     871        1554 :     return (function_mode & kWithNameBit) != 0;
     872             :   }
     873             : 
     874             :   static bool IsFunctionModeWithHomeObject(FunctionMode function_mode) {
     875         999 :     return (function_mode & kWithHomeObjectBit) != 0;
     876             :   }
     877             : 
     878             :   Handle<Map> CreateSloppyFunctionMap(
     879             :       FunctionMode function_mode, MaybeHandle<JSFunction> maybe_empty_function);
     880             : 
     881             :   Handle<Map> CreateStrictFunctionMap(FunctionMode function_mode,
     882             :                                       Handle<JSFunction> empty_function);
     883             : 
     884             :   Handle<Map> CreateClassFunctionMap(Handle<JSFunction> empty_function);
     885             : 
     886             :   // Allocates a new JSMessageObject object.
     887             :   Handle<JSMessageObject> NewJSMessageObject(
     888             :       MessageTemplate message, Handle<Object> argument, int start_position,
     889             :       int end_position, Handle<Script> script, Handle<Object> stack_frames);
     890             : 
     891             :   Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared);
     892             : 
     893             :   Handle<CoverageInfo> NewCoverageInfo(const ZoneVector<SourceRange>& slots);
     894             : 
     895             :   // Return a map for given number of properties using the map cache in the
     896             :   // native context.
     897             :   Handle<Map> ObjectLiteralMapFromCache(Handle<NativeContext> native_context,
     898             :                                         int number_of_properties);
     899             : 
     900             :   Handle<LoadHandler> NewLoadHandler(int data_count);
     901             :   Handle<StoreHandler> NewStoreHandler(int data_count);
     902             : 
     903             :   Handle<RegExpMatchInfo> NewRegExpMatchInfo();
     904             : 
     905             :   // Creates a new FixedArray that holds the data associated with the
     906             :   // atom regexp and stores it in the regexp.
     907             :   void SetRegExpAtomData(Handle<JSRegExp> regexp, JSRegExp::Type type,
     908             :                          Handle<String> source, JSRegExp::Flags flags,
     909             :                          Handle<Object> match_pattern);
     910             : 
     911             :   // Creates a new FixedArray that holds the data associated with the
     912             :   // irregexp regexp and stores it in the regexp.
     913             :   void SetRegExpIrregexpData(Handle<JSRegExp> regexp, JSRegExp::Type type,
     914             :                              Handle<String> source, JSRegExp::Flags flags,
     915             :                              int capture_count);
     916             : 
     917             :   // Returns the value for a known global constant (a property of the global
     918             :   // object which is neither configurable nor writable) like 'undefined'.
     919             :   // Returns a null handle when the given name is unknown.
     920             :   Handle<Object> GlobalConstantFor(Handle<Name> name);
     921             : 
     922             :   // Converts the given boolean condition to JavaScript boolean value.
     923             :   Handle<Object> ToBoolean(bool value);
     924             : 
     925             :   // Converts the given ToPrimitive hint to it's string representation.
     926             :   Handle<String> ToPrimitiveHintString(ToPrimitiveHint hint);
     927             : 
     928             :   Handle<JSPromise> NewJSPromiseWithoutHook(
     929             :       PretenureFlag pretenure = NOT_TENURED);
     930             :   Handle<JSPromise> NewJSPromise(PretenureFlag pretenure = NOT_TENURED);
     931             : 
     932             :   Handle<CallHandlerInfo> NewCallHandlerInfo(bool has_no_side_effect = false);
     933             : 
     934             :   HeapObject NewForTest(Handle<Map> map, PretenureFlag pretenure) {
     935           5 :     return New(map, pretenure);
     936             :   }
     937             : 
     938             :  private:
     939             :   Isolate* isolate() {
     940             :     // Downcast to the privately inherited sub-class using c-style casts to
     941             :     // avoid undefined behavior (as static_cast cannot cast across private
     942             :     // bases).
     943             :     // NOLINTNEXTLINE (google-readability-casting)
     944             :     return (Isolate*)this;  // NOLINT(readability/casting)
     945             :   }
     946             : 
     947             :   HeapObject AllocateRawWithImmortalMap(
     948             :       int size, PretenureFlag pretenure, Map map,
     949             :       AllocationAlignment alignment = kWordAligned);
     950             :   HeapObject AllocateRawWithAllocationSite(
     951             :       Handle<Map> map, PretenureFlag pretenure,
     952             :       Handle<AllocationSite> allocation_site);
     953             : 
     954             :   // Allocate memory for an uninitialized array (e.g., a FixedArray or similar).
     955             :   HeapObject AllocateRawArray(int size, PretenureFlag pretenure);
     956             :   HeapObject AllocateRawFixedArray(int length, PretenureFlag pretenure);
     957             :   HeapObject AllocateRawWeakArrayList(int length, PretenureFlag pretenure);
     958             :   Handle<FixedArray> NewFixedArrayWithFiller(RootIndex map_root_index,
     959             :                                              int length, Object filler,
     960             :                                              PretenureFlag pretenure);
     961             : 
     962             :   // Allocates new context with given map, sets length and initializes the
     963             :   // after-header part with uninitialized values and leaves the context header
     964             :   // uninitialized.
     965             :   Handle<Context> NewContext(RootIndex map_root_index, int size,
     966             :                              int variadic_part_length, PretenureFlag pretenure);
     967             : 
     968             :   template <typename T>
     969             :   Handle<T> AllocateSmallOrderedHashTable(Handle<Map> map, int capacity,
     970             :                                           PretenureFlag pretenure);
     971             : 
     972             :   // Creates a heap object based on the map. The fields of the heap object are
     973             :   // not initialized, it's the responsibility of the caller to do that.
     974             :   HeapObject New(Handle<Map> map, PretenureFlag pretenure);
     975             : 
     976             :   template <typename T>
     977             :   Handle<T> CopyArrayWithMap(Handle<T> src, Handle<Map> map);
     978             :   template <typename T>
     979             :   Handle<T> CopyArrayAndGrow(Handle<T> src, int grow_by,
     980             :                              PretenureFlag pretenure);
     981             : 
     982             :   template <bool is_one_byte, typename T>
     983             :   Handle<String> AllocateInternalizedStringImpl(T t, int chars,
     984             :                                                 uint32_t hash_field);
     985             : 
     986             :   Handle<SeqOneByteString> AllocateRawOneByteInternalizedString(
     987             :       int length, uint32_t hash_field);
     988             : 
     989             :   Handle<String> AllocateTwoByteInternalizedString(Vector<const uc16> str,
     990             :                                                    uint32_t hash_field);
     991             : 
     992             :   MaybeHandle<String> NewStringFromTwoByte(const uc16* string, int length,
     993             :                                            PretenureFlag pretenure);
     994             : 
     995             :   // Attempt to find the number in a small cache.  If we finds it, return
     996             :   // the string representation of the number.  Otherwise return undefined.
     997             :   Handle<Object> NumberToStringCacheGet(Object number, int hash);
     998             : 
     999             :   // Update the cache with a new number-string pair.
    1000             :   Handle<String> NumberToStringCacheSet(Handle<Object> number, int hash,
    1001             :                                         const char* string, bool check_cache);
    1002             : 
    1003             :   // Create a JSArray with no elements and no length.
    1004             :   Handle<JSArray> NewJSArray(ElementsKind elements_kind,
    1005             :                              PretenureFlag pretenure = NOT_TENURED);
    1006             : 
    1007             :   Handle<SharedFunctionInfo> NewSharedFunctionInfo(
    1008             :       MaybeHandle<String> name, MaybeHandle<HeapObject> maybe_function_data,
    1009             :       int maybe_builtin_index, FunctionKind kind = kNormalFunction);
    1010             : 
    1011             :   void InitializeAllocationMemento(AllocationMemento memento,
    1012             :                                    AllocationSite allocation_site);
    1013             : 
    1014             :   // Initializes a JSObject based on its map.
    1015             :   void InitializeJSObjectFromMap(Handle<JSObject> obj,
    1016             :                                  Handle<Object> properties, Handle<Map> map);
    1017             :   // Initializes JSObject body starting at given offset.
    1018             :   void InitializeJSObjectBody(Handle<JSObject> obj, Handle<Map> map,
    1019             :                               int start_offset);
    1020             : };
    1021             : 
    1022             : // Utility class to simplify argument handling around JSFunction creation.
    1023             : class NewFunctionArgs final {
    1024             :  public:
    1025             :   static NewFunctionArgs ForWasm(
    1026             :       Handle<String> name,
    1027             :       Handle<WasmExportedFunctionData> exported_function_data, Handle<Map> map);
    1028             :   static NewFunctionArgs ForBuiltin(Handle<String> name, Handle<Map> map,
    1029             :                                     int builtin_id);
    1030             :   static NewFunctionArgs ForFunctionWithoutCode(Handle<String> name,
    1031             :                                                 Handle<Map> map,
    1032             :                                                 LanguageMode language_mode);
    1033             :   static NewFunctionArgs ForBuiltinWithPrototype(
    1034             :       Handle<String> name, Handle<Object> prototype, InstanceType type,
    1035             :       int instance_size, int inobject_properties, int builtin_id,
    1036             :       MutableMode prototype_mutability);
    1037             :   static NewFunctionArgs ForBuiltinWithoutPrototype(Handle<String> name,
    1038             :                                                     int builtin_id,
    1039             :                                                     LanguageMode language_mode);
    1040             : 
    1041             :   Handle<Map> GetMap(Isolate* isolate) const;
    1042             : 
    1043             :  private:
    1044     2210973 :   NewFunctionArgs() = default;  // Use the static factory constructors.
    1045             : 
    1046             :   void SetShouldCreateAndSetInitialMap();
    1047             :   void SetShouldSetPrototype();
    1048             :   void SetShouldSetLanguageMode();
    1049             : 
    1050             :   // Sentinel value.
    1051             :   static const int kUninitialized = -1;
    1052             : 
    1053             :   Handle<String> name_;
    1054             :   MaybeHandle<Map> maybe_map_;
    1055             :   MaybeHandle<WasmExportedFunctionData> maybe_exported_function_data_;
    1056             : 
    1057             :   bool should_create_and_set_initial_map_ = false;
    1058             :   InstanceType type_;
    1059             :   int instance_size_ = kUninitialized;
    1060             :   int inobject_properties_ = kUninitialized;
    1061             : 
    1062             :   bool should_set_prototype_ = false;
    1063             :   MaybeHandle<Object> maybe_prototype_;
    1064             : 
    1065             :   bool should_set_language_mode_ = false;
    1066             :   LanguageMode language_mode_;
    1067             : 
    1068             :   int maybe_builtin_id_ = kUninitialized;
    1069             : 
    1070             :   MutableMode prototype_mutability_;
    1071             : 
    1072             :   friend class Factory;
    1073             : };
    1074             : 
    1075             : }  // namespace internal
    1076             : }  // namespace v8
    1077             : 
    1078             : #endif  // V8_HEAP_FACTORY_H_

Generated by: LCOV version 1.10