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

This reverts commit eebc219bab.

Reason for revert: performance regressions

Original change's description:
> [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>

Change-Id: I9576bc4b385b5d0e0b728556defedb4962ec0a8a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359842
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
Alexander Markov 2024-03-26 14:25:38 +00:00 committed by Commit Queue
parent 77d10f2ed9
commit 28258e54fd
5 changed files with 1931 additions and 1845 deletions

File diff suppressed because it is too large Load diff

View file

@ -135,6 +135,37 @@ 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,17 +78,14 @@ 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);
@ -186,32 +183,6 @@ 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,6 +78,13 @@ 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;
}