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

#include <jit_call_specializer.h>

Inheritance diagram for dart::JitCallSpecializer:
dart::CallSpecializer dart::FlowGraphVisitor dart::InstructionVisitor dart::ValueObject

Public Member Functions

 JitCallSpecializer (FlowGraph *flow_graph, SpeculativeInliningPolicy *speculative_policy)
 
virtual ~JitCallSpecializer ()
 
virtual void VisitInstanceCall (InstanceCallInstr *instr)
 
virtual void VisitAllocateContext (AllocateContextInstr *instr)
 
virtual void VisitCloneContext (CloneContextInstr *instr)
 
- Public Member Functions inherited from dart::CallSpecializer
 CallSpecializer (FlowGraph *flow_graph, SpeculativeInliningPolicy *speculative_policy, bool should_clone_fields)
 
virtual ~CallSpecializer ()
 
FlowGraphflow_graph () const
 
void set_flow_graph (FlowGraph *flow_graph)
 
void ApplyICData ()
 
void ApplyClassIds ()
 
virtual void ReplaceInstanceCallsWithDispatchTableCalls ()
 
void InsertBefore (Instruction *next, Instruction *instr, Environment *env, FlowGraph::UseKind use_kind)
 
void InsertSpeculativeBefore (Instruction *next, Instruction *instr, Environment *env, FlowGraph::UseKind use_kind)
 
virtual void VisitStaticCall (StaticCallInstr *instr)
 
virtual void VisitLoadCodeUnits (LoadCodeUnitsInstr *instr)
 
- Public Member Functions inherited from dart::FlowGraphVisitor
 FlowGraphVisitor (const GrowableArray< BlockEntryInstr * > &block_order)
 
virtual ~FlowGraphVisitor ()
 
ForwardInstructionIteratorcurrent_iterator () const
 
virtual void VisitBlocks ()
 
- Public Member Functions inherited from dart::InstructionVisitor
 InstructionVisitor ()
 
virtual ~InstructionVisitor ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Private Member Functions

virtual bool IsAllowedForInlining (intptr_t deopt_id) const
 
virtual bool TryOptimizeStaticCallUsingStaticTypes (StaticCallInstr *call)
 

Additional Inherited Members

- Protected Member Functions inherited from dart::CallSpecializer
Threadthread () const
 
IsolateGroupisolate_group () const
 
Zonezone () const
 
const Functionfunction () const
 
bool TryReplaceWithBinaryOp (InstanceCallInstr *call, Token::Kind op_kind)
 
bool TryReplaceWithUnaryOp (InstanceCallInstr *call, Token::Kind op_kind)
 
bool TryReplaceWithEqualityOp (InstanceCallInstr *call, Token::Kind op_kind)
 
bool TryReplaceWithRelationalOp (InstanceCallInstr *call, Token::Kind op_kind)
 
bool TryInlineInstanceGetter (InstanceCallInstr *call)
 
bool TryInlineInstanceSetter (InstanceCallInstr *call)
 
bool TryInlineInstanceMethod (InstanceCallInstr *call)
 
void ReplaceWithInstanceOf (InstanceCallInstr *instr)
 
void ReplaceCallWithResult (Definition *call, Instruction *replacement, Definition *result)
 
void ReplaceCall (Definition *call, Definition *replacement)
 
void AddReceiverCheck (InstanceCallInstr *call)
 
void AddCheckNull (Value *to_check, const String &function_name, intptr_t deopt_id, Environment *deopt_environment, Instruction *insert_before)
 
virtual bool TryCreateICData (InstanceCallInstr *call)
 
virtual bool TryReplaceInstanceOfWithRangeCheck (InstanceCallInstr *call, const AbstractType &type)
 
void InlineImplicitInstanceGetter (Definition *call, const Field &field)
 
void AddCheckClass (Definition *to_check, const Cids &cids, intptr_t deopt_id, Environment *deopt_environment, Instruction *insert_before)
 
- Protected Member Functions inherited from dart::FlowGraphVisitor
void set_block_order (const GrowableArray< BlockEntryInstr * > &block_order)
 
- Protected Attributes inherited from dart::CallSpecializer
SpeculativeInliningPolicyspeculative_policy_
 
const bool should_clone_fields_
 
- Protected Attributes inherited from dart::FlowGraphVisitor
ForwardInstructionIteratorcurrent_iterator_
 

Detailed Description

Definition at line 16 of file jit_call_specializer.h.

Constructor & Destructor Documentation

◆ JitCallSpecializer()

dart::JitCallSpecializer::JitCallSpecializer ( FlowGraph flow_graph,
SpeculativeInliningPolicy speculative_policy 
)
explicit

Definition at line 32 of file jit_call_specializer.cc.

36 speculative_policy,
37 CompilerState::Current().should_clone_fields()) {}
FlowGraph * flow_graph() const
CallSpecializer(FlowGraph *flow_graph, SpeculativeInliningPolicy *speculative_policy, bool should_clone_fields)
static CompilerState & Current()

◆ ~JitCallSpecializer()

virtual dart::JitCallSpecializer::~JitCallSpecializer ( )
inlinevirtual

Definition at line 21 of file jit_call_specializer.h.

21{}

Member Function Documentation

◆ IsAllowedForInlining()

bool dart::JitCallSpecializer::IsAllowedForInlining ( intptr_t  deopt_id) const
privatevirtual

Definition at line 39 of file jit_call_specializer.cc.

39 {
40 return true;
41}

◆ TryOptimizeStaticCallUsingStaticTypes()

bool dart::JitCallSpecializer::TryOptimizeStaticCallUsingStaticTypes ( StaticCallInstr call)
privatevirtual

Implements dart::CallSpecializer.

