Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
dart::IntConverterInstr Class Reference

#include <il.h>

Inheritance diagram for dart::IntConverterInstr:
dart::TemplateDefinition< 1, NoThrow, Pure > dart::PureDefinition dart::Definition dart::Instruction dart::ZoneAllocated

Public Member Functions

 IntConverterInstr (Representation from, Representation to, Value *value, intptr_t deopt_id)
 
Valuevalue () const
 
Representation from () const
 
Representation to () const
 
bool is_truncating () const
 
void mark_truncating ()
 
DefinitionCanonicalize (FlowGraph *flow_graph)
 
virtual bool ComputeCanDeoptimize () const
 
virtual Representation representation () const
 
virtual Representation RequiredInputRepresentation (intptr_t idx) const
 
virtual bool AttributesEqual (const Instruction &other) const
 
virtual intptr_t DeoptimizationTarget () const
 
virtual void InferRange (RangeAnalysis *analysis, Range *range)
 
virtual bool MayCreateUnsafeUntaggedPointer () const
 
 DECLARE_INSTRUCTION (IntConverter)
 
 DECLARE_ATTRIBUTES_NAMED (("from", "to", "is_truncating"),(from(), to(), is_truncating())) PRINT_OPERANDS_TO_SUPPORT DECLARE_INSTRUCTION_SERIALIZABLE_FIELDS(IntConverterInstr
 
- Public Member Functions inherited from dart::TemplateDefinition< 1, 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)
 

Public Attributes

 TemplateDefinition
 

Additional Inherited Members

- Public Types inherited from dart::TemplateDefinition< 1, 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< 1, NoThrow, Pure >
EmbeddedArray< Value *, Ninputs_
 
- Protected Attributes inherited from dart::Definition
Rangerange_ = nullptr
 

Detailed Description

Definition at line 11018 of file il.h.

Constructor & Destructor Documentation

◆ IntConverterInstr()

dart::IntConverterInstr::IntConverterInstr ( Representation  from,
Representation  to,
Value value,
intptr_t  deopt_id 
)
inline

Definition at line 11020 of file il.h.

