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

#include <il.h>

Inheritance diagram for dart::ConstantInstr:
dart::TemplateDefinition< 0, NoThrow, Pure > dart::UnboxedConstantInstr

Public Member Functions

 ConstantInstr (const Object &value)
 
 ConstantInstr (const Object &value, const InstructionSource &source)
 
virtual CompileType ComputeType () const
 
virtual DefinitionCanonicalize (FlowGraph *flow_graph)
 
const Objectvalue () const
 
bool IsSmi () const
 
bool HasZeroRepresentation () const
 
virtual bool ComputeCanDeoptimize () const
 
virtual void InferRange (RangeAnalysis *analysis, Range *range)
 
virtual bool AttributesEqual (const Instruction &other) const
 
virtual TokenPosition token_pos () const
 
void EmitMoveToLocation (FlowGraphCompiler *compiler, const Location &destination, Register tmp=kNoRegister, intptr_t pair_index=0)
 
PRINT_OPERANDS_TO_SUPPORT DECLARE_ATTRIBUTEvalue ()
 
- Public Member Functions inherited from dart::TemplateDefinition< 0, NoThrow, Pure >
 TemplateDefinition (intptr_t deopt_id=DeoptId::kNone)
 
 TemplateDefinition (const InstructionSource &source, intptr_t deopt_id=DeoptId::kNone)
 
virtual intptr_t InputCount () const
 
virtual ValueInputAt (intptr_t i) const
 
virtual bool MayThrow () const
 

Additional Inherited Members

- Public Types inherited from dart::TemplateDefinition< 0, NoThrow, Pure >
using BaseClass = typename Pure< Definition, PureDefinition >::Base
 
- Protected Attributes inherited from dart::TemplateDefinition< 0, NoThrow, Pure >
EmbeddedArray< Value *, Ninputs_
 

Detailed Description

Definition at line 4201 of file il.h.

Constructor & Destructor Documentation

◆ ConstantInstr() [1/2]

dart::ConstantInstr::ConstantInstr ( const Object value)
inlineexplicit

Definition at line 4203 of file il.h.

4204 : ConstantInstr(value, InstructionSource(TokenPosition::kConstant)) {}
const Object & value() const
Definition il.h:4212
ConstantInstr(const Object &value)
Definition il.h:4203

◆ ConstantInstr() [2/2]

dart::ConstantInstr::ConstantInstr ( const Object value,
const InstructionSource source 
)

Definition at line 1130 of file il.cc.

1132 : TemplateDefinition(source), value_(value), token_pos_(source.token_pos) {
1133 // Check that the value is not an incorrect Integer representation.
1134 ASSERT(!value.IsMint() || !Smi::IsValid(Mint::Cast(value).AsInt64Value()));
1135 // Check that clones of fields are not stored as constants.
1136 ASSERT(!value.IsField() || Field::Cast(value).IsOriginal());
1137 // Check that all non-Smi objects are heap allocated and in old space.
1138 ASSERT(value.IsSmi() || value.IsOld());
1139#if defined(DEBUG)
1140 // Generally, instances in the flow graph should be canonical. Smis, null
1141 // values, and sentinel values are canonical by construction and so we skip
1142 // them here.
1143 if (!value.IsNull() && !value.IsSmi() && value.IsInstance() &&
1144 !value.IsCanonical() && (value.ptr() != Object::sentinel().ptr())) {
1145 // Arrays in ConstantInstrs are usually immutable and canonicalized, but
1146 // the Arrays created as backing for ArgumentsDescriptors may not be
1147 // canonicalized for space reasons when inlined in the IL. However, they
1148 // are still immutable.
1149 //
1150 // IRRegExp compilation uses TypeData non-canonical values as "constants".
1151 // Specifically, the bit tables used for certain character classes are
1152 // represented as TypedData, and so those values are also neither immutable
1153 // (as there are no immutable TypedData values) or canonical.
1154 //
1155 // LibraryPrefixes are also never canonicalized since their equality is
1156 // their identity.
1157 ASSERT(value.IsArray() || value.IsTypedData() || value.IsLibraryPrefix());
1158 }
1159#endif
1160}
ObjectPtr ptr() const
Definition object.h:332
bool IsCanonical() const
Definition object.h:335
bool IsOld() const
Definition object.h:391
bool IsNull() const
Definition object.h:363
static bool IsValid(int64_t value)
Definition object.h:10005
TemplateDefinition(intptr_t deopt_id=DeoptId::kNone)
Definition il.h:2731
#define ASSERT(E)
SkBitmap source
Definition examples.cpp:28

Member Function Documentation

◆ AttributesEqual()

bool dart::ConstantInstr::AttributesEqual ( const Instruction other) const
virtual

Definition at line 1162 of file il.cc.

