class MANAGED Array : public Object { public: static constexpr size_t kFirstElementOffset = 12u;
// The size of a java.lang.Class representing an array. static uint32_t ClassSize(PointerSize pointer_size);
// Allocates an array with the given properties, if kFillUsable is true the array will be of at // least component_count size, however, if there's usable space at the end of the allocation the // array will fill it. template <bool kIsInstrumented = true, bool kFillUsable = false>
ALWAYS_INLINE static ObjPtr<Array> Alloc(Thread* self,
ObjPtr<Class> array_class,
int32_t component_count,
size_t component_size_shift,
gc::AllocatorType allocator_type)
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Roles::uninterruptible_);
void SetLength(int32_t length) REQUIRES_SHARED(Locks::mutator_lock_) {
DCHECK_GE(length, 0); // We use non transactional version since we can't undo this write. We also disable checking // since it would fail during a transaction.
SetField32<false, false, kVerifyNone>(OFFSET_OF_OBJECT_MEMBER(Array, length_), length);
}
// Returns true if the index is valid. If not, throws an ArrayIndexOutOfBoundsException and // returns false. template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
ALWAYS_INLINE bool CheckIsValidIndex(int32_t index) REQUIRES_SHARED(Locks::mutator_lock_);
// The number of array elements. // We only use the field indirectly using the LengthOffset() method.
[[maybe_unused]] int32_t length_; // Marker for the data (used by generated code) // We only use the field indirectly using the DataOffset() method.
[[maybe_unused]] uint32_t first_element_[0];
DISALLOW_IMPLICIT_CONSTRUCTORS(Array);
};
template<typename T> class MANAGED PrimitiveArray : public Array { public:
MIRROR_CLASS("[Z");
MIRROR_CLASS("[B");
MIRROR_CLASS("[C");
MIRROR_CLASS("[S");
MIRROR_CLASS("[I");
MIRROR_CLASS("[J");
MIRROR_CLASS("[F");
MIRROR_CLASS("[D");
T Get(int32_t i) ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_);
T GetWithoutChecks(int32_t i) ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_) {
DCHECK(CheckIsValidIndex(i)) << "i=" << i << " length=" << GetLength(); return GetData()[i];
}
void Set(int32_t i, T value) ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_);
// TODO fix thread safety analysis broken by the use of template. This should be // REQUIRES_SHARED(Locks::mutator_lock_). template<bool kTransactionActive, bool kCheckTransaction = true> void Set(int32_t i, T value) ALWAYS_INLINE NO_THREAD_SAFETY_ANALYSIS;
// TODO fix thread safety analysis broken by the use of template. This should be // REQUIRES_SHARED(Locks::mutator_lock_). template<bool kTransactionActive, bool kCheckTransaction = true,
VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> void SetWithoutChecks(int32_t i, T value) ALWAYS_INLINE NO_THREAD_SAFETY_ANALYSIS;
// Declare the different primitive arrays. Instantiations will be in array.cc. externtemplateclass PrimitiveArray<uint8_t>; // BooleanArray externtemplateclass PrimitiveArray<int8_t>; // ByteArray externtemplateclass PrimitiveArray<uint16_t>; // CharArray externtemplateclass PrimitiveArray<double>; // DoubleArray externtemplateclass PrimitiveArray<float>; // FloatArray externtemplateclass PrimitiveArray<int32_t>; // IntArray externtemplateclass PrimitiveArray<int64_t>; // LongArray externtemplateclass PrimitiveArray<int16_t>; // ShortArray
// Either an IntArray or a LongArray. class PointerArray : public Array { public: template<typename T, VerifyObjectFlags kVerifyFlags = kVerifyNone>
T GetElementPtrSize(uint32_t idx, PointerSize ptr_size)
REQUIRES_SHARED(Locks::mutator_lock_); template<typename T, PointerSize kPtrSize, VerifyObjectFlags kVerifyFlags = kVerifyNone>
T GetElementPtrSize(uint32_t idx)
REQUIRES_SHARED(Locks::mutator_lock_); // Same as GetElementPtrSize, but uses unchecked version of array conversion. It is thus not // checked whether kPtrSize matches the underlying array. Only use after at least one invocation // of GetElementPtrSize! template<typename T, PointerSize kPtrSize, VerifyObjectFlags kVerifyFlags = kVerifyNone>
T GetElementPtrSizeUnchecked(uint32_t idx)
REQUIRES_SHARED(Locks::mutator_lock_);
// Fixup the pointers in the dest arrays by passing our pointers through the visitor. Only copies // to dest if visitor(source_ptr) != source_ptr. template <VerifyObjectFlags kVerifyFlags = kVerifyNone, typename Visitor> void Fixup(mirror::PointerArray* dest, PointerSize pointer_size, const Visitor& visitor)
REQUIRES_SHARED(Locks::mutator_lock_);
// Works like memcpy(), except we guarantee not to allow tearing of array values (ie using smaller // than element size copies). Arguments are assumed to be within the bounds of the array and the // arrays non-null. Cannot be called in an active transaction. template<bool kUnchecked = false> void Memcpy(int32_t dst_pos,
ObjPtr<PointerArray> src,
int32_t src_pos,
int32_t count,
PointerSize pointer_size)
REQUIRES_SHARED(Locks::mutator_lock_);
};
} // namespace mirror
} // namespace art
#endif// ART_RUNTIME_MIRROR_ARRAY_H_
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.