24#ifndef RUNTIME_VM_COMPILER_BACKEND_SLOT_H_
25#define RUNTIME_VM_COMPILER_BACKEND_SLOT_H_
27#if defined(DART_PRECOMPILED_RUNTIME)
28#error "AOT runtime should not use compiler sources (including header files)"
54#define NULLABLE_TAGGED_NATIVE_DART_SLOTS_LIST(V) \
55 V(Array, UntaggedArray, type_arguments, TypeArguments, FINAL) \
56 V(Finalizer, UntaggedFinalizer, type_arguments, TypeArguments, FINAL) \
57 V(FinalizerBase, UntaggedFinalizerBase, all_entries, Set, VAR) \
58 V(FinalizerBase, UntaggedFinalizerBase, detachments, Dynamic, VAR) \
59 V(FinalizerBase, UntaggedFinalizer, entries_collected, FinalizerEntry, VAR) \
60 V(FinalizerEntry, UntaggedFinalizerEntry, value, Dynamic, WEAK) \
61 V(FinalizerEntry, UntaggedFinalizerEntry, detach, Dynamic, WEAK) \
62 V(FinalizerEntry, UntaggedFinalizerEntry, token, Dynamic, VAR) \
63 V(FinalizerEntry, UntaggedFinalizerEntry, finalizer, FinalizerBase, WEAK) \
64 V(FinalizerEntry, UntaggedFinalizerEntry, next, FinalizerEntry, VAR) \
65 V(Function, UntaggedFunction, signature, FunctionType, FINAL) \
66 V(Context, UntaggedContext, parent, Context, FINAL) \
67 V(Closure, UntaggedClosure, instantiator_type_arguments, TypeArguments, \
69 V(Closure, UntaggedClosure, delayed_type_arguments, TypeArguments, FINAL) \
70 V(Closure, UntaggedClosure, function_type_arguments, TypeArguments, FINAL) \
71 V(FunctionType, UntaggedFunctionType, type_parameters, TypeParameters, \
73 V(ReceivePort, UntaggedReceivePort, send_port, SendPort, FINAL) \
74 V(ReceivePort, UntaggedReceivePort, handler, Closure, VAR) \
75 V(ImmutableLinkedHashBase, UntaggedLinkedHashBase, index, \
76 TypedDataUint32Array, VAR) \
77 V(Instance, UntaggedInstance, native_fields_array, Dynamic, VAR) \
78 V(SuspendState, UntaggedSuspendState, function_data, Dynamic, VAR) \
79 V(SuspendState, UntaggedSuspendState, then_callback, Closure, VAR) \
80 V(SuspendState, UntaggedSuspendState, error_callback, Closure, VAR) \
81 V(TypeParameters, UntaggedTypeParameters, flags, Array, FINAL) \
82 V(TypeParameters, UntaggedTypeParameters, bounds, TypeArguments, FINAL) \
83 V(TypeParameters, UntaggedTypeParameters, defaults, TypeArguments, FINAL) \
84 V(WeakProperty, UntaggedWeakProperty, key, Dynamic, WEAK) \
85 V(WeakProperty, UntaggedWeakProperty, value, Dynamic, WEAK) \
86 V(WeakReference, UntaggedWeakReference, target, Dynamic, WEAK) \
87 V(WeakReference, UntaggedWeakReference, type_arguments, TypeArguments, FINAL)
102#define NONNULLABLE_INT_TAGGED_NATIVE_DART_SLOTS_LIST(V) \
103 V(Array, UntaggedArray, length, Smi, FINAL) \
104 V(Closure, UntaggedClosure, hash, Smi, VAR) \
105 V(GrowableObjectArray, UntaggedGrowableObjectArray, length, Smi, VAR) \
106 V(TypedDataBase, UntaggedTypedDataBase, length, Smi, FINAL) \
107 V(TypedDataView, UntaggedTypedDataView, offset_in_bytes, Smi, FINAL) \
108 V(String, UntaggedString, length, Smi, FINAL) \
109 V(LinkedHashBase, UntaggedLinkedHashBase, hash_mask, Smi, VAR) \
110 V(LinkedHashBase, UntaggedLinkedHashBase, used_data, Smi, VAR) \
111 V(LinkedHashBase, UntaggedLinkedHashBase, deleted_keys, Smi, VAR) \
112 V(ArgumentsDescriptor, UntaggedArray, type_args_len, Smi, FINAL) \
113 V(ArgumentsDescriptor, UntaggedArray, positional_count, Smi, FINAL) \
114 V(ArgumentsDescriptor, UntaggedArray, count, Smi, FINAL) \
115 V(ArgumentsDescriptor, UntaggedArray, size, Smi, FINAL) \
116 V(Record, UntaggedRecord, shape, Smi, FINAL) \
117 V(TypeArguments, UntaggedTypeArguments, hash, Smi, VAR) \
118 V(TypeArguments, UntaggedTypeArguments, length, Smi, FINAL) \
119 V(AbstractType, UntaggedTypeArguments, hash, Smi, VAR)
134#define NONNULLABLE_NONINT_TAGGED_NATIVE_DART_SLOTS_LIST(V) \
135 V(Closure, UntaggedClosure, function, Function, FINAL) \
136 V(Closure, UntaggedClosure, context, Dynamic, FINAL) \
137 V(Finalizer, UntaggedFinalizer, callback, Closure, FINAL) \
138 V(NativeFinalizer, UntaggedFinalizer, callback, Pointer, FINAL) \
139 V(Function, UntaggedFunction, data, Dynamic, FINAL) \
140 V(FunctionType, UntaggedFunctionType, named_parameter_names, Array, FINAL) \
141 V(FunctionType, UntaggedFunctionType, parameter_types, Array, FINAL) \
142 V(GrowableObjectArray, UntaggedGrowableObjectArray, data, Array, VAR) \
143 V(TypedDataView, UntaggedTypedDataView, typed_data, Dynamic, FINAL) \
144 V(LinkedHashBase, UntaggedLinkedHashBase, index, TypedDataUint32Array, VAR) \
145 V(LinkedHashBase, UntaggedLinkedHashBase, data, Array, VAR) \
146 V(ImmutableLinkedHashBase, UntaggedLinkedHashBase, data, ImmutableArray, \
148 V(TypeParameters, UntaggedTypeParameters, names, Array, FINAL) \
149 V(UnhandledException, UntaggedUnhandledException, exception, Dynamic, FINAL) \
150 V(UnhandledException, UntaggedUnhandledException, stacktrace, Dynamic, FINAL)
170#define UNBOXED_NATIVE_DART_SLOTS_LIST(V) \
171 V(AbstractType, UntaggedAbstractType, flags, Uint32, FINAL) \
172 V(ClosureData, UntaggedClosureData, packed_fields, Uint32, FINAL) \
173 V(FinalizerEntry, UntaggedFinalizerEntry, external_size, IntPtr, VAR) \
174 V(Function, UntaggedFunction, kind_tag, Uint32, FINAL) \
175 V(FunctionType, UntaggedFunctionType, packed_parameter_counts, Uint32, \
177 V(FunctionType, UntaggedFunctionType, packed_type_parameter_counts, Uint16, \
179 V(SubtypeTestCache, UntaggedSubtypeTestCache, num_inputs, Uint32, FINAL)
183#if defined(DART_PRECOMPILER) && !defined(TARGET_ARCH_IA32)
184#define AOT_ONLY_UNTAGGED_NATIVE_DART_SLOTS_LIST(V) \
185 V(Closure, UntaggedClosure, entry_point, false, FINAL)
187#define AOT_ONLY_UNTAGGED_NATIVE_DART_SLOTS_LIST(V)
209#define UNTAGGED_NATIVE_DART_SLOTS_LIST(V) \
210 AOT_ONLY_UNTAGGED_NATIVE_DART_SLOTS_LIST(V) \
211 V(Function, UntaggedFunction, entry_point, false, FINAL) \
212 V(FinalizerBase, UntaggedFinalizerBase, isolate, false, VAR) \
213 V(PointerBase, UntaggedPointerBase, data, true, VAR)
230#define NULLABLE_TAGGED_NATIVE_NONDART_SLOTS_LIST(V) \
231 V(Isolate, _, finalizers, GrowableObjectArray, VAR) \
232 V(LocalHandle, _, ptr, Dynamic, VAR) \
233 V(ObjectStore, _, record_field_names, Array, VAR) \
234 V(PersistentHandle, _, ptr, Dynamic, VAR)
253#define UNBOXED_NATIVE_NONDART_SLOTS_LIST(V) \
254 V(StreamInfo, _, enabled, IntPtr, VAR)
279#define UNTAGGED_NATIVE_NONDART_SLOTS_LIST(V) \
280 V(IsolateGroup, _, object_store, false, FINAL) \
281 V(Thread, _, api_top_scope, false, VAR) \
282 V(Thread, _, isolate, false, FINAL) \
283 V(Thread, _, isolate_group, false, FINAL) \
284 V(Thread, _, service_extension_stream, false, FINAL)
289#define CHECK_NATIVE_NONDART_SLOT(__, ___, ____, gc_may_move, _____) \
290 static_assert(!gc_may_move);
292#undef CHECK_NATIVE_NONDART_SLOT
297#define UNBOXED_NATIVE_SLOTS_LIST(V) \
298 UNBOXED_NATIVE_DART_SLOTS_LIST(V) \
299 UNBOXED_NATIVE_NONDART_SLOTS_LIST(V)
304#define UNTAGGED_NATIVE_SLOTS_LIST(V) \
305 UNTAGGED_NATIVE_DART_SLOTS_LIST(V) \
306 UNTAGGED_NATIVE_NONDART_SLOTS_LIST(V)
311#define NOT_TAGGED_NATIVE_SLOTS_LIST(V) \
312 UNBOXED_NATIVE_SLOTS_LIST(V) \
313 UNTAGGED_NATIVE_SLOTS_LIST(V)
318#define TAGGED_INT_NATIVE_SLOTS_LIST(V) \
319 NONNULLABLE_INT_TAGGED_NATIVE_DART_SLOTS_LIST(V)
326#define TAGGED_NONINT_NATIVE_SLOTS_LIST(V) \
327 NULLABLE_TAGGED_NATIVE_DART_SLOTS_LIST(V) \
328 NONNULLABLE_NONINT_TAGGED_NATIVE_DART_SLOTS_LIST(V) \
329 NULLABLE_TAGGED_NATIVE_NONDART_SLOTS_LIST(V)
335#define NOT_INT_NATIVE_SLOTS_LIST(V) \
336 TAGGED_NONINT_NATIVE_SLOTS_LIST(V) \
337 UNTAGGED_NATIVE_SLOTS_LIST(V)
343#define TAGGED_NATIVE_DART_SLOTS_LIST(V) \
344 NULLABLE_TAGGED_NATIVE_DART_SLOTS_LIST(V) \
345 NONNULLABLE_INT_TAGGED_NATIVE_DART_SLOTS_LIST(V) \
346 NONNULLABLE_NONINT_TAGGED_NATIVE_DART_SLOTS_LIST(V)
352#define NOT_TAGGED_NATIVE_DART_SLOTS_LIST(V) \
353 NULLABLE_TAGGED_NATIVE_NONDART_SLOTS_LIST(V) \
354 NOT_TAGGED_NATIVE_SLOTS_LIST(V)
359#define TAGGED_NATIVE_SLOTS_LIST(V) \
360 TAGGED_INT_NATIVE_SLOTS_LIST(V) \
361 TAGGED_NONINT_NATIVE_SLOTS_LIST(V)
366#define NATIVE_SLOTS_LIST(V) \
367 TAGGED_NATIVE_SLOTS_LIST(V) \
368 NOT_TAGGED_NATIVE_SLOTS_LIST(V)
378#define CHECK_TAGGED_NATIVE_SLOT(__, ___, ____, field_type, _____) \
379 static_assert(k##field_type##Cid != kObjectCid); \
380 static_assert(k##field_type##Cid != kInstanceCid); \
381 static_assert(k##field_type##Cid != kIntegerCid); \
382 static_assert(k##field_type##Cid != kStringCid); \
383 static_assert(k##field_type##Cid != kAbstractTypeCid);
385#undef CHECK_NULLABLE_TAGGED_NATIVE_SLOT
394#define CHECK_INT_NATIVE_SLOT(__, ___, ____, field_type, _____) \
395 static_assert(k##field_type##Cid == kSmiCid);
397#undef CHECK_INT_NATIVE_SLOT
403#define CHECK_NONINT_NATIVE_SLOT(__, ___, ____, field_type, _____) \
404 static_assert(k##field_type##Cid != kSmiCid); \
405 static_assert(k##field_type##Cid != kMintCid);
407#undef CHECK_NONINT_NATIVE_SLOT
421 const int32_t state_;
436#define DECLARE_KIND(ClassName, __, FieldName, ___, ____) \
437 k##ClassName##_##FieldName,
487 const LocalVariable& var);
490 static const Slot&
Get(
const Field&
field,
491 const ParsedFunction* parsed_function);
494#define DEFINE_GETTER(ClassName, __, FieldName, ___, ____) \
495 static const Slot& ClassName##_##FieldName() { \
496 return GetNativeSlot(Kind::k##ClassName##_##FieldName); \
511 const char*
Name()
const;
543 return *DataAs<const Field>();
575 field_guard_state_(field_guard_state),
579 Slot(
const Slot& other)
582 other.offset_in_bytes_,
585 other.representation_,
586 other.field_guard_state_) {}
588 template <
typename T>
589 const T* DataAs()
const {
590 return static_cast<const T*
>(data_);
593 static const Slot& GetCanonicalSlot(
601 const FieldGuardState& field_guard_state = FieldGuardState());
603 static const Slot& GetNativeSlot(
Kind kind);
605 const FieldGuardState& field_guard_state()
const {
606 return field_guard_state_;
611 const intptr_t offset_in_bytes_;
614 const FieldGuardState field_guard_state_;
624 using IsImmutableBit = BitField<
decltype(flags_),
bool, 0, 1>;
628 using IsCompressedBit =
631 using IsNonTaggedBit =
633 using MayContainInnerPointerBit =
635 using HasUntaggedInstanceBit =
static constexpr intptr_t kNextBit
static constexpr T decode(S value)
intptr_t guarded_cid() const
bool is_guarded_field() const
static const Slot & GetContextVariableSlotFor(Thread *thread, const LocalVariable &var)
bool IsArgumentOfType() const
bool IsImmutableLengthSlot() const
static const Slot & GetRecordFieldSlot(Thread *thread, intptr_t offset_in_bytes)
bool IsArrayElement() const
bool IsLocalVariable() const
bool IsRecordField() const
static const Slot & GetArrayElementSlot(Thread *thread, intptr_t offset_in_bytes)
bool IsIdentical(const Slot &other) const
bool is_immutable() const
static const Slot & Get(const Field &field, const ParsedFunction *parsed_function)
static const Slot & GetLengthFieldForArrayCid(intptr_t array_cid)
bool Equals(const Slot &other) const
const Field & field() const
bool IsTypeArguments() const
bool IsContextSlot() const
Representation representation() const
void Write(FlowGraphSerializer *s) const
intptr_t offset_in_bytes() const
bool has_untagged_instance() const
static const Slot & Read(FlowGraphDeserializer *d)
bool may_contain_inner_pointer() const
const char * Name() const
static const Slot & GetTypeArgumentsIndexSlot(Thread *thread, intptr_t index)
bool is_compressed() const
static const Slot & GetTypeArgumentsSlotFor(Thread *thread, const Class &cls)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
FlutterSemanticsFlag flags
static int8_t data[kExtLength]
#define CHECK_TAGGED_NATIVE_SLOT(__, ___, ____, field_type, _____)
#define DEFINE_GETTER(ClassName, __, FieldName, ___, ____)
#define NATIVE_SLOTS_LIST(V)
#define TAGGED_NONINT_NATIVE_SLOTS_LIST(V)
#define CHECK_INT_NATIVE_SLOT(__, ___, ____, field_type, _____)
#define CHECK_NATIVE_NONDART_SLOT(__, ___, ____, gc_may_move, _____)
#define TAGGED_NATIVE_SLOTS_LIST(V)
#define TAGGED_INT_NATIVE_SLOTS_LIST(V)
#define CHECK_NONINT_NATIVE_SLOT(__, ___, ____, field_type, _____)
#define UNTAGGED_NATIVE_NONDART_SLOTS_LIST(V)