Flutter Engine
The Flutter Engine
Public Member Functions | Private Member Functions | List of all members
dart::BranchInstr Class Reference

#include <il.h>

Inheritance diagram for dart::BranchInstr:
dart::Instruction dart::ZoneAllocated

Public Member Functions

 BranchInstr (ComparisonInstr *comparison, intptr_t deopt_id)
 
virtual intptr_t ArgumentCount () const
 
virtual void SetMoveArguments (MoveArgumentsArray *move_arguments)
 
virtual MoveArgumentsArrayGetMoveArguments () const
 
intptr_t InputCount () const
 
ValueInputAt (intptr_t i) const
 
virtual TokenPosition token_pos () const
 
virtual intptr_t inlining_id () const
 
virtual void set_inlining_id (intptr_t value)
 
virtual bool has_inlining_id () const
 
virtual bool ComputeCanDeoptimize () const
 
virtual bool CanBecomeDeoptimizationTarget () const
 
virtual bool HasUnknownSideEffects () const
 
virtual bool CanCallDart () const
 
ComparisonInstrcomparison () const
 
void SetComparison (ComparisonInstr *comp)
 
virtual intptr_t DeoptimizationTarget () const
 
virtual Representation RequiredInputRepresentation (intptr_t i) const
 
virtual InstructionCanonicalize (FlowGraph *flow_graph)
 
void set_constant_target (TargetEntryInstr *target)
 
TargetEntryInstrconstant_target () const
 
virtual void CopyDeoptIdFrom (const Instruction &instr)
 
virtual bool MayThrow () const
 
TargetEntryInstrtrue_successor () const
 
TargetEntryInstrfalse_successor () const
 
TargetEntryInstr ** true_successor_address ()
 
TargetEntryInstr ** false_successor_address ()
 
virtual intptr_t SuccessorCount () const
 
virtual BlockEntryInstrSuccessorAt (intptr_t index) 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)
 

Private Member Functions

virtual void RawSetInputAt (intptr_t i, Value *value)
 

Additional Inherited Members

- 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::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::Instruction
static const intptr_t kInstructionAttrs [kNumInstructions]
 
- 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)
 

Detailed Description

Definition at line 3972 of file il.h.

Constructor & Destructor Documentation

◆ BranchInstr()

dart::BranchInstr::BranchInstr ( ComparisonInstr comparison,
intptr_t  deopt_id 
)
inlineexplicit

Definition at line 3974 of file il.h.

3975 : Instruction(deopt_id), comparison_(comparison) {
3976 ASSERT(comparison->env() == nullptr);
3977 for (intptr_t i = comparison->InputCount() - 1; i >= 0; --i) {
3979 }
3980 }
ComparisonInstr * comparison() const
Definition: il.h:4021
virtual intptr_t InputCount() const =0
Instruction(const InstructionSource &source, intptr_t deopt_id=DeoptId::kNone)
Definition: il.h:980
virtual Value * InputAt(intptr_t i) const =0
Environment * env() const
Definition: il.h:1215
intptr_t deopt_id() const
Definition: il.h:993
void set_instruction(Instruction *instruction)
Definition: il.h:122
#define ASSERT(E)

Member Function Documentation

◆ ArgumentCount()

virtual intptr_t dart::BranchInstr::ArgumentCount ( ) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 3984 of file il.h.

3984 {
3985 return comparison()->ArgumentCount();
3986 }
virtual intptr_t ArgumentCount() const
Definition: il.h:1041

◆ CanBecomeDeoptimizationTarget()

virtual bool dart::BranchInstr::CanBecomeDeoptimizationTarget ( ) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 4011 of file il.h.

4011 {
4013 }
virtual bool CanBecomeDeoptimizationTarget() const
Definition: il.h:3882

◆ CanCallDart()

virtual bool dart::BranchInstr::CanCallDart ( ) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 4019 of file il.h.

4019{ return comparison()->CanCallDart(); }
virtual bool CanCallDart() const
Definition: il.h:1304

◆ Canonicalize()

Instruction * dart::BranchInstr::Canonicalize ( FlowGraph flow_graph)
virtual

Reimplemented from dart::Instruction.

Definition at line 3654 of file il.cc.

