Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dart::compiler::ffi::NativeArrayType Class Reference

#include <native_type.h>

Inheritance diagram for dart::compiler::ffi::NativeArrayType:
dart::compiler::ffi::NativeType dart::ZoneAllocated

Public Member Functions

 NativeArrayType (const NativeType &element_type, intptr_t length)
 
const NativeTypeelement_type () const
 
intptr_t length () const
 
virtual bool IsArray () const
 
virtual intptr_t SizeInBytes () const
 
virtual intptr_t AlignmentInBytesField () const
 
virtual intptr_t AlignmentInBytesStack (bool is_vararg=false) const
 
virtual bool ContainsOnlyFloats (Range range) const
 
virtual bool ContainsUnalignedMembers (intptr_t offset=0) const
 
virtual bool Equals (const NativeType &other) const
 
virtual void PrintTo (BaseTextBuffer *f, bool multi_line=false, bool verbose=true) const
 
virtual intptr_t NumPrimitiveMembersRecursive () const
 
virtual const NativePrimitiveTypeFirstPrimitiveMember () const
 
virtual intptr_t PrimitivePairMembers (const NativePrimitiveType **first, const NativePrimitiveType **second, intptr_t offset_in_members=0) const
 
- Public Member Functions inherited from dart::compiler::ffi::NativeType
virtual bool IsPrimitive () const
 
const NativePrimitiveTypeAsPrimitive () const
 
const NativeArrayTypeAsArray () const
 
virtual bool IsCompound () const
 
const NativeCompoundTypeAsCompound () const
 
virtual bool IsStruct () const
 
const NativeStructTypeAsStruct () const
 
virtual bool IsInt () const
 
virtual bool IsFloat () const
 
virtual bool IsVoid () const
 
virtual bool IsSigned () const
 
virtual bool IsExpressibleAsRepresentation () const
 
virtual Representation AsRepresentation () const
 
Representation AsRepresentationOverApprox (Zone *zone_) const
 
virtual NativeTypeSplit (Zone *zone, intptr_t index) const
 
const NativeTypeWidenTo4Bytes (Zone *zone) const
 
const NativeTypeWidenTo8Bytes (Zone *zone) const
 
const NativeTypeExtend (Zone *zone, ExtensionStrategy extension) const
 
const char * ToCString (Zone *zone, bool multi_line=false, bool verbose=true) const
 
const char * ToCString () const
 
virtual ~NativeType ()
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Additional Inherited Members

- Static Public Member Functions inherited from dart::compiler::ffi::NativeType
static const NativeTypeFromAbstractType (Zone *zone, const AbstractType &type, const char **error)
 
static const NativeTypeFromTypedDataClassId (Zone *zone, classid_t class_id)
 
static NativePrimitiveTypeFromRepresentation (Zone *zone, Representation rep)
 
- Protected Member Functions inherited from dart::compiler::ffi::NativeType
 NativeType ()
 

Detailed Description

Definition at line 270 of file native_type.h.

Constructor & Destructor Documentation

◆ NativeArrayType()

dart::compiler::ffi::NativeArrayType::NativeArrayType ( const NativeType element_type,
intptr_t  length 
)
inline

Definition at line 272 of file native_type.h.

273 : element_type_(element_type), length_(length) {
275 ASSERT(length > 0);
276 }
const NativeType & element_type() const
virtual bool IsArray() const
Definition native_type.h:82
#define ASSERT(E)

Member Function Documentation

◆ AlignmentInBytesField()

virtual intptr_t dart::compiler::ffi::NativeArrayType::AlignmentInBytesField ( ) const
inlinevirtual

Implements dart::compiler::ffi::NativeType.

Definition at line 286 of file native_type.h.

286 {
287 return element_type_.AlignmentInBytesField();
288 }
virtual intptr_t AlignmentInBytesField() const =0

◆ AlignmentInBytesStack()

virtual intptr_t dart::compiler::ffi::NativeArrayType::AlignmentInBytesStack ( bool  is_vararg = false) const
inlinevirtual

Implements dart::compiler::ffi::NativeType.

Definition at line 289 of file native_type.h.

289 {
290 return element_type_.AlignmentInBytesStack();
291 }
virtual intptr_t AlignmentInBytesStack(bool is_vararg=false) const =0

◆ ContainsOnlyFloats()

bool dart::compiler::ffi::NativeArrayType::ContainsOnlyFloats ( Range  range) const
virtual

Implements dart::compiler::ffi::NativeType.

Definition at line 893 of file native_type.cc.

893 {
894 const auto this_range = Range::StartAndEnd(0, SizeInBytes());
895 ASSERT(this_range.Contains(range));
896
897 const intptr_t element_size_in_bytes = element_type_.SizeInBytes();
898
899 // Assess how many elements are (partially) covered by the range.
900 const intptr_t first_element_start = range.start() / element_size_in_bytes;
901 const intptr_t last_element_index =
902 range.end_inclusive() / element_size_in_bytes;
903 const intptr_t num_elements = last_element_index - first_element_start + 1;
904 ASSERT(num_elements >= 1);
905
906 if (num_elements > 2) {
907 // At least one full element covered.
908 return element_type_.ContainsOnlyFloats(
909 Range::StartAndLength(0, element_size_in_bytes));
910 }
911
912 // Check first element, which falls (partially) in range.
913 const intptr_t first_start = first_element_start * element_size_in_bytes;
914 const auto first_range =
915 Range::StartAndLength(first_start, element_size_in_bytes);
916 const auto first_range_clipped = range.Intersect(first_range);
917 const auto range_in_first = first_range_clipped.Translate(-first_start);
918 if (!element_type_.ContainsOnlyFloats(range_in_first)) {
919 // First element contains not only floats in specified range.
920 return false;
921 }
922
923 if (num_elements == 2) {
924 // Check the second (and last) element, which falls (partially) in range.
925 const intptr_t second_element_index = first_element_start + 1;
926 const intptr_t second_start = second_element_index * element_size_in_bytes;
927 const auto second_range =
928 Range::StartAndLength(second_start, element_size_in_bytes);
929 const auto second_range_clipped = range.Intersect(second_range);
930 const auto range_in_second = second_range_clipped.Translate(-second_start);
931 return element_type_.ContainsOnlyFloats(range_in_second);
932 }
933
934 return true;
935}
virtual intptr_t SizeInBytes() const
virtual intptr_t SizeInBytes() const =0
virtual bool ContainsOnlyFloats(Range range) const =0
static Range StartAndLength(intptr_t start_inclusive, intptr_t length)
Definition range.h:28
static Range StartAndEnd(intptr_t start_inclusive, intptr_t end_exclusive)
Definition range.h:35