1162 {
1163 auto const other_constant = other.AsConstant();
1164 ASSERT(other_constant != nullptr);
1165 return (value().ptr() == other_constant->value().ptr() &&
1166 representation() == other_constant->representation());
1167}

◆ Canonicalize()

Definition * dart::ConstantInstr::Canonicalize ( FlowGraph flow_graph)
virtual

Definition at line 2723 of file il.cc.

2723 {
2724 return HasUses() ? this : nullptr;
2725}

◆ ComputeCanDeoptimize()

virtual bool dart::ConstantInstr::ComputeCanDeoptimize ( ) const
inlinevirtual

Definition at line 4233 of file il.h.

4233{ return false; }

◆ ComputeType()

CompileType dart::ConstantInstr::ComputeType ( ) const
virtual

Definition at line 1349 of file type_propagator.cc.

1349 {
1350 if (value().IsNull()) {
1351 return CompileType::Null();
1352 }
1353
1354 intptr_t cid = value().GetClassId();
1355
1356 if (cid == kSmiCid && !compiler::target::IsSmi(Smi::Cast(value()).Value())) {
1357 return CompileType(CompileType::kCannotBeNull,
1360 }
1361
1362 if ((cid != kTypeArgumentsCid) && value().IsInstance()) {
1363 // Allocate in old-space since this may be invoked from the
1364 // background compiler.
1365 return CompileType(
1366 cid == kNullCid, cid == kSentinelCid, cid,
1367 &AbstractType::ZoneHandle(Instance::Cast(value()).GetType(Heap::kOld)));
1368 } else {
1369 // Type info for non-instance objects.
1370 return CompileType::FromCid(cid);
1371 }
1372}
static CompileType FromCid(intptr_t cid)
static constexpr bool kCannotBeSentinel
static constexpr bool kCannotBeNull
static CompileType Null()
@ kOld
Definition heap.h:39
intptr_t GetClassId() const
Definition object.h:341
static Object & ZoneHandle()
Definition object.h:419
static TypePtr MintType()
Definition object.cc:21898
bool IsSmi(int64_t v)
DART_EXPORT bool IsNull(Dart_Handle object)
@ kNullCid
Definition class_id.h:252
const intptr_t cid
static Dart_TypedData_Type GetType(intptr_t class_id)

◆ EmitMoveToLocation()

void dart::ConstantInstr::EmitMoveToLocation ( FlowGraphCompiler compiler,
const Location destination,
Register  tmp = kNoRegister,
intptr_t  pair_index = 0 
)

◆ HasZeroRepresentation()

bool dart::ConstantInstr::HasZeroRepresentation ( ) const
inline

Definition at line 4216 of file il.h.

4216 {
4217 switch (representation()) {
4218 case kTagged:
4219 case kUnboxedUint8:
4220 case kUnboxedUint16:
4221 case kUnboxedUint32:
4222 case kUnboxedInt32:
4223 case kUnboxedInt64:
4224 return IsSmi() && compiler::target::SmiValue(value()) == 0;
4225 case kUnboxedDouble:
4227 bit_cast<uint64_t>(compiler::target::DoubleValue(value())) == 0;
4228 default:
4229 return false;
4230 }
4231 }
bool IsSmi() const
Definition il.h:4214
double DoubleValue(const dart::Object &a)
bool IsDouble(const dart::Object &a)
word SmiValue(const dart::Object &a)

◆ InferRange()

void dart::ConstantInstr::InferRange ( RangeAnalysis analysis,
Range range 
)
virtual

Definition at line 2793 of file range_analysis.cc.

2793 {
2794 if (value_.IsSmi()) {
2795 int64_t value = Smi::Cast(value_).Value();
2796 *range = Range(RangeBoundary::FromConstant(value),
2798 } else if (value_.IsMint()) {
2799 int64_t value = Mint::Cast(value_).value();
2800 *range = Range(RangeBoundary::FromConstant(value),
2802 } else {
2803 // Only Smi and Mint supported.
2804 FATAL("Unexpected constant: %s\n", value_.ToCString());
2805 }
2806}
static RangeBoundary FromConstant(int64_t val)
#define FATAL(error)

◆ IsSmi()

bool dart::ConstantInstr::IsSmi ( ) const
inline

Definition at line 4214 of file il.h.

4214{ return compiler::target::IsSmi(value()); }

◆ token_pos()

virtual TokenPosition dart::ConstantInstr::token_pos ( ) const
inlinevirtual

Definition at line 4239 of file il.h.

4239{ return token_pos_; }

◆ value() [1/2]

PRINT_OPERANDS_TO_SUPPORT DECLARE_ATTRIBUTE & dart::ConstantInstr::value ( )

◆ value() [2/2]

const Object & dart::ConstantInstr::value ( ) const
inline

Definition at line 4212 of file il.h.

4212{ return value_; }

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