Definition at line 43 of file jit_call_specializer.cc.

44 {
45 return false;
46}

◆ VisitAllocateContext()

void dart::JitCallSpecializer::VisitAllocateContext ( AllocateContextInstr instr)
virtual

Definition at line 210 of file jit_call_specializer.cc.

210 {
211 LowerContextAllocation(instr, instr->context_slots(), nullptr);
212}

◆ VisitCloneContext()

void dart::JitCallSpecializer::VisitCloneContext ( CloneContextInstr instr)
virtual

Definition at line 214 of file jit_call_specializer.cc.

214 {
215 LowerContextAllocation(instr, instr->context_slots(), instr->context_value());
216}

◆ VisitInstanceCall()

void dart::JitCallSpecializer::VisitInstanceCall ( InstanceCallInstr instr)
virtual

Definition at line 67 of file jit_call_specializer.cc.

67 {
68 const CallTargets& targets = instr->Targets();
69 if (targets.is_empty()) {
70 return; // No feedback.
71 }
72
73 const Token::Kind op_kind = instr->token_kind();
74
75 // Type test is special as it always gets converted into inlined code.
76 if (Token::IsTypeTestOperator(op_kind)) {
78 return;
79 }
80
81 if (op_kind == Token::kEQ && TryReplaceWithEqualityOp(instr, op_kind)) {
82 return;
83 }
84
85 if (Token::IsRelationalOperator(op_kind) &&
86 TryReplaceWithRelationalOp(instr, op_kind)) {
87 return;
88 }
89
90 if (Token::IsBinaryOperator(op_kind) &&
91 TryReplaceWithBinaryOp(instr, op_kind)) {
92 return;
93 }
94 if (Token::IsUnaryOperator(op_kind) &&
95 TryReplaceWithUnaryOp(instr, op_kind)) {
96 return;
97 }
98 if ((op_kind == Token::kGET) && TryInlineInstanceGetter(instr)) {
99 return;
100 }
101 if ((op_kind == Token::kSET) && TryInlineInstanceSetter(instr)) {
102 return;
103 }
104 if (TryInlineInstanceMethod(instr)) {
105 return;
106 }
107
108 bool has_one_target = targets.HasSingleTarget();
109 if (has_one_target) {
110 // Check if the single target is a polymorphic target, if it is,
111 // we don't have one target.
112 const Function& target = targets.FirstTarget();
113 if (target.recognized_kind() == MethodRecognizer::kObjectRuntimeType) {
115 targets) != Type::null();
116 } else {
117 has_one_target = !target.is_polymorphic_target();
118 }
119 }
120
121 if (has_one_target) {
122 const Function& target = targets.FirstTarget();
123 if (flow_graph()->CheckForInstanceCall(instr, target.kind()) ==
125 ReplaceWithStaticCall(instr, target, targets.AggregateCallCount());
126 return;
127 }
128 }
129
130 // If there is only one target we can make this into a deopting class check,
131 // followed by a call instruction that does not check the class of the
132 // receiver. This enables a lot of optimizations because after the class
133 // check we can probably inline the call and not worry about side effects.
134 // However, this can fall down if new receiver classes arrive at this call
135 // site after we generated optimized code. This causes a deopt, and after a
136 // few deopts we won't optimize this function any more at all. Therefore for
137 // very polymorphic sites we don't make this optimization, keeping it as a
138 // regular checked PolymorphicInstanceCall, which falls back to the slow but
139 // non-deopting megamorphic call stub when it sees new receiver classes.
140 if (has_one_target && FLAG_polymorphic_with_deopt &&
141 (!instr->ic_data()->HasDeoptReason(ICData::kDeoptCheckClass) ||
142 targets.length() <= FLAG_max_polymorphic_checks)) {
143 // Type propagation has not run yet, we cannot eliminate the check.
144 AddReceiverCheck(instr);
145
146 // Call can still deoptimize, do not detach environment from instr.
147 const Function& target = targets.FirstTarget();
148 ReplaceWithStaticCall(instr, target, targets.AggregateCallCount());
149 } else {
150 PolymorphicInstanceCallInstr* call =
152 /* complete = */ false);
153 instr->ReplaceWith(call, current_iterator());
154 }
155}
#define Z
void AddReceiverCheck(InstanceCallInstr *call)
bool TryReplaceWithEqualityOp(InstanceCallInstr *call, Token::Kind op_kind)
bool TryInlineInstanceSetter(InstanceCallInstr *call)
bool TryInlineInstanceGetter(InstanceCallInstr *call)
bool TryReplaceWithRelationalOp(InstanceCallInstr *call, Token::Kind op_kind)
bool TryReplaceWithUnaryOp(InstanceCallInstr *call, Token::Kind op_kind)
void ReplaceWithInstanceOf(InstanceCallInstr *instr)
bool TryReplaceWithBinaryOp(InstanceCallInstr *call, Token::Kind op_kind)
bool TryInlineInstanceMethod(InstanceCallInstr *call)
ForwardInstructionIterator * current_iterator() const
Definition il.h:11792
static ObjectPtr null()
Definition object.h:433
static TypePtr ComputeRuntimeType(const CallTargets &targets)
Definition il.cc:5570
static PolymorphicInstanceCallInstr * FromCall(Zone *zone, InstanceCallBaseInstr *call, const CallTargets &targets, bool complete)
Definition il.h:4906
static bool IsTypeTestOperator(Kind tok)
Definition token.h:244
static bool IsRelationalOperator(Kind tok)
Definition token.h:232
static bool IsBinaryOperator(Token::Kind token)
Definition token.cc:31
static bool IsUnaryOperator(Token::Kind token)
Definition token.cc:41
uint32_t * target
call(args)
Definition dom.py:159

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