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

#include <native_type.h>

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

Public Member Functions

 NativePrimitiveType (PrimitiveType rep)
 
PrimitiveType representation () const
 
virtual bool IsPrimitive () const
 
virtual bool IsInt () const
 
virtual bool IsFloat () const
 
virtual bool IsVoid () const
 
virtual bool IsSigned () const
 
virtual intptr_t SizeInBytes () const
 
virtual intptr_t AlignmentInBytesStack (bool is_vararg=false) const
 
virtual intptr_t AlignmentInBytesField () const
 
virtual bool ContainsOnlyFloats (Range range) const
 
virtual bool ContainsUnalignedMembers (intptr_t offset=0) const
 
virtual bool IsExpressibleAsRepresentation () const
 
virtual Representation AsRepresentation () const
 
virtual bool Equals (const NativeType &other) const
 
virtual NativePrimitiveTypeSplit (Zone *zone, intptr_t part) 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
 
virtual ~NativePrimitiveType ()
 
- Public Member Functions inherited from dart::compiler::ffi::NativeType
const NativePrimitiveTypeAsPrimitive () const
 
virtual bool IsArray () const
 
const NativeArrayTypeAsArray () const
 
virtual bool IsCompound () const
 
const NativeCompoundTypeAsCompound () const
 
virtual bool IsStruct () const
 
const NativeStructTypeAsStruct () const
 
Representation AsRepresentationOverApprox (Zone *zone_) 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 221 of file native_type.h.

Constructor & Destructor Documentation

◆ NativePrimitiveType()

dart::compiler::ffi::NativePrimitiveType::NativePrimitiveType ( PrimitiveType  rep)
inlineexplicit

Definition at line 223 of file native_type.h.

223: representation_(rep) {}

◆ ~NativePrimitiveType()

virtual dart::compiler::ffi::NativePrimitiveType::~NativePrimitiveType ( )
inlinevirtual

Definition at line 263 of file native_type.h.

263{}

Member Function Documentation

◆ AlignmentInBytesField()

intptr_t dart::compiler::ffi::NativePrimitiveType::AlignmentInBytesField ( ) const
virtual

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

Definition at line 174 of file native_type.cc.

174 {
177 // The default is to align fields to their own size.
178 return SizeInBytes();
180 // However, on some 32-bit architectures, 8-byte fields are only aligned
181 // to 4 bytes.
182 if (SizeInBytes() == 8) {
183 return 4;
184 }
185 return SizeInBytes();
186 }
187 default:
189 }
190}
static constexpr AlignmentStrategy kFieldAlignment
@ kAlignedToValueSizeBut8AlignedTo4
@ kAlignedToValueSize
#define UNREACHABLE_THIS()
Definition native_type.h:25

◆ AlignmentInBytesStack()

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

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

Definition at line 154 of file native_type.cc.

154 {
155 const auto alignment =
158 switch (alignment) {
160 // The default is to align stack arguments to word size.
161 return compiler::target::kWordSize;
163 // However, arm32+riscv32 align to the greater of word size or value size.
165 static_cast<intptr_t>(compiler::target::kWordSize));
167 // iOS on arm64 only aligns to size.
168 return SizeInBytes();
169 default:
171 }
172}
static constexpr AlignmentStrategy kArgumentStackAlignmentVarArgs
static constexpr AlignmentStrategy kArgumentStackAlignment
static constexpr T Maximum(T x, T y)
Definition utils.h:26
@ kAlignedToWordSizeAndValueSize
@ kAlignedToWordSize

◆ AsRepresentation()

Representation dart::compiler::ffi::NativePrimitiveType::AsRepresentation ( ) const
virtual

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

Definition at line 313 of file native_type.cc.

313 {
315 switch (representation_) {
316 case kInt8:
317 return kUnboxedInt8;
318 case kUint8:
319 return kUnboxedUint8;
320 case kInt16:
321 return kUnboxedInt16;
322 case kUint16:
323 return kUnboxedUint16;
324 case kInt32:
325 return kUnboxedInt32;
326 case kUint32:
327 return kUnboxedUint32;
328 case kInt64:
329 case kUint64:
330 return kUnboxedInt64;
331 case kFloat:
332 return kUnboxedFloat;
333 case kDouble:
334 return kUnboxedDouble;
335 case kVoid:
336 return kUnboxedIntPtr;
337 default:
339 }
340}
virtual bool IsExpressibleAsRepresentation() const
#define ASSERT(E)
static constexpr Representation kUnboxedIntPtr
Definition locations.h:176

◆ ContainsOnlyFloats()

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

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

Definition at line 886 of file native_type.cc.

886 {
887 const auto this_range = Range::StartAndEnd(0, SizeInBytes());
888 ASSERT(this_range.Contains(range));
889
890 return IsFloat();
891}
static Range StartAndEnd(intptr_t start_inclusive, intptr_t end_exclusive)
Definition range.h:35

◆ ContainsUnalignedMembers()

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

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

Definition at line 1003 of file native_type.cc.

