Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
dart::UnboxIntegerInstr Class Reference

#include <il.h>

Inheritance diagram for dart::UnboxIntegerInstr:
dart::UnboxInstr dart::TemplateDefinition< 1, NoThrow, Pure > dart::PureDefinition dart::Definition dart::Instruction dart::ZoneAllocated dart::UnboxInt64Instr dart::UnboxInteger32Instr dart::UnboxInt32Instr dart::UnboxUint32Instr

Public Types

enum  TruncationMode { kTruncate , kNoTruncation }
 
- 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 >
 

Public Member Functions

 UnboxIntegerInstr (Representation representation, TruncationMode truncation_mode, Value *value, intptr_t deopt_id, SpeculativeMode speculative_mode)
 
bool is_truncating () const
 
void mark_truncating ()
 
virtual bool ComputeCanDeoptimize () const
 
virtual bool AttributesEqual (const Instruction &other) const
 
virtual DefinitionCanonicalize (FlowGraph *flow_graph)
 
virtual void InferRange (RangeAnalysis *analysis, Range *range)
 
- Public Member Functions inherited from dart::UnboxInstr
Valuevalue () const
 
virtual bool ComputeCanDeoptimize () const
 
virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const
 
virtual Representation representation () const
 
virtual bool AttributesEqual (const Instruction &other) const
 
DefinitionCanonicalize (FlowGraph *flow_graph)
 
virtual intptr_t DeoptimizationTarget () const
 
virtual TokenPosition token_pos () const
 
 DECLARE_INSTRUCTION_SERIALIZABLE_FIELDS (UnboxInstr, TemplateDefinition, FIELD_LIST) protected
 
void set_speculative_mode (SpeculativeMode value)
 
- 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)
 

Additional Inherited Members

- Static Public Member Functions inherited from dart::UnboxInstr
static UnboxInstrCreate (Representation to, Value *value, intptr_t deopt_id, SpeculativeMode speculative_mode=kGuardInputs)
 
- 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 8760 of file il.h.

Member Enumeration Documentation

◆ TruncationMode

Enumerator
kTruncate 
kNoTruncation 

Definition at line 8762 of file il.h.

Constructor & Destructor Documentation

◆ UnboxIntegerInstr()

dart::UnboxIntegerInstr::UnboxIntegerInstr ( Representation  representation,
TruncationMode  truncation_mode,
Value value,
intptr_t  deopt_id,
SpeculativeMode  speculative_mode 
)
inline

Definition at line 8764 of file il.h.

8769 : UnboxInstr(representation, value, deopt_id, speculative_mode),
8770 is_truncating_(truncation_mode == kTruncate) {}
intptr_t deopt_id() const
Definition: il.h:993
virtual Representation representation() const
Definition: il.h:8703
Value * value() const
Definition: il.h:8678

Member Function Documentation

◆ AttributesEqual()

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

Reimplemented from dart::UnboxInstr.

Definition at line 8778 of file il.h.

8778 {
8779 auto const other_unbox = other.AsUnboxInteger();
8780 return UnboxInstr::AttributesEqual(other) &&
8781 (other_unbox->is_truncating_ == is_truncating_);
8782 }
virtual bool AttributesEqual(const Instruction &other) const
Definition: il.h:8707

◆ Canonicalize()

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

Reimplemented from dart::UnboxInstr.

Definition at line 3376 of file il.cc.

