5 #ifndef V8_HEAP_FACTORY_H_ 6 #define V8_HEAP_FACTORY_H_ 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-buffer.h" 20 #include "src/objects/js-array.h" 21 #include "src/objects/js-regexp.h" 22 #include "src/objects/ordered-hash-table.h" 23 #include "src/objects/string.h" 29 class AliasedArgumentsEntry;
30 class ObjectBoilerplateDescription;
35 class CallHandlerInfo;
37 class EmbedderDataArray;
38 class ArrayBoilerplateDescription;
42 class FreshlyAllocatedBigInt;
44 class JSGeneratorObject;
47 class JSModuleNamespace;
56 class NewFunctionArgs;
57 class PreParsedScopeData;
58 class PromiseResolveThenableJobTask;
59 class RegExpMatchInfo;
60 class ScriptContextTable;
63 class TemplateObjectDescription;
64 class UncompiledDataWithoutPreParsedScope;
65 class UncompiledDataWithPreParsedScope;
66 class WasmExportedFunctionData;
67 class WeakFactoryCleanupJobTask;
73 kWithNameBit = 1 << 0,
74 kWithHomeObjectBit = 1 << 1,
75 kWithWritablePrototypeBit = 1 << 2,
76 kWithReadonlyPrototypeBit = 1 << 3,
77 kWithPrototypeBits = kWithWritablePrototypeBit | kWithReadonlyPrototypeBit,
80 FUNCTION_WITHOUT_PROTOTYPE = 0,
81 METHOD_WITH_NAME = kWithNameBit,
82 METHOD_WITH_HOME_OBJECT = kWithHomeObjectBit,
83 METHOD_WITH_NAME_AND_HOME_OBJECT = kWithNameBit | kWithHomeObjectBit,
86 FUNCTION_WITH_WRITEABLE_PROTOTYPE = kWithWritablePrototypeBit,
87 FUNCTION_WITH_NAME_AND_WRITEABLE_PROTOTYPE =
88 kWithWritablePrototypeBit | kWithNameBit,
89 FUNCTION_WITH_HOME_OBJECT_AND_WRITEABLE_PROTOTYPE =
90 kWithWritablePrototypeBit | kWithHomeObjectBit,
91 FUNCTION_WITH_NAME_AND_HOME_OBJECT_AND_WRITEABLE_PROTOTYPE =
92 kWithWritablePrototypeBit | kWithNameBit | kWithHomeObjectBit,
95 FUNCTION_WITH_READONLY_PROTOTYPE = kWithReadonlyPrototypeBit,
96 FUNCTION_WITH_NAME_AND_READONLY_PROTOTYPE =
97 kWithReadonlyPrototypeBit | kWithNameBit,
106 PretenureFlag pretenure = TENURED_READ_ONLY);
109 Handle<Oddball> NewSelfReferenceMarker(PretenureFlag pretenure = TENURED);
113 template <
typename T = FixedArray>
114 Handle<T> NewFixedArrayWithMap(RootIndex map_root_index,
int length,
115 PretenureFlag pretenure = NOT_TENURED);
119 template <
typename T = WeakFixedArray>
120 Handle<T> NewWeakFixedArrayWithMap(RootIndex map_root_index,
int length,
121 PretenureFlag pretenure = NOT_TENURED);
125 PretenureFlag pretenure = NOT_TENURED);
130 int length, PretenureFlag pretenure = NOT_TENURED);
134 PretenureFlag pretenure = NOT_TENURED);
140 V8_WARN_UNUSED_RESULT
142 int length, PretenureFlag pretenure = NOT_TENURED);
146 int length, PretenureFlag pretenure = NOT_TENURED);
150 int length, PretenureFlag pretenure = NOT_TENURED);
159 int length, PretenureFlag pretenure = NOT_TENURED);
164 int boilerplate,
int all_properties,
int index_keys,
bool has_seen_proto);
170 int length, PretenureFlag pretenure = NOT_TENURED);
174 int size, PretenureFlag pretenure = NOT_TENURED);
178 PretenureFlag tenure = TENURED);
181 PretenureFlag pretenure = NOT_TENURED);
188 int capacity = SmallOrderedHashSet::kMinCapacity,
189 PretenureFlag pretenure = NOT_TENURED);
191 int capacity = SmallOrderedHashMap::kMinCapacity,
192 PretenureFlag pretenure = NOT_TENURED);
194 int capacity = SmallOrderedHashMap::kMinCapacity,
195 PretenureFlag pretenure = NOT_TENURED);
206 PretenureFlag pretenure);
227 return InternalizeUtf8String(CStrVector(str));
236 template <
class StringTableKey>
269 const char (&str)[N], PretenureFlag pretenure = NOT_TENURED) {
270 DCHECK(N == StrLength(str) + 1);
271 return NewStringFromOneByte(STATIC_CHAR_VECTOR(str), pretenure)
276 const char* str, PretenureFlag pretenure = NOT_TENURED) {
277 return NewStringFromOneByte(OneByteVector(str), pretenure)
288 PretenureFlag pretenure = NOT_TENURED);
323 template <
class StringClass>
330 int length, PretenureFlag pretenure = NOT_TENURED);
332 int length, PretenureFlag pretenure = NOT_TENURED);
344 int length,
bool one_byte);
348 Handle<String> NewSurrogatePairString(uint16_t lead, uint16_t trail);
372 Handle<Symbol> NewPrivateSymbol(PretenureFlag pretenure = TENURED);
423 PretenureFlag pretenure = NOT_TENURED);
426 int aliased_context_slot);
431 PretenureFlag tenure = TENURED);
433 PretenureFlag tenure = TENURED);
440 NewSourcePositionTableWithFrameCache(
457 PretenureFlag pretenure = NOT_TENURED);
460 PretenureFlag pretenure = NOT_TENURED);
463 int frame_size,
int parameter_count,
467 int length, ExternalArrayType array_type,
void* external_pointer,
468 PretenureFlag pretenure = NOT_TENURED);
471 size_t length,
size_t byte_length, ExternalArrayType array_type,
472 bool initialize, PretenureFlag pretenure = NOT_TENURED);
477 PretenureFlag pretenure = TENURED);
494 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
495 int inobject_properties = 0);
498 Map InitializeMap(
Map map, InstanceType
type,
int instance_size,
499 ElementsKind elements_kind,
int inobject_properties);
504 AllocationSpace space);
521 PretenureFlag pretenure = NOT_TENURED);
525 PretenureFlag pretenure = NOT_TENURED);
529 PretenureFlag pretenure = NOT_TENURED);
533 PretenureFlag pretenure = NOT_TENURED);
536 PretenureFlag pretenure = NOT_TENURED);
550 Handle<Object> NewNumber(
double value, PretenureFlag pretenure = NOT_TENURED);
553 PretenureFlag pretenure = NOT_TENURED);
555 PretenureFlag pretenure = NOT_TENURED);
557 size_t value, PretenureFlag pretenure = NOT_TENURED);
559 int64_t value, PretenureFlag pretenure = NOT_TENURED);
561 double value, PretenureFlag pretenure = NOT_TENURED);
563 uint64_t bits, PretenureFlag pretenure = NOT_TENURED);
569 PretenureFlag pretenure = NOT_TENURED);
571 double value, PretenureFlag pretenure = NOT_TENURED);
573 uint64_t bits, PretenureFlag pretenure = NOT_TENURED);
575 PretenureFlag pretenure = NOT_TENURED);
580 int length, PretenureFlag pretenure = NOT_TENURED);
589 PretenureFlag pretenure = NOT_TENURED);
592 PretenureFlag pretenure = NOT_TENURED);
603 Handle<Map> map, PretenureFlag pretenure = NOT_TENURED,
607 int number_of_slow_properties = NameDictionary::kInitialCapacity,
608 PretenureFlag pretenure = NOT_TENURED);
624 ElementsKind elements_kind,
int length,
int capacity,
625 ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS,
626 PretenureFlag pretenure = NOT_TENURED);
629 int capacity, ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
630 PretenureFlag pretenure = NOT_TENURED) {
632 elements_kind = GetHoleyElementsKind(elements_kind);
634 return NewJSArray(elements_kind, 0, capacity,
635 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure);
640 ElementsKind elements_kind,
int length,
641 PretenureFlag pretenure = NOT_TENURED);
645 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
646 PretenureFlag pretenure = NOT_TENURED);
648 void NewJSArrayStorage(
650 ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS);
661 SharedFlag shared = SharedFlag::kNotShared,
662 PretenureFlag pretenure = NOT_TENURED);
664 static void TypeAndSizeForElementsKind(ElementsKind kind,
665 ExternalArrayType* array_type,
666 size_t* element_size);
669 PretenureFlag pretenure = NOT_TENURED);
672 PretenureFlag pretenure = NOT_TENURED);
677 size_t byte_offset,
size_t length,
678 PretenureFlag pretenure = NOT_TENURED);
682 size_t number_of_elements,
683 PretenureFlag pretenure = NOT_TENURED);
686 size_t byte_offset,
size_t byte_length);
725 PretenureFlag pretenure = TENURED);
737 PretenureFlag pretenure = TENURED);
744 PretenureFlag pretenure = TENURED);
754 NewUncompiledDataWithoutPreParsedScope(
Handle<String> inferred_name,
755 int32_t start_position,
756 int32_t end_position,
757 int32_t function_literal_id);
761 int32_t end_position, int32_t function_literal_id,
777 int32_t builtin_index = Builtins::kNoBuiltinId,
782 Movability movability = kMovable,
uint32_t stub_key = 0,
783 bool is_turbofanned =
false,
int stack_slots = 0,
784 int safepoint_table_offset = 0,
785 int handler_table_offset = 0);
792 int32_t builtin_index = Builtins::kNoBuiltinId,
797 Movability movability = kMovable,
uint32_t stub_key = 0,
798 bool is_turbofanned =
false,
int stack_slots = 0,
799 int safepoint_table_offset = 0,
int handler_table_offset = 0);
819 MessageTemplate template_index,
824 #define DECLARE_ERROR(NAME) \ 825 Handle<Object> New##NAME(MessageTemplate template_index, \ 826 Handle<Object> arg0 = Handle<Object>(), \ 827 Handle<Object> arg1 = Handle<Object>(), \ 828 Handle<Object> arg2 = Handle<Object>()); 830 DECLARE_ERROR(EvalError)
831 DECLARE_ERROR(RangeError)
832 DECLARE_ERROR(ReferenceError)
833 DECLARE_ERROR(SyntaxError)
834 DECLARE_ERROR(TypeError)
835 DECLARE_ERROR(WasmCompileError)
836 DECLARE_ERROR(WasmLinkError)
837 DECLARE_ERROR(WasmRuntimeError)
846 #define ROOT_ACCESSOR(Type, name, CamelName) \ 847 inline Handle<std::remove_pointer<Type>::type> name(); 848 ROOT_LIST(ROOT_ACCESSOR)
858 FunctionKind kind = kNormalFunction);
863 static bool IsFunctionModeWithPrototype(FunctionMode function_mode) {
864 return (function_mode & kWithPrototypeBits) != 0;
867 static bool IsFunctionModeWithWritablePrototype(FunctionMode function_mode) {
868 return (function_mode & kWithWritablePrototypeBit) != 0;
871 static bool IsFunctionModeWithName(FunctionMode function_mode) {
872 return (function_mode & kWithNameBit) != 0;
875 static bool IsFunctionModeWithHomeObject(FunctionMode function_mode) {
876 return (function_mode & kWithHomeObjectBit) != 0;
882 Handle<Map> CreateStrictFunctionMap(FunctionMode function_mode,
889 MessageTemplate message,
Handle<Object> argument,
int start_position,
899 int number_of_properties);
930 PretenureFlag pretenure = NOT_TENURED);
936 return New(map, pretenure);
949 int size, PretenureFlag pretenure,
Map map,
950 AllocationAlignment alignment = kWordAligned);
956 HeapObject* AllocateRawArray(
int size, PretenureFlag pretenure);
957 HeapObject* AllocateRawFixedArray(
int length, PretenureFlag pretenure);
958 HeapObject* AllocateRawWeakArrayList(
int length, PretenureFlag pretenure);
960 int length,
Object* filler,
961 PretenureFlag pretenure);
967 int variadic_part_length, PretenureFlag pretenure);
969 template <
typename T>
971 PretenureFlag pretenure);
977 template <
typename T>
979 template <
typename T>
981 PretenureFlag pretenure);
983 template <
bool is_one_byte,
typename T>
994 PretenureFlag pretenure);
1002 const char*
string,
bool check_cache);
1006 PretenureFlag pretenure = NOT_TENURED);
1010 int maybe_builtin_index, FunctionKind kind = kNormalFunction);
1033 LanguageMode language_mode);
1036 int instance_size,
int inobject_properties,
int builtin_id,
1037 MutableMode prototype_mutability);
1040 LanguageMode language_mode);
1047 void SetShouldCreateAndSetInitialMap();
1048 void SetShouldSetPrototype();
1049 void SetShouldSetLanguageMode();
1052 static const int kUninitialized = -1;
1058 bool should_create_and_set_initial_map_ =
false;
1060 int instance_size_ = kUninitialized;
1061 int inobject_properties_ = kUninitialized;
1063 bool should_set_prototype_ =
false;
1066 bool should_set_language_mode_ =
false;
1067 LanguageMode language_mode_;
1069 int maybe_builtin_id_ = kUninitialized;
1071 MutableMode prototype_mutability_;
1079 #endif // V8_HEAP_FACTORY_H_