◆ ContainsUnalignedMembers()

bool dart::compiler::ffi::NativeArrayType::ContainsUnalignedMembers ( intptr_t  offset = 0) const
virtual

Implements dart::compiler::ffi::NativeType.

Definition at line 1007 of file native_type.cc.

1007 {
1008 const intptr_t element_size = element_type_.SizeInBytes();
1009 // We're only checking the first two elements of the array.
1010 //
1011 // If the element size is divisible by the alignment of the largest type
1012 // contained within the element type, the alignment of all elements is the
1013 // same. If not, either the first or the second element is unaligned.
1014 const intptr_t max_check = 2;
1015 for (intptr_t i = 0; i < Utils::Minimum(length_, max_check); i++) {
1016 const intptr_t element_offset = i * element_size;
1017 if (element_type_.ContainsUnalignedMembers(offset + element_offset)) {
1018 return true;
1019 }
1020 }
1021 return false;
1022}
static size_t element_size(Layout layout, SkSLType type)
static T Minimum(T x, T y)
Definition utils.h:21
virtual bool ContainsUnalignedMembers(intptr_t offset=0) const =0
Point offset

◆ element_type()

const NativeType & dart::compiler::ffi::NativeArrayType::element_type ( ) const
inline

Definition at line 278 of file native_type.h.

278{ return element_type_; }

◆ Equals()

bool dart::compiler::ffi::NativeArrayType::Equals ( const NativeType other) const
virtual

Reimplemented from dart::compiler::ffi::NativeType.

Definition at line 350 of file native_type.cc.

350 {
351 if (!other.IsArray()) {
352 return false;
353 }
354 return other.AsArray().length_ == length_ &&
355 other.AsArray().element_type_.Equals(element_type_);
356}

◆ FirstPrimitiveMember()

const NativePrimitiveType & dart::compiler::ffi::NativeArrayType::FirstPrimitiveMember ( ) const
virtual

Implements dart::compiler::ffi::NativeType.

Definition at line 840 of file native_type.cc.

840 {
841 return element_type_.FirstPrimitiveMember();
842}
virtual const NativePrimitiveType & FirstPrimitiveMember() const =0

◆ IsArray()

virtual bool dart::compiler::ffi::NativeArrayType::IsArray ( ) const
inlinevirtual

Reimplemented from dart::compiler::ffi::NativeType.

Definition at line 281 of file native_type.h.

281{ return true; }

◆ length()

intptr_t dart::compiler::ffi::NativeArrayType::length ( ) const
inline

Definition at line 279 of file native_type.h.

279{ return length_; }

◆ NumPrimitiveMembersRecursive()

intptr_t dart::compiler::ffi::NativeArrayType::NumPrimitiveMembersRecursive ( ) const
virtual

Implements dart::compiler::ffi::NativeType.

Definition at line 816 of file native_type.cc.

816 {
817 return element_type_.NumPrimitiveMembersRecursive() * length_;
818}
virtual intptr_t NumPrimitiveMembersRecursive() const =0

◆ PrimitivePairMembers()

intptr_t dart::compiler::ffi::NativeArrayType::PrimitivePairMembers ( const NativePrimitiveType **  first,
const NativePrimitiveType **  second,
intptr_t  offset_in_members = 0 
) const
virtual

Implements dart::compiler::ffi::NativeType.

Definition at line 863 of file native_type.cc.

866 {
867 for (intptr_t i = 0; i < length_; i++) {
868 offset_in_members =
869 element_type_.PrimitivePairMembers(first, second, offset_in_members);
870 }
871 return offset_in_members;
872}
virtual intptr_t PrimitivePairMembers(const NativePrimitiveType **first, const NativePrimitiveType **second, intptr_t offset_in_members=0) const =0

◆ PrintTo()

void dart::compiler::ffi::NativeArrayType::PrintTo ( BaseTextBuffer f,
bool  multi_line = false,
bool  verbose = true 
) const
virtual

Reimplemented from dart::compiler::ffi::NativeType.

Definition at line 733 of file native_type.cc.

735 {
736 f->AddString("Array(");
737 f->Printf("element type: ");
738 element_type_.PrintTo(f, /*multi_line*/ false, verbose);
739 f->Printf(", length: %" Pd "", length_);
740 f->AddString(")");
741}
virtual void PrintTo(BaseTextBuffer *f, bool multi_line=false, bool verbose=true) const
#define Pd
Definition globals.h:408

◆ SizeInBytes()

virtual intptr_t dart::compiler::ffi::NativeArrayType::SizeInBytes ( ) const
inlinevirtual

Implements dart::compiler::ffi::NativeType.

Definition at line 283 of file native_type.h.

283 {
284 return element_type_.SizeInBytes() * length_;
285 }

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