Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
dart::TypedData Class Reference

#include <object.h>

Inheritance diagram for dart::TypedData:
dart::TypedDataBase dart::PointerBase dart::Instance dart::Object

Public Member Functions

virtual bool CanonicalizeEquals (const Instance &other) const
 
virtual uint32_t CanonicalizeHash () const
 
- Public Member Functions inherited from dart::TypedDataBase
SmiPtr length () const
 
intptr_t Length () const
 
intptr_t LengthInBytes () const
 
TypedDataElementType ElementType () const
 
intptr_t ElementSizeInBytes () const
 
bool IsExternalOrExternalView () const
 
TypedDataViewPtr ViewFromTo (intptr_t start, intptr_t end, Heap::Space space=Heap::kNew) const
 
void * DataAddr (intptr_t byte_offset) const
 
- Public Member Functions inherited from dart::Instance
virtual bool OperatorEquals (const Instance &other) const
 
bool IsIdenticalTo (const Instance &other) const
 
virtual bool CanonicalizeEquals (const Instance &other) const
 
virtual uint32_t CanonicalizeHash () const
 
intptr_t SizeFromClass () const
 
InstancePtr Canonicalize (Thread *thread) const
 
virtual InstancePtr CanonicalizeLocked (Thread *thread) const
 
virtual void CanonicalizeFieldsLocked (Thread *thread) const
 
InstancePtr CopyShallowToOldSpace (Thread *thread) const
 
ObjectPtr GetField (const Field &field) const
 
void SetField (const Field &field, const Object &value) const
 
AbstractTypePtr GetType (Heap::Space space) const
 
virtual TypeArgumentsPtr GetTypeArguments () const
 
virtual void SetTypeArguments (const TypeArguments &value) const
 
bool IsInstanceOf (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments) const
 
bool IsAssignableTo (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments) const
 
bool IsValidNativeIndex (int index) const
 
intptr_t * NativeFieldsDataAddr () const
 
intptr_t GetNativeField (int index) const
 
void GetNativeFields (uint16_t num_fields, intptr_t *field_values) const
 
void SetNativeFields (uint16_t num_fields, const intptr_t *field_values) const
 
uint16_t NumNativeFields () const
 
void SetNativeField (int index, intptr_t value) const
 
bool IsCallable (Function *function) const
 