11025 from_representation_(from),
11026 to_representation_(to),
11027 is_truncating_(to == kUnboxedUint32) {
11028 ASSERT(from != to);
11029 // Integer conversion doesn't currently handle non-native representations.
11032 ASSERT(from == kUnboxedInt64 || from == kUnboxedUint32 ||
11033 from == kUnboxedInt32 || from == kUntagged);
11034 ASSERT(to == kUnboxedInt64 || to == kUnboxedUint32 || to == kUnboxedInt32 ||
11035 to == kUntagged);
11036 ASSERT(from != kUntagged || to == kUnboxedIntPtr || to == kUnboxedAddress);
11037 ASSERT(to != kUntagged || from == kUnboxedIntPtr ||
11039 // Don't allow conversions from unsafe untagged addresses.
11041 SetInputAt(0, value);
11042 }
#define ASSERT_EQUAL(expected, actual)
Definition: assert.h:309
virtual bool MayCreateUnsafeUntaggedPointer() const
Definition: il.h:2591
void SetInputAt(intptr_t i, Value *value)
Definition: il.h:1014
intptr_t deopt_id() const
Definition: il.h:993
Value * value() const
Definition: il.h:11044
Representation to() const
Definition: il.h:11047
Representation from() const
Definition: il.h:11046
Definition * definition() const
Definition: il.h:103
#define ASSERT(E)
static constexpr Representation kUnboxedAddress
Definition: locations.h:182
static constexpr Representation kUnboxedIntPtr
Definition: locations.h:176
static constexpr Representation NativeRepresentation(Representation rep)
Definition: il.h:8504

Member Function Documentation

◆ AttributesEqual()

virtual bool dart::IntConverterInstr::AttributesEqual ( const Instruction other) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 11063 of file il.h.

11063 {
11064 ASSERT(other.IsIntConverter());
11065 auto const converter = other.AsIntConverter();
11066 return (converter->from() == from()) && (converter->to() == to()) &&
11067 (converter->is_truncating() == is_truncating());
11068 }
bool is_truncating() const
Definition: il.h:11048
string converter
Definition: cacheimages.py:19

◆ Canonicalize()

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

Reimplemented from dart::Definition.

Definition at line 3447 of file il.cc.

3447 {
3448 if (!HasUses()) return nullptr;
3449
3450 // Fold IntConverter({Unboxed}Constant(...)) to UnboxedConstant.
3451 if (auto constant = value()->definition()->AsConstant()) {
3452 if (from() != kUntagged && to() != kUntagged &&
3453 constant->representation() == from() && constant->value().IsInteger()) {
3454 const int64_t value = Integer::Cast(constant->value()).AsInt64Value();
3455 const int64_t result =
3457 if (is_truncating() || (value == result)) {
3459 box ^= box.Canonicalize(flow_graph->thread());
3460 return flow_graph->GetConstant(box, to());
3461 }
3462 }
3463 }
3464
3465 // Fold IntCoverter(b->c, IntConverter(a->b, v)) into IntConverter(a->c, v).
3466 IntConverterInstr* first_converter = value()->definition()->AsIntConverter();
3467 if ((first_converter != nullptr) &&
3468 (first_converter->representation() == from())) {
3469 const auto intermediate_rep = first_converter->representation();
3470 // Only eliminate intermediate conversion if it does not change the value.
3471 auto src_defn = first_converter->value()->definition();
3472 if (intermediate_rep == kUntagged) {
3473 // Both conversions are no-ops, as the other representations must be
3474 // kUnboxedIntPtr.
3475 } else if (!Range::Fits(src_defn->range(), intermediate_rep)) {
3476 return this;
3477 }
3478
3479 // Otherwise it is safe to discard any other conversions from and then back
3480 // to the same integer type.
3481 if (first_converter->from() == to()) {
3482 return src_defn;
3483 }
3484
3485 // Do not merge conversions where the first starts from Untagged or the
3486 // second ends at Untagged, since we expect to see either UnboxedIntPtr
3487 // or UnboxedFfiIntPtr as the other type in an Untagged conversion.
3488 if ((first_converter->from() == kUntagged) || (to() == kUntagged)) {
3489 return this;
3490 }
3491
3493 first_converter->from(), representation(),
3494 first_converter->value()->CopyWithType(),
3495 (to() == kUnboxedInt32) ? GetDeoptId() : DeoptId::kNone);
3496 if ((representation() == kUnboxedInt32) && is_truncating()) {
3497 converter->mark_truncating();
3498 }
3499 flow_graph->InsertBefore(this, converter, env(), FlowGraph::kValue);
3500 return converter;
3501 }
3502
3503 UnboxInt64Instr* unbox_defn = value()->definition()->AsUnboxInt64();
3504 if (unbox_defn != nullptr && (from() == kUnboxedInt64) &&
3505 (to() == kUnboxedInt32) && unbox_defn->HasOnlyInputUse(value())) {
3506 // TODO(vegorov): there is a duplication of code between UnboxedIntConverter
3507 // and code path that unboxes Mint into Int32. We should just schedule
3508 // these instructions close to each other instead of fusing them.
3509 Definition* replacement =
3510 new UnboxInt32Instr(is_truncating() ? UnboxInt32Instr::kTruncate
3512 unbox_defn->value()->CopyWithType(), GetDeoptId());
3513 flow_graph->InsertBefore(this, replacement, env(), FlowGraph::kValue);
3514 return replacement;
3515 }
3516
3517 return this;
3518}
bool HasUses() const
Definition: il.h:2569
Definition(intptr_t deopt_id=DeoptId::kNone)
Definition: il.h:2488
static constexpr intptr_t kNone
Definition: deopt_id.h:27
static int64_t TruncateTo(int64_t v, Representation r)
Definition: evaluator.cc:81
@ kOld
Definition: heap.h:39
intptr_t GetDeoptId() const
Definition: il.h:1409
Environment * env() const
Definition: il.h:1215
virtual Representation representation() const
Definition: il.h:1260
IntConverterInstr(Representation from, Representation to, Value *value, intptr_t deopt_id)
Definition: il.h:11020
virtual Representation representation() const
Definition: il.h:11056
static IntegerPtr New(const String &str, Heap::Space space=Heap::kNew)
Definition: object.cc:22984
static Object & Handle()
Definition: object.h:407
bool Fits(RangeBoundary::RangeSize size) const
GAsyncResult * result

◆ ComputeCanDeoptimize()

bool dart::IntConverterInstr::ComputeCanDeoptimize ( ) const
virtual

Implements dart::Instruction.

Definition at line 2034 of file il.cc.