3654 {
3655 Zone* zone = flow_graph->zone();
3656 if (comparison()->IsStrictCompare()) {
3657 bool negated = false;
3658 Definition* replacement = CanonicalizeStrictCompare(
3659 comparison()->AsStrictCompare(), &negated, /*is_branch=*/true);
3660 if (replacement == comparison()) {
3661 return this;
3662 }
3663 ComparisonInstr* comp = replacement->AsComparison();
3664 if ((comp == nullptr) || comp->CanDeoptimize() ||
3665 comp->HasUnmatchedInputRepresentations()) {
3666 return this;
3667 }
3668
3669 // Replace the comparison if the replacement is used at this branch,
3670 // and has exactly one use.
3671 Value* use = comp->input_use_list();
3672 if ((use->instruction() == this) && comp->HasOnlyUse(use)) {
3673 if (negated) {
3674 comp->NegateComparison();
3675 }
3677 flow_graph->CopyDeoptTarget(this, comp);
3678 // Unlink environment from the comparison since it is copied to the
3679 // branch instruction.
3680 comp->RemoveEnvironment();
3681
3682 comp->RemoveFromGraph();
3683 SetComparison(comp);
3684 if (FLAG_trace_optimization && flow_graph->should_print()) {
3685 THR_Print("Merging comparison v%" Pd "\n", comp->ssa_temp_index());
3686 }
3687 // Clear the comparison's temp index and ssa temp index since the
3688 // value of the comparison is not used outside the branch anymore.
3689 ASSERT(comp->input_use_list() == nullptr);
3690 comp->ClearSSATempIndex();
3691 comp->ClearTempIndex();
3692 }
3693
3694 return this;
3695 }
3696
3697 if (comparison()->IsEqualityCompare() &&
3698 (comparison()->operation_cid() == kSmiCid ||
3699 comparison()->operation_cid() == kMintCid)) {
3700 const auto representation =
3701 comparison()->operation_cid() == kSmiCid ? kTagged : kUnboxedInt64;
3703 BinaryIntegerOpInstr* bit_and = nullptr;
3704 bool negate = false;
3706 &negate)) {
3707 bit_and = comparison()->left()->definition()->AsBinaryIntegerOp();
3708 } else if (RecognizeTestPattern(comparison()->right(),
3709 comparison()->left(), &negate)) {
3710 bit_and = comparison()->right()->definition()->AsBinaryIntegerOp();
3711 }
3712 if (bit_and != nullptr) {
3713 if (FLAG_trace_optimization && flow_graph->should_print()) {
3714 THR_Print("Merging test integer v%" Pd "\n",
3715 bit_and->ssa_temp_index());
3716 }
3717 TestIntInstr* test = new TestIntInstr(
3718 comparison()->source(),
3719 negate ? Token::NegateComparison(comparison()->kind())
3720 : comparison()->kind(),
3721 representation, bit_and->left()->Copy(zone),
3722 bit_and->right()->Copy(zone));
3725 flow_graph->CopyDeoptTarget(this, bit_and);
3727 bit_and->RemoveFromGraph();
3728 }
3729 }
3730 }
3731 return this;
3732}
void SetComparison(ComparisonInstr *comp)
Definition: il.cc:1672
intptr_t operation_cid() const
Definition: il.h:3878
Value * right() const
Definition: il.h:3847
Value * left() const
Definition: il.h:3846
void RemoveEnvironment()
Definition: il.cc:1282
virtual Representation representation() const
Definition: il.h:1260
bool CanDeoptimize() const
Definition: il.h:1079
friend class ComparisonInstr
Definition: il.h:1401
InstructionSource source() const
Definition: il.h:1008
static bool IsSupported(Representation representation)
Definition: il.h:5188
static Token::Kind NegateComparison(Token::Kind op)
Definition: token.h:322
Definition * definition() const
Definition: il.h:103
#define THR_Print(format,...)
Definition: log.h:20
static Definition * CanonicalizeStrictCompare(StrictCompareInstr *compare, bool *negated, bool is_branch)
Definition: il.cc:3562
static bool RecognizeTestPattern(Value *left, Value *right, bool *negate)
Definition: il.cc:3620
#define Pd
Definition: globals.h:408

◆ comparison()

ComparisonInstr * dart::BranchInstr::comparison ( ) const
inline

Definition at line 4021 of file il.h.

4021{ return comparison_; }

◆ ComputeCanDeoptimize()

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

Implements dart::Instruction.

Definition at line 4007 of file il.h.

4007 {
4008 return comparison()->ComputeCanDeoptimize();
4009 }
virtual bool ComputeCanDeoptimize() const =0

◆ constant_target()

TargetEntryInstr * dart::BranchInstr::constant_target ( ) const
inline

Definition at line 4038 of file il.h.

4038{ return constant_target_; }

◆ CopyDeoptIdFrom()

virtual void dart::BranchInstr::CopyDeoptIdFrom ( const Instruction instr)
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 4040 of file il.h.

4040 {
4042 comparison()->CopyDeoptIdFrom(instr);
4043 }
virtual void CopyDeoptIdFrom(const Instruction &instr)
Definition: il.h:1411

◆ DeoptimizationTarget()

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

Reimplemented from dart::Instruction.

Definition at line 4024 of file il.h.

4024 {
4025 return comparison()->DeoptimizationTarget();
4026 }
virtual intptr_t DeoptimizationTarget() const
Definition: il.h:3883

◆ false_successor()

TargetEntryInstr * dart::BranchInstr::false_successor ( ) const
inline

Definition at line 4048 of file il.h.

4048{ return false_successor_; }

◆ false_successor_address()

TargetEntryInstr ** dart::BranchInstr::false_successor_address ( )
inline

Definition at line 4051 of file il.h.

4051{ return &false_successor_; }

◆ GetMoveArguments()

virtual MoveArgumentsArray * dart::BranchInstr::GetMoveArguments ( ) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 3990 of file il.h.

