5#ifndef V8_COMPILER_HEAP_REFS_H_
6#define V8_COMPILER_HEAP_REFS_H_
26class FixedDoubleArray;
27class FunctionTemplateInfo;
29class InternalizedString;
35class ScriptContextTable;
39namespace interpreter {
50class CompilationDependencies;
54class PerIsolateCompilerCache;
55class PropertyAccessInfo;
84#define FOR_HOLE(Name, name, Root) k##Name,
100#define HEAP_BROKER_OBJECT_LIST_BASE(BACKGROUND_SERIALIZED, NEVER_SERIALIZED) \
102 BACKGROUND_SERIALIZED(JSArray) \
103 BACKGROUND_SERIALIZED(JSBoundFunction) \
104 BACKGROUND_SERIALIZED(JSDataView) \
105 BACKGROUND_SERIALIZED(JSFunction) \
106 BACKGROUND_SERIALIZED(JSGlobalObject) \
107 BACKGROUND_SERIALIZED(JSGlobalProxy) \
108 BACKGROUND_SERIALIZED(JSTypedArray) \
109 BACKGROUND_SERIALIZED(JSPrimitiveWrapper) \
111 NEVER_SERIALIZED(NativeContext) \
113 NEVER_SERIALIZED(ObjectBoilerplateDescription) \
114 BACKGROUND_SERIALIZED(ScriptContextTable) \
116 NEVER_SERIALIZED(InternalizedString) \
118 BACKGROUND_SERIALIZED(FixedArray) \
119 NEVER_SERIALIZED(FixedDoubleArray) \
121 NEVER_SERIALIZED(String) \
122 NEVER_SERIALIZED(Symbol) \
124 BACKGROUND_SERIALIZED(JSObject) \
126 NEVER_SERIALIZED(AccessorInfo) \
127 NEVER_SERIALIZED(AllocationSite) \
128 NEVER_SERIALIZED(ArrayBoilerplateDescription) \
129 BACKGROUND_SERIALIZED(BigInt) \
130 NEVER_SERIALIZED(BytecodeArray) \
131 NEVER_SERIALIZED(Cell) \
132 NEVER_SERIALIZED(Code) \
133 NEVER_SERIALIZED(Context) \
134 NEVER_SERIALIZED(DescriptorArray) \
135 NEVER_SERIALIZED(FeedbackCell) \
136 NEVER_SERIALIZED(FeedbackVector) \
137 BACKGROUND_SERIALIZED(FixedArrayBase) \
138 NEVER_SERIALIZED(FunctionTemplateInfo) \
139 NEVER_SERIALIZED(HeapNumber) \
140 BACKGROUND_SERIALIZED(JSReceiver) \
141 BACKGROUND_SERIALIZED(Map) \
142 NEVER_SERIALIZED(Name) \
143 BACKGROUND_SERIALIZED(PropertyCell) \
144 NEVER_SERIALIZED(RegExpBoilerplateDescription) \
145 NEVER_SERIALIZED(ScopeInfo) \
146 NEVER_SERIALIZED(SharedFunctionInfo) \
147 NEVER_SERIALIZED(SourceTextModule) \
148 NEVER_SERIALIZED(TemplateObjectDescription) \
150 BACKGROUND_SERIALIZED(HeapObject)
152#define HEAP_BROKER_OBJECT_LIST(V) HEAP_BROKER_OBJECT_LIST_BASE(V, V)
153#define IGNORE_CASE(...)
154#define HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(V) \
155 HEAP_BROKER_OBJECT_LIST_BASE(V, IGNORE_CASE)
157#define FORWARD_DECL(Name) class Name##Ref;
163struct is_ref :
public std::false_type {};
165#define DEFINE_IS_REF(Name) \
167 struct is_ref<Name##Ref> : public std::true_type {};
175#define FORWARD_DECL(Name) class Name##Data;
179#define BACKGROUND_SERIALIZED_REF_TRAITS(Name) \
181 struct ref_traits<Name> { \
182 using ref_type = Name##Ref; \
183 using data_type = Name##Data; \
184 static constexpr RefSerializationKind ref_serialization_kind = \
185 RefSerializationKind::kBackgroundSerialized; \
188#define NEVER_SERIALIZED_REF_TRAITS(Name) \
190 struct ref_traits<Name> { \
191 using ref_type = Name##Ref; \
192 using data_type = ObjectData; \
193 static constexpr RefSerializationKind ref_serialization_kind = \
194 RefSerializationKind::kNeverSerialized; \
199#undef NEVER_SERIALIZED_REF_TRAITS
200#undef BACKGROUND_SERIALIZED_REF_TRAITS
204 using ref_type = ObjectRef;
261#if V8_ENABLE_WEBASSEMBLY
278 static constexpr bool kAllJSReceiverRef =
279 (std::is_base_of_v<JSReceiverRef, typename ref_traits<T>::ref_type> &&
281 static constexpr bool kAllHeapObjectRef =
282 (std::is_base_of_v<JSReceiverRef, typename ref_traits<T>::ref_type> &&
287 std::conditional_t<kAllHeapObjectRef, HeapObjectRef, ObjectRef>>;
290 std::conditional_t<kAllHeapObjectRef, HeapObjectData, ObjectData>>;
303template <
typename TRef>
328 template <
typename SRef>
331 requires std::is_convertible_v<SRef*, TRef*>
332 :
data_(ref.data_) {}
335 template <
typename SRef>
338 requires std::is_convertible_v<SRef*, TRef*>
339 :
data_(ref.data_) {}
346 return TRef(
data_,
false);
365 template <
typename SRef>
380#define V(Name) using Optional##Name##Ref = OptionalRef<Name##Ref>;
387 explicit ObjectRef(
ObjectData* data,
bool check_type =
true) :
data_(data) {
393 bool equals(ObjectRef other)
const;
395 size_t hash_value()
const {
return base::hash_combine(
object().address()); }
400#define HEAP_IS_METHOD_DECL(Name) bool Is##Name() const;
402#undef HEAP_IS_METHOD_DECL
404#define HEAP_AS_METHOD_DECL(Name) Name##Ref As##Name() const;
406#undef HEAP_AS_METHOD_DECL
409 bool IsUndefined()
const;
411 bool IsTheHole()
const;
412 bool IsPropertyCellHole()
const;
413 bool IsHashTableHole()
const;
414 bool IsPromiseHole()
const;
420 bool should_access_heap()
const;
425 size_t operator()(ObjectRef ref)
const {
return ref.hash_value(); }
439 friend class StringData;
441 template <
typename TRef>
444 friend std::ostream&
operator<<(std::ostream& os, ObjectRef ref);
445 friend bool operator<(ObjectRef lhs, ObjectRef rhs);
446 template <
typename T,
typename Enable>
447 friend struct ::v8::internal::ZoneCompactSetTraits;
450inline bool operator==(ObjectRef lhs, ObjectRef rhs) {
return lhs.equals(rhs); }
453 return !lhs.equals(rhs);
457 return lhs.data_ < rhs.data_;
460inline size_t hash_value(ObjectRef ref) {
return ref.hash_value(); }
465template <
class K,
class V>
514#define DEFINE_REF_CONSTRUCTOR(Name, Base) \
515 explicit Name##Ref(ObjectData* data, bool check_type = true) \
516 : Base(data, false) { \
546 bool cached = Cache(
broker);
581 OptionalObjectRef GetOwnConstantElement(
599 OptionalObjectRef GetOwnFastConstantDataProperty(
608 std::optional<
Float64> GetOwnFastConstantDoubleProperty(
614 OptionalObjectRef GetOwnDictionaryProperty(
634 size_t byte_length() const;
672#ifdef V8_ENABLE_LEAPTIERING
699 double value() const;
700 uint64_t value_as_bits() const;
723#define BROKER_NATIVE_CONTEXT_FIELDS(V) \
724 V(JSFunction, array_function) \
725 V(JSFunction, bigint_function) \
726 V(JSFunction, boolean_function) \
727 V(JSFunction, function_prototype_apply) \
728 V(JSFunction, number_function) \
729 V(JSFunction, object_function) \
730 V(JSFunction, promise_function) \
731 V(JSFunction, promise_then) \
732 V(JSFunction, regexp_exec_function) \
733 V(JSFunction, regexp_function) \
734 V(JSFunction, string_function) \
735 V(JSFunction, symbol_function) \
736 V(JSGlobalObject, global_object) \
737 V(JSGlobalProxy, global_proxy_object) \
738 V(JSObject, initial_array_prototype) \
739 V(JSObject, promise_prototype) \
740 V(Map, async_function_object_map) \
741 V(Map, block_context_map) \
742 V(Map, bound_function_with_constructor_map) \
743 V(Map, bound_function_without_constructor_map) \
744 V(Map, catch_context_map) \
745 V(Map, eval_context_map) \
746 V(Map, fast_aliased_arguments_map) \
747 V(Map, function_context_map) \
748 V(Map, initial_array_iterator_map) \
749 V(Map, initial_string_iterator_map) \
750 V(Map, iterator_result_map) \
751 V(Map, js_array_holey_double_elements_map) \
752 V(Map, js_array_holey_elements_map) \
753 V(Map, js_array_holey_smi_elements_map) \
754 V(Map, js_array_packed_double_elements_map) \
755 V(Map, js_array_packed_elements_map) \
756 V(Map, js_array_packed_smi_elements_map) \
757 V(Map, map_key_iterator_map) \
758 V(Map, map_key_value_iterator_map) \
759 V(Map, map_value_iterator_map) \
761 V(Map, set_key_value_iterator_map) \
762 V(Map, set_value_iterator_map) \
763 V(Map, sloppy_arguments_map) \
764 V(Map, slow_object_with_null_prototype_map) \
765 V(Map, strict_arguments_map) \
766 V(Map, with_context_map) \
767 V(ScriptContextTable, script_context_table)
775#define DECL_ACCESSOR(type, name) type##Ref name(JSHeapBroker* broker) const;
779 MapRef GetFunctionMapFromIndex(JSHeapBroker*
broker,
int index)
const;
780 MapRef GetInitialJSArrayMap(JSHeapBroker*
broker, ElementsKind
kind)
const;
781 OptionalJSFunctionRef GetConstructorFunction(JSHeapBroker*
broker,
783 bool GlobalIsDetached(JSHeapBroker*
broker)
const;
792 bool IsUniqueName() const;
818 OptionalSharedFunctionInfoRef shared_function_info(
820#ifdef V8_ENABLE_LEAPTIERING
835 bool was_once_deoptimized() const;
851 bool PointsToLiteral() const;
857 bool CanInlineCall() const;
866 uint64_t AsUint64() const;
867 int64_t AsInt64(
bool* lossless) const;
876 int instance_size() const;
878 int GetInObjectProperties() const;
879 int GetInObjectPropertiesStartInWords() const;
880 int NumberOfOwnDescriptors() const;
881 int GetInObjectPropertyOffset(
int index) const;
882 int constructor_function_index() const;
883 int NextFreePropertyIndex() const;
884 int UnusedPropertyFields() const;
886 bool is_stable() const;
887 bool is_constructor() const;
888 bool has_prototype_slot() const;
889 bool is_access_check_needed() const;
890 bool is_deprecated() const;
891 bool CanBeDeprecated() const;
892 bool CanTransition() const;
893 bool IsInobjectSlackTrackingInProgress() const;
894 bool is_dictionary_map() const;
896 bool IsPrimitiveMap() const;
897 bool is_undetectable() const;
898 bool is_callable() const;
899 bool has_indexed_interceptor() const;
900 int construction_counter() const;
901 bool is_migration_target() const;
904 bool is_abandoned_prototype_map() const;
905 bool IsTwoByteStringMap() const;
906 bool IsThinStringMap() const;
907 bool IsStringWrapperMap() const;
911 bool CanInlineElementAccess() const;
917#define DEF_TESTER(Type, ...) bool Is##Type##Map() const;
921 bool IsBooleanMap(JSHeapBroker*
broker)
const;
923 HeapObjectRef GetBackPointer(JSHeapBroker*
broker)
const;
925 HeapObjectRef prototype(JSHeapBroker*
broker)
const;
927 bool PrototypesElementsDoNotHaveAccessorsOrThrow(
928 JSHeapBroker*
broker, ZoneVector<MapRef>* prototype_maps);
931 DescriptorArrayRef instance_descriptors(JSHeapBroker*
broker)
const;
932 MapRef FindFieldOwner(JSHeapBroker*
broker,
933 InternalIndex descriptor_index)
const;
934 PropertyDetails GetPropertyDetails(JSHeapBroker*
broker,
935 InternalIndex descriptor_index)
const;
936 NameRef GetPropertyKey(JSHeapBroker*
broker,
937 InternalIndex descriptor_index)
const;
938 FieldIndex GetFieldIndexFor(InternalIndex descriptor_index)
const;
939 OptionalObjectRef GetStrongValue(JSHeapBroker*
broker,
940 InternalIndex descriptor_number)
const;
942 MapRef FindRootMap(JSHeapBroker*
broker)
const;
943 ObjectRef GetConstructor(JSHeapBroker*
broker)
const;
948 CallOptimization::kHolderNotFound,
949 OptionalJSObjectRef
holder_ = std::nullopt)
950 : lookup(lookup_), holder(
holder_) {}
962 bool accept_any_receiver() const;
963 int16_t allowed_receiver_instance_type_range_start() const;
964 int16_t allowed_receiver_instance_type_range_end() const;
983 uint32_t length() const;
988 using HeapObjectRef::HeapObjectRef;
991 int constants_elements_length()
const;
1012 Float64 GetFromImmutableFixedDoubleArray(
int i) const;
1027 int register_count() const;
1029 uint16_t parameter_count_without_receiver() const;
1030 uint16_t max_arguments() const;
1031 interpreter::
Register incoming_new_target_or_generator_register() const;
1037 Address handler_table_address() const;
1038 int handler_table_size() const;
1054 int boilerplate_properties_count() const;
1074 uint32_t index) const;
1089 int ContextLength() const;
1090 bool HasContext() const;
1091 bool HasOuterScopeInfo() const;
1092 bool HasContextExtensionSlot() const;
1093 bool SomeContextHasExtension() const;
1094 bool ClassScopeHasPrivateBrand() const;
1095 bool SloppyEvalCanExtendVars() const;
1101#define BROKER_SFI_FIELDS(V) \
1102 V(int, internal_formal_parameter_count_with_receiver) \
1103 V(int, internal_formal_parameter_count_without_receiver) \
1104 V(bool, IsDontAdaptArguments) \
1105 V(bool, has_simple_parameters) \
1106 V(bool, has_duplicate_parameters) \
1107 V(int, function_map_index) \
1108 V(FunctionKind, kind) \
1109 V(LanguageMode, language_mode) \
1111 V(bool, HasBuiltinId) \
1112 V(bool, construct_as_builtin) \
1113 V(bool, HasBytecodeArray) \
1114 V(int, StartPosition) \
1115 V(bool, is_compiled) \
1116 V(bool, IsUserJavaScript) \
1117 V(bool, requires_instance_members_initializer)
1126 int context_header_size() const;
1127 int context_parameters_start() const;
1132 OptionalFunctionTemplateInfoRef function_template_info(
1136#define DECL_ACCESSOR(type, name) type name() const;
1141 return GetInlineability(
broker) == SharedFunctionInfo::kIsInlineable;
1154 uint32_t index) const;
1159 uint32_t length() const;
1165 bool IsSeqString() const;
1166 bool IsExternalString() const;
1168 bool IsContentAccessible() const;
1169 bool IsOneByteRepresentation() const;
1175 bool SupportedStringKind() const;
1191 bool is_on_heap() const;
1192 size_t length() const;
1193 size_t byte_length() const;
1195 void* data_ptr() const;
1258 unsigned GetInlinedBytecodeSize() const;
1268#undef DEFINE_REF_CONSTRUCTOR
1272 static_assert(sizeof(Name##Ref) == kSystemPointerSize); \
1273 static_assert(sizeof(OptionalName##Ref) == kSystemPointerSize); \
1275 static_assert(std::is_trivially_copyable_v<Name##Ref>); \
1276 static_assert(std::is_trivially_copyable_v<OptionalName##Ref>); \
1277 static_assert(std::is_trivially_destructible_v<Name##Ref>); \
1278 static_assert(std::is_trivially_destructible_v<OptionalName##Ref>);
1285template <
typename T>
1300template <
typename T>
1304 return std::any_of(maps.begin(), maps.end(),
1305 [](
MapRef map) { return map.IsHeapNumberMap(); });
1309 return std::any_of(maps.begin(), maps.end(),
1310 [](
MapRef map) { return map.IsHeapNumberMap(); });
uint8_t data_[MAX_STACK_LENGTH]
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
IndirectHandle< ArrayBoilerplateDescription > object() const
OptionalMapRef map_direct_read(JSHeapBroker *broker) const
HeapObjectType GetHeapObjectType(JSHeapBroker *broker) const
ElementsKind const elements_kind_
HoleType hole_type(JSHeapBroker *broker) const
OddballType oddball_type(JSHeapBroker *broker) const
bool is_undetectable() const
HoleType hole_type() const
OddballType oddball_type() const
ElementsKind elements_kind() const
InstanceType instance_type() const
HoleType const hole_type_
HeapObjectType(InstanceType instance_type, ElementsKind elements_kind, Flags flags, OddballType oddball_type, HoleType hole_type)
InstanceType const instance_type_
OddballType const oddball_type_
IndirectHandle< JSPrimitiveWrapper > object() const
ArrowOperatorHelper(TRef object)
ArrowOperatorHelper operator->() const
OptionalRef(ObjectData *data)
constexpr bool has_value() const
V8_INLINE OptionalRef(OptionalRef< SRef > ref)
OptionalRef(std::nullopt_t)
V8_INLINE OptionalRef(SRef ref)
size_t hash_value() const
bool equals(OptionalRef other) const
PropertyDetails property_details() const
ObjectRef value(JSHeapBroker *broker) const
bool IsInlineable(JSHeapBroker *broker) const
JSObjectRef const holder_
#define DEF_TESTER(Type,...)
#define BACKGROUND_SERIALIZED_REF_TRAITS(Name)
#define HEAP_BROKER_OBJECT_LIST_BASE(BACKGROUND_SERIALIZED, NEVER_SERIALIZED)
#define HEAP_IS_METHOD_DECL(Name)
#define DECL_ACCESSOR(type, name)
#define NEVER_SERIALIZED_REF_TRAITS(Name)
#define DEFINE_IS_REF(Name)
#define HEAP_BROKER_OBJECT_LIST(V)
#define FORWARD_DECL(Name)
#define HEAP_AS_METHOD_DECL(Name)
#define HEAP_BROKER_BACKGROUND_SERIALIZED_OBJECT_LIST(V)
#define BROKER_SFI_FIELDS(V)
#define BROKER_NATIVE_CONTEXT_FIELDS(V)
#define DEFINE_REF_CONSTRUCTOR(Name, Base)
#define INSTANCE_TYPE_CHECKERS(V)
V8_INLINE size_t hash_value(unsigned int v)
template const Signature< wasm::ValueType > bool
bool operator<(const CaseInfoT &l, const CaseInfoT &r)
bool IsAnyStore(AccessMode mode)
size_t hash_value(const BranchParameters &p)
bool operator!=(DeoptimizeParameters lhs, DeoptimizeParameters rhs)
bool operator==(const BranchParameters &lhs, const BranchParameters &rhs)
FOR_HOLE(Name, name, Root)
bool IsDefiningStore(AccessMode mode)
bool AnyMapIsHeapNumber(const ZoneRefSet< Map > &maps)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
wasm::WasmModule WasmModule
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
bool IsNullOrUndefined(Tagged< Object > obj, Isolate *isolate)
V8_INLINE constexpr bool operator<(Builtin a, Builtin b)
kInstanceDescriptorsOffset kTransitionsOrPrototypeInfoOffset IsNull(value)||IsJSProxy(value)||IsWasmObject(value)||(IsJSObject(value) &&(HeapLayout
std::ostream & operator<<(std::ostream &os, const Operation &operation)
#define CHECK_NOT_NULL(val)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define V8_EXPORT_PRIVATE
static data_type * HandleToPointer(handle_type handle)
static handle_type PointerToHandle(data_type *ptr)
HolderLookupResult(CallOptimization::HolderLookup lookup_=CallOptimization::kHolderNotFound, OptionalJSObjectRef holder_=std::nullopt)
OptionalJSObjectRef holder
CallOptimization::HolderLookup lookup
std::conditional_t< kAllJSReceiverRef, JSReceiverData, std::conditional_t< kAllHeapObjectRef, HeapObjectData, ObjectData > > data_type
std::conditional_t< kAllJSReceiverRef, JSReceiverRef, std::conditional_t< kAllHeapObjectRef, HeapObjectRef, ObjectRef > > ref_type
#define V8_WARN_UNUSED_RESULT