1003 {
1004 return offset % AlignmentInBytesField() != 0;
1005}
virtual intptr_t AlignmentInBytesField() const
Point offset

◆ Equals()

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

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

Definition at line 343 of file native_type.cc.

343 {
344 if (!other.IsPrimitive()) {
345 return false;
346 }
347 return other.AsPrimitive().representation_ == representation_;
348}

◆ FirstPrimitiveMember()

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

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

Definition at line 836 of file native_type.cc.

836 {
837 return *this;
838}

◆ IsExpressibleAsRepresentation()

bool dart::compiler::ffi::NativePrimitiveType::IsExpressibleAsRepresentation ( ) const
virtual

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

Definition at line 284 of file native_type.cc.

284 {
285 switch (representation_) {
286 case kInt24:
287 case kUint24:
288 case kInt40:
289 case kUint40:
290 case kInt48:
291 case kUint48:
292 case kInt56:
293 case kUint56:
294 case kHalfDouble:
295 return false;
296 case kInt8:
297 case kUint8:
298 case kInt16:
299 case kUint16:
300 case kInt32:
301 case kUint32:
302 case kInt64:
303 case kUint64: // We don't actually have a kUnboxedUint64.
304 case kFloat:
305 case kDouble:
306 case kVoid:
307 return true;
308 default:
309 UNREACHABLE_THIS(); // Make MSVC happy.
310 }
311}

◆ IsFloat()

bool dart::compiler::ffi::NativePrimitiveType::IsFloat ( ) const
virtual

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

Definition at line 90 of file native_type.cc.

90 {
91 return representation_ == kFloat || representation_ == kDouble ||
92 representation_ == kHalfDouble;
93}

◆ IsInt()

bool dart::compiler::ffi::NativePrimitiveType::IsInt ( ) const
virtual

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

Definition at line 66 of file native_type.cc.

66 {
67 switch (representation_) {
68 case kInt8:
69 case kUint8:
70 case kInt16:
71 case kUint16:
72 case kInt24:
73 case kUint24:
74 case kInt32:
75 case kUint32:
76 case kInt40:
77 case kUint40:
78 case kInt48:
79 case kUint48:
80 case kInt56:
81 case kUint56:
82 case kInt64:
83 case kUint64:
84 return true;
85 default:
86 return false;
87 }
88}

◆ IsPrimitive()

virtual bool dart::compiler::ffi::NativePrimitiveType::IsPrimitive ( ) const
inlinevirtual

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

Definition at line 227 of file native_type.h.

227{ return true; }

◆ IsSigned()

bool dart::compiler::ffi::NativePrimitiveType::IsSigned ( ) const
virtual

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

Definition at line 99 of file native_type.cc.

99 {
100 ASSERT(IsInt() || IsFloat());
101 switch (representation_) {
102 case kInt8:
103 case kInt16:
104 case kInt24:
105 case kInt32:
106 case kInt40:
107 case kInt48:
108 case kInt56:
109 case kInt64:
110 case kFloat:
111 case kDouble:
112 case kHalfDouble:
113 return true;
114 case kUint8:
115 case kUint16:
116 case kUint24:
117 case kUint32:
118 case kUint40:
119 case kUint48:
120 case kUint56:
121 case kUint64:
122 default:
123 return false;
124 }
125}

◆ IsVoid()

bool dart::compiler::ffi::NativePrimitiveType::IsVoid ( ) const
virtual

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

Definition at line 95 of file native_type.cc.

95 {
96 return representation_ == kVoid;
97}

◆ NumPrimitiveMembersRecursive()

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

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

Definition at line 812 of file native_type.cc.

812 {
813 return 1;
814}

◆ PrimitivePairMembers()

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

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

Definition at line 854 of file native_type.cc.

857 {
858 if (offset_in_members == 0) *first = this;
859 if (offset_in_members == 1) *second = this;
860 return offset_in_members + 1;
861}

◆ PrintTo()

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

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

Definition at line 721 of file native_type.cc.

723 {
724 f->Printf("%s", PrimitiveTypeToCString(representation_));
725}
static const char * PrimitiveTypeToCString(PrimitiveType rep)

◆ representation()

PrimitiveType dart::compiler::ffi::NativePrimitiveType::representation ( ) const
inline

Definition at line 225 of file native_type.h.

225{ return representation_; }

◆ SizeInBytes()

intptr_t dart::compiler::ffi::NativePrimitiveType::SizeInBytes ( ) const
virtual

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

Definition at line 150 of file native_type.cc.

150 {
151 return fundamental_size_in_bytes[representation_];
152}
static const intptr_t fundamental_size_in_bytes[kVoid+1]

◆ Split()

NativePrimitiveType & dart::compiler::ffi::NativePrimitiveType::Split ( Zone zone,
intptr_t  part 
) const
virtual

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

Definition at line 396 of file native_type.cc.

397 {
398 ASSERT(index == 0 || index == 1);
399 auto new_rep = split_fundamental(representation());
400 return *new (zone) NativePrimitiveType(new_rep);
401}
static PrimitiveType split_fundamental(PrimitiveType in)

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