[vm/compiler] Move handling of recognized methods from inliner to call specializer

This refactoring reduces number of places where recognized methods are
handled and cleans up general-purpose inliner pass.

The code is mostly moved as is to simplify reviewing, with a notable
exception: in a few places handling of recognized method calls is
removed as it duplicates handling performed during call specialization
passes (ApplyClassIds and ApplyICData) which run both before and after
inlining.

TEST=ci

Change-Id: I8d53d23587beb09e6edf64ee95524f6ad3e060de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358221
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov 2024-03-25 20:58:15 +00:00 committed by Commit Queue
parent 403040c2f7
commit eebc219bab
5 changed files with 1845 additions and 1931 deletions

File diff suppressed because it is too large Load diff

View file

@ -135,37 +135,6 @@ class FlowGraphInliner : ValueObject {
return speculative_policy_;
}
struct ExactnessInfo {
const bool is_exact;
bool emit_exactness_guard;
};
static bool TryReplaceInstanceCallWithInline(
FlowGraph* flow_graph,
ForwardInstructionIterator* iterator,
InstanceCallInstr* call,
SpeculativeInliningPolicy* policy);
static bool TryReplaceStaticCallWithInline(
FlowGraph* flow_graph,
ForwardInstructionIterator* iterator,
StaticCallInstr* call,
SpeculativeInliningPolicy* policy);
static bool TryInlineRecognizedMethod(FlowGraph* flow_graph,
intptr_t receiver_cid,
const Function& target,
Definition* call,
Definition* receiver,
const InstructionSource& source,
const ICData* ic_data,
GraphEntryInstr* graph_entry,
FunctionEntryInstr** entry,
Instruction** last,
Definition** result,
SpeculativeInliningPolicy* policy,
ExactnessInfo* exactness = nullptr);
private:
friend class CallSiteInliner;

File diff suppressed because it is too large Load diff

View file

@ -78,14 +78,17 @@ class CallSpecializer : public FlowGraphVisitor {
// Find a better place for them.
virtual void VisitLoadCodeUnits(LoadCodeUnitsInstr* instr);
struct ExactnessInfo {
const bool is_exact;
bool emit_exactness_guard;
};
protected:
Thread* thread() const { return flow_graph_->thread(); }
IsolateGroup* isolate_group() const { return flow_graph_->isolate_group(); }
Zone* zone() const { return flow_graph_->zone(); }
const Function& function() const { return flow_graph_->function(); }
bool TryReplaceWithIndexedOp(InstanceCallInstr* call);
bool TryReplaceWithBinaryOp(InstanceCallInstr* call, Token::Kind op_kind);
bool TryReplaceWithUnaryOp(InstanceCallInstr* call, Token::Kind op_kind);
@ -183,6 +186,32 @@ class CallSpecializer : public FlowGraphVisitor {
ZoneGrowableArray<intptr_t>* results,
const AbstractType& type);
static bool TryReplaceInstanceCallWithInline(
FlowGraph* flow_graph,
ForwardInstructionIterator* iterator,
InstanceCallInstr* call,
SpeculativeInliningPolicy* policy);
static bool TryReplaceStaticCallWithInline(
FlowGraph* flow_graph,
ForwardInstructionIterator* iterator,
StaticCallInstr* call,
SpeculativeInliningPolicy* policy);
static bool TryInlineRecognizedMethod(FlowGraph* flow_graph,
intptr_t receiver_cid,
const Function& target,
Definition* call,
Definition* receiver,
const InstructionSource& source,
const ICData* ic_data,
GraphEntryInstr* graph_entry,
FunctionEntryInstr** entry,
Instruction** last,
Definition** result,
SpeculativeInliningPolicy* policy,
ExactnessInfo* exactness = nullptr);
FlowGraph* flow_graph_;
};

View file

@ -78,13 +78,6 @@ void JitCallSpecializer::VisitInstanceCall(InstanceCallInstr* instr) {
return;
}
if ((op_kind == Token::kASSIGN_INDEX) && TryReplaceWithIndexedOp(instr)) {
return;
}
if ((op_kind == Token::kINDEX) && TryReplaceWithIndexedOp(instr)) {
return;
}
if (op_kind == Token::kEQ && TryReplaceWithEqualityOp(instr, op_kind)) {
return;
}