3990 {
3991 return comparison()->GetMoveArguments();
3992 }
virtual MoveArgumentsArray * GetMoveArguments() const
Definition: il.h:1050

◆ has_inlining_id()

virtual bool dart::BranchInstr::has_inlining_id ( ) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 4003 of file il.h.

4003 {
4004 return comparison_->has_inlining_id();
4005 }

◆ HasUnknownSideEffects()

virtual bool dart::BranchInstr::HasUnknownSideEffects ( ) const
inlinevirtual

Implements dart::Instruction.

Definition at line 4015 of file il.h.

4015 {
4017 }
virtual bool HasUnknownSideEffects() const =0

◆ inlining_id()

virtual intptr_t dart::BranchInstr::inlining_id ( ) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 3999 of file il.h.

3999{ return comparison_->inlining_id(); }

◆ InputAt()

Value * dart::BranchInstr::InputAt ( intptr_t  i) const
inlinevirtual

Implements dart::Instruction.

Definition at line 3996 of file il.h.

3996{ return comparison()->InputAt(i); }

◆ InputCount()

intptr_t dart::BranchInstr::InputCount ( ) const
inlinevirtual

Implements dart::Instruction.

Definition at line 3994 of file il.h.

3994{ return comparison()->InputCount(); }

◆ MayThrow()

virtual bool dart::BranchInstr::MayThrow ( ) const
inlinevirtual

Implements dart::Instruction.

Definition at line 4045 of file il.h.

4045{ return comparison()->MayThrow(); }
virtual bool MayThrow() const =0

◆ RawSetInputAt()

virtual void dart::BranchInstr::RawSetInputAt ( intptr_t  i,
Value value 
)
inlineprivatevirtual

Implements dart::Instruction.

Definition at line 4065 of file il.h.

4065 {
4066 comparison()->RawSetInputAt(i, value);
4067 }
uint8_t value

◆ RequiredInputRepresentation()

virtual Representation dart::BranchInstr::RequiredInputRepresentation ( intptr_t  i) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 4028 of file il.h.

4028 {
4030 }
virtual Representation RequiredInputRepresentation(intptr_t idx) const
Definition: il.h:1241

◆ set_constant_target()

void dart::BranchInstr::set_constant_target ( TargetEntryInstr target)
inline

Definition at line 4034 of file il.h.

4034 {
4036 constant_target_ = target;
4037 }
TargetEntryInstr * false_successor() const
Definition: il.h:4048
TargetEntryInstr * true_successor() const
Definition: il.h:4047
uint32_t * target

◆ set_inlining_id()

virtual void dart::BranchInstr::set_inlining_id ( intptr_t  value)
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 4000 of file il.h.

4000 {
4001 return comparison_->set_inlining_id(value);
4002 }

◆ SetComparison()

void dart::BranchInstr::SetComparison ( ComparisonInstr comp)

Definition at line 1672 of file il.cc.

1672 {
1673 for (intptr_t i = new_comparison->InputCount() - 1; i >= 0; --i) {
1674 Value* input = new_comparison->InputAt(i);
1675 input->definition()->AddInputUse(input);
1676 input->set_instruction(this);
1677 }
1678 // There should be no need to copy or unuse an environment.
1679 ASSERT(comparison()->env() == nullptr);
1680 ASSERT(new_comparison->env() == nullptr);
1681 // Remove the current comparison's input uses.
1683 ASSERT(!new_comparison->HasUses());
1684 comparison_ = new_comparison;
1685}
void UnuseAllInputs()
Definition: il.cc:1534

◆ SetMoveArguments()

virtual void dart::BranchInstr::SetMoveArguments ( MoveArgumentsArray move_arguments)
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 3987 of file il.h.

3987 {
3988 comparison()->SetMoveArguments(move_arguments);
3989 }
virtual void SetMoveArguments(MoveArgumentsArray *move_arguments)
Definition: il.h:1046

◆ SuccessorAt()

BlockEntryInstr * dart::BranchInstr::SuccessorAt ( intptr_t  index) const
virtual

Reimplemented from dart::Instruction.

Definition at line 2014 of file il.cc.

2014 {
2015 if (index == 0) return true_successor_;
2016 if (index == 1) return false_successor_;
2017 UNREACHABLE();
2018 return nullptr;
2019}
#define UNREACHABLE()
Definition: assert.h:248

◆ SuccessorCount()

intptr_t dart::BranchInstr::SuccessorCount ( ) const
virtual

Reimplemented from dart::Instruction.

Definition at line 2010 of file il.cc.

2010 {
2011 return 2;
2012}

◆ token_pos()

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

Reimplemented from dart::Instruction.

Definition at line 3998 of file il.h.

3998{ return comparison_->token_pos(); }

◆ true_successor()

TargetEntryInstr * dart::BranchInstr::true_successor ( ) const
inline

Definition at line 4047 of file il.h.

4047{ return true_successor_; }

◆ true_successor_address()

TargetEntryInstr ** dart::BranchInstr::true_successor_address ( )
inline

Definition at line 4050 of file il.h.

4050{ return &true_successor_; }

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