3376 {
3377 if (!HasUses() && !CanDeoptimize()) return nullptr;
3378
3379 // Fold away Unbox<rep>(v) if v has a target representation already.
3380 Definition* value_defn = value()->definition();
3381 if (value_defn->representation() == representation()) {
3382 return value_defn;
3383 }
3384
3385 // Do not attempt to fold this instruction if we have not matched
3386 // input/output representations yet.
3388 return this;
3389 }
3390
3391 // Fold away UnboxInteger<rep_to>(BoxInteger<rep_from>(v)).
3392 BoxIntegerInstr* box_defn = value()->definition()->AsBoxInteger();
3393 if (box_defn != nullptr && !box_defn->HasUnmatchedInputRepresentations()) {
3394 Representation from_representation =
3395 box_defn->value()->definition()->representation();
3396 if (from_representation == representation()) {
3397 return box_defn->value()->definition();
3398 } else {
3399 // Only operate on explicit unboxed operands.
3400 IntConverterInstr* converter = new IntConverterInstr(
3401 from_representation, representation(),
3402 box_defn->value()->CopyWithType(),
3403 (representation() == kUnboxedInt32) ? GetDeoptId() : DeoptId::kNone);
3404 // TODO(vegorov): marking resulting converter as truncating when
3405 // unboxing can't deoptimize is a workaround for the missing
3406 // deoptimization environment when we insert converter after
3407 // EliminateEnvironments and there is a mismatch between predicates
3408 // UnboxIntConverterInstr::CanDeoptimize and UnboxInt32::CanDeoptimize.
3409 if ((representation() == kUnboxedInt32) &&
3410 (is_truncating() || !CanDeoptimize())) {
3411 converter->mark_truncating();
3412 }
3413 flow_graph->InsertBefore(this, converter, env(), FlowGraph::kValue);
3414 return converter;
3415 }
3416 }
3417
3419 // Remember if we ever learn out input doesn't require checking, as
3420 // the input Value might be later changed that would make us forget.
3422 }
3423
3424 if (value()->BindsToConstant()) {
3425 const auto& obj = value()->BoundConstant();
3426 if (obj.IsInteger()) {
3427 if (representation() == kUnboxedInt64) {
3428 return flow_graph->GetConstant(obj, representation());
3429 }
3430 const int64_t intval = Integer::Cast(obj).AsInt64Value();
3432 return flow_graph->GetConstant(obj, representation());
3433 }
3434 if (is_truncating()) {
3435 const int64_t result = Evaluator::TruncateTo(intval, representation());
3436 return flow_graph->GetConstant(
3437 Integer::ZoneHandle(flow_graph->zone(),
3439 representation());
3440 }
3441 }
3442 }
3443
3444 return this;
3445}
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
intptr_t GetDeoptId() const
Definition: il.h:1409
Environment * env() const
Definition: il.h:1215
@ kGuardInputs
Definition: il.h:972
@ kNotSpeculative
Definition: il.h:975
bool HasUnmatchedInputRepresentations() const
Definition: il.cc:1609
bool CanDeoptimize() const
Definition: il.h:1079
static IntegerPtr NewCanonical(const String &str)
Definition: object.cc:22999
static Object & ZoneHandle()
Definition: object.h:419
void set_speculative_mode(SpeculativeMode value)
Definition: il.h:8741
virtual SpeculativeMode SpeculativeModeOfInput(intptr_t index) const
Definition: il.h:8699
bool is_truncating() const
Definition: il.h:8772
virtual bool ComputeCanDeoptimize() const
Definition: il.cc:2040
const Object & BoundConstant() const
Definition: il.cc:1201
Definition * definition() const
Definition: il.h:103
GAsyncResult * result
string converter
Definition: cacheimages.py:19
Representation
Definition: locations.h:66
static bool IsRepresentable(Representation rep, int64_t value)
Definition: locations.cc:72

◆ ComputeCanDeoptimize()

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

Reimplemented from dart::UnboxInstr.

Definition at line 2040 of file il.cc.

2040 {
2042 return false;
2043 }
2044 if (!value()->Type()->IsInt()) {
2045 return true;
2046 }
2047 if (representation() == kUnboxedInt64 || is_truncating()) {
2048 return false;
2049 }
2050 const intptr_t rep_bitsize =
2052 if (value()->Type()->ToCid() == kSmiCid &&
2053 compiler::target::kSmiBits <= rep_bitsize) {
2054 return false;
2055 }
2056 return !RangeUtils::IsWithin(value()->definition()->range(),
2059}
Range * range() const
Definition: il.h:2636
CompileType * Type()
Definition: il.h:2521
SpeculativeMode SpeculativeModeOfInputs() const
Definition: il.h:1245
static bool IsWithin(const Range *range, int64_t min, int64_t max)
constexpr intptr_t kSmiBits
Definition: runtime_api.h:301
constexpr intptr_t kBitsPerByte
Definition: globals.h:463
static constexpr size_t ValueSize(Representation rep)
Definition: locations.h:112
static int64_t MaxValue(Representation rep)
Definition: locations.cc:62
static int64_t MinValue(Representation rep)
Definition: locations.cc:49

◆ InferRange()

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

Reimplemented from dart::Definition.

Definition at line 3080 of file range_analysis.cc.

3080 {
3081 auto* const value_range = value()->Type()->ToCid() == kSmiCid
3082 ? analysis->GetSmiRange(value())
3083 : value()->definition()->range();
3084 const Range to_range = Range::Full(representation());
3085
3086 if (Range::IsUnknown(value_range)) {
3087 *range = to_range;
3088 } else if (value_range->IsWithin(&to_range)) {
3089 *range = *value_range;
3090 } else if (is_truncating()) {
3091 // If truncating, then in most cases any non-representable values means
3092 // no assumption can be made about the truncated value.
3093 *range = to_range;
3094 } else {
3095 // When not truncating, then unboxing deoptimizes if the value is outside
3096 // the range representation.
3097 *range = value_range->Intersect(&to_range);
3098 }
3100}
Range Intersect(const Range *other) const
static bool IsUnknown(const Range *other)
static Range Full(RangeBoundary::RangeSize size)
CompileType * Type()
#define ASSERT_VALID_RANGE_FOR_REPRESENTATION(instr, range, representation)

◆ is_truncating()

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

Definition at line 8772 of file il.h.

8772{ return is_truncating_; }

◆ mark_truncating()

void dart::UnboxIntegerInstr::mark_truncating ( )
inline

Definition at line 8774 of file il.h.

8774{ is_truncating_ = true; }

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