Flutter Engine
The Flutter Engine
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::PureDefinition dart::Definition dart::Instruction dart::ZoneAllocated 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
 
- Public Member Functions inherited from dart::PureDefinition
 PureDefinition (intptr_t deopt_id)
 
 PureDefinition (const InstructionSource &source, intptr_t deopt_id)
 
virtual bool AllowsCSE () const
 
virtual bool HasUnknownSideEffects () const
 
- Public Member Functions inherited from dart::Definition
 Definition (intptr_t deopt_id=DeoptId::kNone)
 
 Definition (const InstructionSource &source, intptr_t deopt_id=DeoptId::kNone)
 
virtual intptr_t CallCount () const
 
intptr_t temp_index () const
 
void set_temp_index (intptr_t index)
 
void ClearTempIndex ()
 
bool HasTemp () const
 
intptr_t ssa_temp_index () const
 
void set_ssa_temp_index (intptr_t index)
 
bool HasSSATemp () const
 
void ClearSSATempIndex ()
 
intptr_t vreg (intptr_t index) const
 
intptr_t location_count () const
 
bool HasPairRepresentation () const
 
CompileTypeType ()
 
bool HasType () const
 
bool IsInt64Definition ()
 
bool IsInt32Definition ()
 
virtual CompileType ComputeType () const
 
virtual bool RecomputeType ()
 
PRINT_OPERANDS_TO_SUPPORT PRINT_TO_SUPPORT bool UpdateType (CompileType new_type)
 
bool HasUses () const
 
bool HasOnlyUse (Value *use) const
 
bool HasOnlyInputUse (Value *use) const
 
Valueinput_use_list () const
 
void set_input_use_list (Value *head)
 
Valueenv_use_list () const
 
void set_env_use_list (Value *head)
 
ValueListIterable input_uses () const
 
void AddInputUse (Value *value)
 
void AddEnvUse (Value *value)
 
virtual bool MayCreateUnsafeUntaggedPointer () const
 
virtual bool CanReplaceWithConstant () const
 
virtual bool CanEliminate (const BlockEntryInstr *block) const
 
void ReplaceUsesWith (Definition *other)
 
void ReplaceWithResult (Instruction *replacement, Definition *replacement_for_uses, ForwardInstructionIterator *iterator)
 
void ReplaceWith (Definition *other, ForwardInstructionIterator *iterator)
 
Objectconstant_value ()
 
virtual void InferRange (RangeAnalysis *analysis, Range *range)
 
Rangerange () const
 
void set_range (const Range &)
 
virtual DefinitionCanonicalize (FlowGraph *flow_graph)
 
DefinitionReplacement ()
 
void SetReplacement (Definition *other)
 
virtual AliasIdentity Identity () const
 
virtual void SetIdentity (AliasIdentity identity)
 
DefinitionOriginalDefinition ()
 
virtual ValueRedefinedValue () const
 
DefinitionOriginalDefinitionIgnoreBoxingAndConstraints ()
 
virtual DefinitionAsDefinition ()
 
virtual const DefinitionAsDefinition () const
 
- Public Member Functions inherited from dart::Instruction
 Instruction (const InstructionSource &source, intptr_t deopt_id=DeoptId::kNone)
 
 Instruction (intptr_t deopt_id=DeoptId::kNone)
 
virtual ~Instruction ()
 
virtual Tag tag () const =0
 
virtual intptr_t statistics_tag () const
 
intptr_t deopt_id () const
 
virtual TokenPosition token_pos () const
 
InstructionSource source () const
 
virtual intptr_t InputCount () const =0
 
virtual ValueInputAt (intptr_t i) const =0
 
void SetInputAt (intptr_t i, Value *value)
 
InputsIterable inputs ()
 
void UnuseAllInputs ()
 
virtual intptr_t ArgumentCount () const
 
ValueArgumentValueAt (intptr_t index) const
 
DefinitionArgumentAt (intptr_t index) const
 
virtual void SetMoveArguments (MoveArgumentsArray *move_arguments)
 
virtual MoveArgumentsArrayGetMoveArguments () const
 
virtual void ReplaceInputsWithMoveArguments (MoveArgumentsArray *move_arguments)
 
bool HasMoveArguments () const
 
void RepairArgumentUsesInEnvironment () const
 
virtual bool ComputeCanDeoptimize () const =0
 
virtual bool ComputeCanDeoptimizeAfterCall () const
 
bool CanDeoptimize () const
 
virtual void Accept (InstructionVisitor *visitor)=0
 
Instructionprevious () const
 
void set_previous (Instruction *instr)
 
Instructionnext () const
 
void set_next (Instruction *instr)
 
void LinkTo (Instruction *next)
 
InstructionRemoveFromGraph (bool return_previous=true)
 
virtual intptr_t SuccessorCount () const
 
virtual BlockEntryInstrSuccessorAt (intptr_t index) const
 
SuccessorsIterable successors () const
 
void Goto (JoinEntryInstr *entry)
 
virtual const char * DebugName () const =0
 
void CheckField (const Field &field) const
 
const char * ToCString () const
 
 DECLARE_INSTRUCTION_TYPE_CHECK (BlockEntryWithInitialDefs, BlockEntryWithInitialDefs) template< typename T > T *Cast()
 
template<typename T >
const TCast () const
 
LocationSummarylocs ()
 
bool HasLocs () const
 
virtual LocationSummaryMakeLocationSummary (Zone *zone, bool is_optimizing) const =0
 
void InitializeLocationSummary (Zone *zone, bool optimizing)
 
virtual void EmitNativeCode (FlowGraphCompiler *compiler)
 
Environmentenv () const
 
void SetEnvironment (Environment *deopt_env)
 
void RemoveEnvironment ()
 
void ReplaceInEnvironment (Definition *current, Definition *replacement)
 
virtual intptr_t NumberOfInputsConsumedBeforeCall () const
 
intptr_t GetPassSpecificId (CompilerPass::Id pass) const
 
void SetPassSpecificId (CompilerPass::Id pass, intptr_t id)
 
bool HasPassSpecificId (CompilerPass::Id pass) const
 
bool HasUnmatchedInputRepresentations () const
 
virtual Representation RequiredInputRepresentation (intptr_t idx) const
 
SpeculativeMode SpeculativeModeOfInputs () const
 
virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const
 
virtual Representation representation () const
 
bool WasEliminated () const
 
virtual intptr_t DeoptimizationTarget () const
 
virtual InstructionCanonicalize (FlowGraph *flow_graph)
 
void InsertBefore (Instruction *next)
 
void InsertAfter (Instruction *prev)
 
InstructionAppendInstruction (Instruction *tail)
 
virtual bool AllowsCSE () const
 
virtual bool HasUnknownSideEffects () const =0
 
virtual bool CanCallDart () const
 
virtual bool CanTriggerGC () const
 
virtual BlockEntryInstrGetBlock ()
 
virtual intptr_t inlining_id () const
 
virtual void set_inlining_id (intptr_t value)
 
virtual bool has_inlining_id () const
 
virtual uword Hash () const
 
bool Equals (const Instruction &other) const
 
virtual bool AttributesEqual (const Instruction &other) const
 
void InheritDeoptTarget (Zone *zone, Instruction *other)
 
bool NeedsEnvironment () const
 
virtual bool CanBecomeDeoptimizationTarget () const
 
void InheritDeoptTargetAfter (FlowGraph *flow_graph, Definition *call, Definition *result)
 
virtual bool MayThrow () const =0
 
virtual bool MayHaveVisibleEffect () const
 
virtual bool CanEliminate (const BlockEntryInstr *block) const
 
bool CanEliminate ()
 
bool IsDominatedBy (Instruction *dom)
 
void ClearEnv ()
 
void Unsupported (FlowGraphCompiler *compiler)
 
virtual bool UseSharedSlowPathStub (bool is_optimizing) const
 
Location::Kind RegisterKindForResult () const
 
- 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

- Public Types inherited from dart::TemplateDefinition< 0, NoThrow, Pure >
using BaseClass = typename Pure< Definition, PureDefinition >::Base
 
- Public Types inherited from dart::Instruction
enum  Tag { FOR_EACH_INSTRUCTION =(DECLARE_TAG) kNumInstructions }
 
enum  SpeculativeMode { kGuardInputs , kNotSpeculative }
 
using InputsIterable = InstructionIndexedPropertyIterable< InputsTrait >
 
using SuccessorsIterable = InstructionIndexedPropertyIterable< SuccessorsTrait >
 
- Static Public Member Functions inherited from dart::Definition
static bool IsArrayLength (Definition *def)
 
- Static Public Member Functions inherited from dart::Instruction
static const ICDataGetICData (const ZoneGrowableArray< const ICData * > &ic_data_array, intptr_t deopt_id, bool is_static_call)
 
static LocationSummaryMakeCallSummary (Zone *zone, const Instruction *instr, LocationSummary *locs=nullptr)
 
static bool SlowPathSharingSupported (bool is_optimizing)
 
- Static Public Attributes inherited from dart::Definition
static constexpr intptr_t kReplacementMarker = -2
 
- Static Public Attributes inherited from dart::Instruction
static const intptr_t kInstructionAttrs [kNumInstructions]
 
- Protected Member Functions inherited from dart::Definition
void set_type (CompileType *type)
 
- Protected Member Functions inherited from dart::Instruction
intptr_t GetDeoptId () const
 
virtual void CopyDeoptIdFrom (const Instruction &instr)
 
void WriteExtraWithoutInputs (FlowGraphSerializer *s)
 
void ReadExtraWithoutInputs (FlowGraphDeserializer *d)
 
- Protected Attributes inherited from dart::TemplateDefinition< 0, NoThrow, Pure >
EmbeddedArray< Value *, Ninputs_
 
- Protected Attributes inherited from dart::Definition
Rangerange_ = nullptr
 

Detailed Description

Definition at line 4219 of file il.h.

Constructor & Destructor Documentation

◆ ConstantInstr() [1/2]

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

Definition at line 4221 of file il.h.

4222 : ConstantInstr(value, InstructionSource(TokenPosition::kConstant)) {}
const Object & value() const
Definition: il.h:4230
ConstantInstr(const Object &value)
Definition: il.h:4221

◆ ConstantInstr() [2/2]

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

Definition at line 1132 of file il.cc.

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

Member Function Documentation

◆ AttributesEqual()

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

Reimplemented from dart::Instruction.

Definition at line 1164 of file il.cc.

1164 {
1165 auto const other_constant = other.AsConstant();
1166 ASSERT(other_constant != nullptr);
1167 return (value().ptr() == other_constant->value().ptr() &&
1168 representation() == other_constant->representation());
1169}
virtual Representation representation() const
Definition: il.h:1260

◆ Canonicalize()

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

Reimplemented from dart::Definition.

Definition at line 2732 of file il.cc.

2732 {
2733 return HasUses() ? this : nullptr;
2734}
bool HasUses() const
Definition: il.h:2569

◆ ComputeCanDeoptimize()

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

Implements dart::Instruction.

Definition at line 4251 of file il.h.

4251{ return false; }

◆ ComputeType()

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

Reimplemented from dart::Definition.

Definition at line 1348 of file type_propagator.cc.

1348 {
1349 if (value().IsNull()) {
1350 return CompileType::Null();
1351 }
1352
1353 intptr_t cid = value().GetClassId();
1354
1355 if (cid == kSmiCid && !compiler::target::IsSmi(Smi::Cast(value()).Value())) {
1356 return CompileType(CompileType::kCannotBeNull,
1359 }
1360
1361 if ((cid != kTypeArgumentsCid) && value().IsInstance()) {
1362 // Allocate in old-space since this may be invoked from the
1363 // background compiler.
1364 return CompileType(
1365 cid == kNullCid, cid == kSentinelCid, cid,
1366 &AbstractType::ZoneHandle(Instance::Cast(value()).GetType(Heap::kOld)));
1367 } else {
1368 // Type info for non-instance objects.
1369 return CompileType::FromCid(cid);
1370 }
1371}
static CompileType FromCid(intptr_t cid)
static constexpr bool kCannotBeSentinel
Definition: compile_type.h:49
static constexpr bool kCannotBeNull
Definition: compile_type.h:46
static CompileType Null()
friend class Value
Definition: il.h:2690
@ kOld
Definition: heap.h:39
intptr_t GetClassId() const
Definition: object.h:341
static Object & ZoneHandle()
Definition: object.h:419
static TypePtr MintType()
bool IsSmi(int64_t v)
Definition: runtime_api.cc:31
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 4234 of file il.h.

4234 {
4235 switch (representation()) {
4236 case kTagged:
4237 case kUnboxedUint8:
4238 case kUnboxedUint16:
4239 case kUnboxedUint32:
4240 case kUnboxedInt32:
4241 case kUnboxedInt64:
4242 return IsSmi() && compiler::target::SmiValue(value()) == 0;
4243 case kUnboxedDouble:
4245 bit_cast<uint64_t>(compiler::target::DoubleValue(value())) == 0;
4246 default:
4247 return false;
4248 }
4249 }
bool IsSmi() const
Definition: il.h:4232
double DoubleValue(const dart::Object &a)
Definition: runtime_api.cc:978
bool IsDouble(const dart::Object &a)
Definition: runtime_api.cc:974
word SmiValue(const dart::Object &a)
Definition: runtime_api.cc:969

◆ InferRange()

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

Reimplemented from dart::Definition.

Definition at line 2793 of file range_analysis.cc.

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

◆ IsSmi()

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

Definition at line 4232 of file il.h.

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

◆ token_pos()

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

Reimplemented from dart::Instruction.

Definition at line 4257 of file il.h.

4257{ 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 4230 of file il.h.

4230{ return value_; }

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