2034 {
2035 return (to() == kUnboxedInt32) && !is_truncating() &&
2036 !RangeUtils::Fits(value()->definition()->range(),
2038}
Range * range() const
Definition: il.h:2636
static bool Fits(Range *range, RangeBoundary::RangeSize size)

◆ DECLARE_ATTRIBUTES_NAMED()

dart::IntConverterInstr::DECLARE_ATTRIBUTES_NAMED ( ("from", "to", "is_truncating")  ,
(from(), to(), is_truncating())   
)

◆ DECLARE_INSTRUCTION()

dart::IntConverterInstr::DECLARE_INSTRUCTION ( IntConverter  )

◆ DeoptimizationTarget()

virtual intptr_t dart::IntConverterInstr::DeoptimizationTarget ( ) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 11070 of file il.h.

11070{ return GetDeoptId(); }

◆ from()

Representation dart::IntConverterInstr::from ( ) const
inline

Definition at line 11046 of file il.h.

11046{ return from_representation_; }

◆ InferRange()

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

Reimplemented from dart::Definition.

Definition at line 3102 of file range_analysis.cc.

3102 {
3103 ASSERT(to() != kUntagged); // Not an integer-valued definition.
3106
3107 const Range* const value_range = value()->definition()->range();
3108 const Range to_range = Range::Full(to());
3109
3110 if (from() == kUntagged) {
3111 ASSERT(value_range == nullptr); // Not an integer-valued definition.
3112 *range = to_range;
3113 } else if (Range::IsUnknown(value_range)) {
3114 *range = to_range;
3115 } else if (RepresentationUtils::ValueSize(to()) >
3119 // All signed unboxed ints of larger sizes can represent all values for
3120 // signed or unsigned unboxed ints of smaller sizes, and all unsigned
3121 // unboxed ints of larger sizes can represent all values for unsigned
3122 // boxed ints of smaller sizes.
3123 *range = *value_range;
3124 } else if (is_truncating()) {
3125 // Either the bits are being reinterpreted (if the two representations
3126 // are the same size) or a larger value is being truncated. That means
3127 // we need to determine whether or not the value range lies within the
3128 // range of numbers that have the same representation (modulo truncation).
3129 const Range common_range = Range::Full(from()).Intersect(&to_range);
3130 if (value_range->IsWithin(&common_range)) {
3131 *range = *value_range;
3132 } else {
3133 // In most cases, if there are non-representable values, then no
3134 // assumptions can be made about the converted value.
3135 *range = to_range;
3136 }
3137 } else {
3138 // The conversion deoptimizes if the value is outside the range represented
3139 // by to(), so we can just take the intersection.
3140 *range = value_range->Intersect(&to_range);
3141 }
3142
3144}
Range Intersect(const Range *other) const
static bool IsUnknown(const Range *other)
static Range Full(RangeBoundary::RangeSize size)
#define ASSERT_VALID_RANGE_FOR_REPRESENTATION(instr, range, representation)
static constexpr size_t ValueSize(Representation rep)
Definition: locations.h:112
static constexpr bool IsUnboxedInteger(Representation rep)
Definition: locations.h:92
static bool IsUnsignedInteger(Representation rep)
Definition: locations.h:126

◆ is_truncating()

bool dart::IntConverterInstr::is_truncating ( ) const
inline

Definition at line 11048 of file il.h.

11048{ return is_truncating_; }

◆ mark_truncating()

void dart::IntConverterInstr::mark_truncating ( )
inline

Definition at line 11050 of file il.h.

11050{ is_truncating_ = true; }

◆ MayCreateUnsafeUntaggedPointer()

virtual bool dart::IntConverterInstr::MayCreateUnsafeUntaggedPointer ( ) const
inlinevirtual

Reimplemented from dart::Definition.

Definition at line 11074 of file il.h.

11074 {
11075 // The compiler no longer converts between unsafe untagged pointers and
11076 // unboxed integers.
11077 return false;
11078 }

◆ representation()

virtual Representation dart::IntConverterInstr::representation ( ) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 11056 of file il.h.

11056{ return to(); }

◆ RequiredInputRepresentation()

virtual Representation dart::IntConverterInstr::RequiredInputRepresentation ( intptr_t  idx) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 11058 of file il.h.

11058 {
11059 ASSERT(idx == 0);
11060 return from();
11061 }

◆ to()

Representation dart::IntConverterInstr::to ( ) const
inline

Definition at line 11047 of file il.h.

11047{ return to_representation_; }

◆ value()

Value * dart::IntConverterInstr::value ( ) const
inline

Definition at line 11044 of file il.h.

11044{ return inputs_[0]; }
EmbeddedArray< Value *, N > inputs_
Definition: il.h:2762

Member Data Documentation

◆ TemplateDefinition

dart::IntConverterInstr::TemplateDefinition

Definition at line 11093 of file il.h.


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