ObjectPtr Invoke (const String &selector, const Array &arguments, const Array &argument_names, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr InvokeGetter (const String &selector, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr InvokeSetter (const String &selector, const Instance &argument, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr EvaluateCompiledExpression (const Class &klass, const ExternalTypedData &kernel_buffer, const Array &type_definitions, const Array &arguments, const TypeArguments &type_arguments) const
 
virtual ObjectPtr HashCode () const
 
IntegerPtr IdentityHashCode (Thread *thread) const
 
virtual bool IsPointer () const
 
- Public Member Functions inherited from dart::Object
virtual ~Object ()
 
ObjectPtr ptr () const
 
void operator= (ObjectPtr value)
 
bool IsCanonical () const
 
void SetCanonical () const
 
void ClearCanonical () const
 
bool IsImmutable () const
 
void SetImmutable () const
 
void ClearImmutable () const
 
intptr_t GetClassId () const
 
ClassPtr clazz () const
 
 CLASS_LIST_FOR_HANDLES (DEFINE_CLASS_TESTER)
 
bool IsNull () const
 
virtual const char * ToCString () const
 
void PrintJSON (JSONStream *stream, bool ref=true) const
 
virtual void PrintJSONImpl (JSONStream *stream, bool ref) const
 
void PrintImplementationFields (JSONStream *stream) const
 
virtual void PrintImplementationFieldsImpl (const JSONArray &jsarr_fields) const
 
virtual const char * JSONType () const
 
virtual StringPtr DictionaryName () const
 
bool IsNew () const
 
bool IsOld () const
 
bool InVMIsolateHeap () const
 
void Print () const
 

Static Public Member Functions

static intptr_t payload_offset ()
 
static intptr_t InstanceSize ()
 
static intptr_t InstanceSize (intptr_t lengthInBytes)
 
static intptr_t MaxElements (intptr_t class_id)
 
static intptr_t MaxNewSpaceElements (intptr_t class_id)
 
static TypedDataPtr New (intptr_t class_id, intptr_t len, Heap::Space space=Heap::kNew)
 
static TypedDataPtr Grow (const TypedData &current, intptr_t len, Heap::Space space=Heap::kNew)
 
static bool IsTypedData (const Instance &obj)
 
- Static Public Member Functions inherited from dart::TypedDataBase
static intptr_t length_offset ()
 
static intptr_t ElementSizeInBytes (classid_t cid)
 
static TypedDataElementType ElementType (classid_t cid)
 
- Static Public Member Functions inherited from dart::PointerBase
static intptr_t data_offset ()
 
- Static Public Member Functions inherited from dart::Instance
static bool NullIsAssignableTo (const AbstractType &other)
 
static bool NullIsAssignableTo (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments)
 
static ObjectPtr EvaluateCompiledExpression (Thread *thread, const Object &receiver, const Library &library, const Class &klass, const ExternalTypedData &kernel_buffer, const Array &type_definitions, const Array &param_values, const TypeArguments &type_param_values)
 
static intptr_t UnroundedSize ()
 
static intptr_t InstanceSize ()
 
static InstancePtr New (const Class &cls, Heap::Space space=Heap::kNew)
 
static InstancePtr NewAlreadyFinalized (const Class &cls, Heap::Space space=Heap::kNew)
 
static intptr_t DataOffsetFor (intptr_t cid)
 
static intptr_t ElementSizeFor (intptr_t cid)
 
static intptr_t NextFieldOffset ()
 
static intptr_t NativeFieldsOffset ()
 
- Static Public Member Functions inherited from dart::Object
static ObjectPtr RawCast (ObjectPtr obj)
 
static constexpr bool ContainsCompressedPointers ()
 
static intptr_t tags_offset ()
 
static ObjectHandle ()
 
static ObjectHandle (Zone *zone)
 
static ObjectHandle (ObjectPtr ptr)
 
static ObjectHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectZoneHandle ()
 
static ObjectZoneHandle (Zone *zone)
 
static ObjectZoneHandle (ObjectPtr ptr)
 
static ObjectZoneHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectReadOnlyHandle ()
 
static ObjectPtr null ()
 
static void set_vm_isolate_snapshot_object_table (const Array &table)
 
static ClassPtr class_class ()
 
static ClassPtr dynamic_class ()
 
static ClassPtr void_class ()
 
static ClassPtr type_parameters_class ()
 
static ClassPtr type_arguments_class ()
 
static ClassPtr patch_class_class ()
 
static ClassPtr function_class ()
 
static ClassPtr closure_data_class ()
 
static ClassPtr ffi_trampoline_data_class ()
 
static ClassPtr field_class ()
 
static ClassPtr script_class ()
 
static ClassPtr library_class ()
 
static ClassPtr namespace_class ()
 
static ClassPtr kernel_program_info_class ()
 
static ClassPtr code_class ()
 
static ClassPtr instructions_class ()
 
static ClassPtr instructions_section_class ()
 
static ClassPtr instructions_table_class ()
 
static ClassPtr object_pool_class ()
 
static ClassPtr pc_descriptors_class ()
 
static ClassPtr code_source_map_class ()
 
static ClassPtr compressed_stackmaps_class ()
 
static ClassPtr var_descriptors_class ()
 
static ClassPtr exception_handlers_class ()
 
static ClassPtr context_class ()
 
static ClassPtr context_scope_class ()
 
static ClassPtr sentinel_class ()
 
static ClassPtr api_error_class ()
 
static ClassPtr language_error_class ()
 
static ClassPtr unhandled_exception_class ()
 
static ClassPtr unwind_error_class ()
 
static ClassPtr singletargetcache_class ()
 
static ClassPtr unlinkedcall_class ()
 
static ClassPtr monomorphicsmiablecall_class ()
 
static ClassPtr icdata_class ()
 
static ClassPtr megamorphic_cache_class ()
 
static ClassPtr subtypetestcache_class ()
 
static ClassPtr loadingunit_class ()
 
static ClassPtr weak_serialization_reference_class ()
 
static ClassPtr weak_array_class ()
 
static void InitNullAndBool (IsolateGroup *isolate_group)
 
static void Init (IsolateGroup *isolate_group)
 
static void InitVtables ()
 
static void FinishInit (IsolateGroup *isolate_group)
 
static void FinalizeVMIsolate (IsolateGroup *isolate_group)
 
static void FinalizeReadOnlyObject (ObjectPtr object)
 
static void Cleanup ()
 
static ErrorPtr Init (IsolateGroup *isolate_group, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
 
static void MakeUnusedSpaceTraversable (const Object &obj, intptr_t original_size, intptr_t used_size)
 
static intptr_t InstanceSize ()
 
template<class FakeObject >
static void VerifyBuiltinVtable (intptr_t cid)
 
static void VerifyBuiltinVtables ()
 
static bool ShouldHaveImmutabilityBitSet (classid_t class_id)
 

Protected Member Functions

void RecomputeDataField ()
 
- Protected Member Functions inherited from dart::TypedDataBase
void SetLength (intptr_t value) const
 
virtual uint8_t * Validate (uint8_t *data) const
 
- Protected Member Functions inherited from dart::Instance
virtual void PrintSharedInstanceJSON (JSONObject *jsobj, bool ref, bool include_id=true) const
 
- Protected Member Functions inherited from dart::Object
 Object ()
 
uword raw_value () const
 
void setPtr (ObjectPtr value, intptr_t default_cid)
 
void CheckHandle () const
 
cpp_vtable vtable () const
 
void set_vtable (cpp_vtable value)
 
bool Contains (uword addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
type LoadPointer (type const *addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
void StorePointer (type const *addr, type value) const
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
void StoreCompressedPointer (compressed_type const *addr, type value) const
 
template<typename type >
void StorePointerUnaligned (type const *addr, type value, Thread *thread) const
 
void StoreSmi (SmiPtr const *addr, SmiPtr value) const
 
template<typename FieldType >
void StoreSimd128 (const FieldType *addr, simd128_value_t value) const
 
template<typename FieldType >
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , std::memory_order order>
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , typename ValueType >
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType , typename ValueType , std::memory_order order>
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType >
FieldType * UnsafeMutableNonPointer (const FieldType *addr) const
 
 CLASS_LIST (STORE_NON_POINTER_ILLEGAL_TYPE)
 
void UnimplementedMethod () const
 
void AddCommonObjectProperties (JSONObject *jsobj, const char *protocol_type, bool ref) const
 

Friends

class Class
 
class ExternalTypedData
 
class TypedDataView
 

Additional Inherited Members

- Public Types inherited from dart::Object
enum  NameVisibility { kInternalName = 0 , kScrubbedName , kUserVisibleName }
 
enum class  NameDisambiguation { kYes , kNo }
 
using UntaggedObjectType = UntaggedObject
 
using ObjectPtrType = ObjectPtr
 
- Static Public Attributes inherited from dart::Object
static constexpr intptr_t kHashBits = 30
 
static const ClassId kClassId = kObjectCid
 
- Static Protected Member Functions inherited from dart::Object
static DART_NOINLINE ObjectHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectZoneHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectReadOnlyHandleImpl (intptr_t cid)
 
static ObjectPtr Allocate (intptr_t cls_id, intptr_t size, Heap::Space space, bool compressed, uword ptr_field_start_offset, uword ptr_field_end_offset)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space, intptr_t elements)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space, intptr_t elements)
 
static constexpr intptr_t RoundedAllocationSize (intptr_t size)
 
static ObjectPtr Clone (const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
 
template<typename T >
static DART_FORCE_INLINE uword from_offset ()
 
template<typename T >
static DART_FORCE_INLINE uword to_offset (intptr_t length=0)
 
- Protected Attributes inherited from dart::Object
ObjectPtr ptr_
 

Detailed Description

Definition at line 11634 of file object.h.

Member Function Documentation

◆ CanonicalizeEquals()

bool dart::TypedData::CanonicalizeEquals ( const Instance other) const
virtual

Reimplemented from dart::Instance.

Definition at line 25550 of file object.cc.

25550 {
25551 if (this->ptr() == other.ptr()) {
25552 // Both handles point to the same raw instance.
25553 return true;
25554 }
25555
25556 if (!other.IsTypedData() || other.IsNull()) {
25557 return false;
25558 }
25559
25560 const TypedData& other_typed_data = TypedData::Cast(other);
25561
25562 if (this->ElementType() != other_typed_data.ElementType()) {
25563 return false;
25564 }
25565
25566 const intptr_t len = this->LengthInBytes();
25567 if (len != other_typed_data.LengthInBytes()) {
25568 return false;
25569 }
25570 NoSafepointScope no_safepoint;
25571 return (len == 0) ||
25572 (memcmp(DataAddr(0), other_typed_data.DataAddr(0), len) == 0);
25573}
ObjectPtr ptr() const
Definition: object.h:332
TypedDataElementType ElementType() const
Definition: object.h:11527
intptr_t LengthInBytes() const
Definition: object.h:11523
void * DataAddr(intptr_t byte_offset) const
Definition: object.h:11571

◆ CanonicalizeHash()

uint32_t dart::TypedData::CanonicalizeHash ( ) const
virtual

Reimplemented from dart::Instance.

Definition at line 25575 of file object.cc.

25575 {
25576 const intptr_t len = this->LengthInBytes();
25577 if (len == 0) {
25578 return 1;
25579 }
25580 uint32_t hash = len;
25581 for (intptr_t i = 0; i < len; i++) {
25582 hash = CombineHashes(len, GetUint8(i));
25583 }
25584 return FinalizeHash(hash, kHashBits);
25585}
static uint32_t hash(const SkShaderBase::GradientInfo &v)
static constexpr intptr_t kHashBits
Definition: object.h:323
uint32_t CombineHashes(uint32_t hash, uint32_t other_hash)
Definition: hash.h:12
uint32_t FinalizeHash(uint32_t hash, intptr_t hashbits=kBitsPerInt32)
Definition: hash.h:20

◆ Grow()

TypedDataPtr dart::TypedData::Grow ( const TypedData current,
intptr_t  len,
Heap::Space  space = Heap::kNew 
)
static

Definition at line 25601 of file object.cc.

25603 {
25604 ASSERT(len > current.Length());
25605 const auto& new_td =
25606 TypedData::Handle(TypedData::New(current.GetClassId(), len, space));
25607 {
25608 NoSafepointScope no_safepoint_scope;
25609 memcpy(new_td.DataAddr(0), current.DataAddr(0), current.LengthInBytes());
25610 }
25611 return new_td.ptr();
25612}
static Object & Handle()
Definition: object.h:407
static TypedDataPtr New(intptr_t class_id, intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.cc:25587
#define ASSERT(E)

◆ InstanceSize() [1/2]

static intptr_t dart::TypedData::InstanceSize ( )
inlinestatic

Definition at line 11673 of file object.h.

11673 {
11674 ASSERT(sizeof(UntaggedTypedData) ==
11675 OFFSET_OF_RETURNED_VALUE(UntaggedTypedData, internal_data));
11676 return 0;
11677 }
#define OFFSET_OF_RETURNED_VALUE(type, accessor)
Definition: globals.h:143

◆ InstanceSize() [2/2]

static intptr_t dart::TypedData::InstanceSize ( intptr_t  lengthInBytes)
inlinestatic

Definition at line 11679 of file object.h.

11679 {
11680 ASSERT(0 <= lengthInBytes && lengthInBytes <= kSmiMax);
11681 return RoundedAllocationSize(sizeof(UntaggedTypedData) + lengthInBytes);
11682 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition: object.h:758
const intptr_t kSmiMax
Definition: globals.h:28

◆ IsTypedData()

static bool dart::TypedData::IsTypedData ( const Instance obj)
inlinestatic

Definition at line 11703 of file object.h.

11703 {
11704 ASSERT(!obj.IsNull());
11705 intptr_t cid = obj.ptr()->GetClassId();
11706 return IsTypedDataClassId(cid);
11707 }
bool IsTypedDataClassId(intptr_t index)
Definition: class_id.h:433
const intptr_t cid

◆ MaxElements()

static intptr_t dart::TypedData::MaxElements ( intptr_t  class_id)
inlinestatic

Definition at line 11684 of file object.h.

11684 {
11685 ASSERT(IsTypedDataClassId(class_id));
11686 return (kSmiMax / ElementSizeInBytes(class_id));
11687 }
intptr_t ElementSizeInBytes() const
Definition: object.h:11531

◆ MaxNewSpaceElements()

static intptr_t dart::TypedData::MaxNewSpaceElements ( intptr_t  class_id)
inlinestatic

Definition at line 11689 of file object.h.

11689 {
11690 ASSERT(IsTypedDataClassId(class_id));
11691 return (kNewAllocatableSize - sizeof(UntaggedTypedData)) /
11692 ElementSizeInBytes(class_id);
11693 }
static constexpr intptr_t kNewAllocatableSize
Definition: spaces.h:54

◆ New()

TypedDataPtr dart::TypedData::New ( intptr_t  class_id,
intptr_t  len,
Heap::Space  space = Heap::kNew 
)
static

Definition at line 25587 of file object.cc.

25589 {
25590 if (len < 0 || len > TypedData::MaxElements(class_id)) {
25591 FATAL("Fatal error in TypedData::New: invalid len %" Pd "\n", len);
25592 }
25593 auto raw = Object::AllocateVariant<TypedData>(
25594 class_id, space, len * ElementSizeInBytes(class_id));
25595 NoSafepointScope no_safepoint;
25596 raw->untag()->set_length(Smi::New(len));
25597 raw->untag()->RecomputeDataField();
25598 return raw;
25599}
static SmiPtr New(intptr_t value)
Definition: object.h:10006
static intptr_t MaxElements(intptr_t class_id)
Definition: object.h:11684
#define FATAL(error)
#define Pd
Definition: globals.h:408

◆ payload_offset()

static intptr_t dart::TypedData::payload_offset ( )
inlinestatic

Definition at line 11669 of file object.h.

11669 {
11671 }
static intptr_t payload_offset()
Definition: raw_object.h:3114

◆ RecomputeDataField()

void dart::TypedData::RecomputeDataField ( )
inlineprotected

Definition at line 11710 of file object.h.

11710{ ptr()->untag()->RecomputeDataField(); }
UntaggedObject * untag() const

Friends And Related Function Documentation

◆ Class

friend class Class
friend

Definition at line 11725 of file object.h.

◆ ExternalTypedData

friend class ExternalTypedData
friend

Definition at line 11726 of file object.h.

◆ TypedDataView

friend class TypedDataView
friend

Definition at line 11727 of file object.h.


The documentation for this class was generated from the following files: