From 74d4e1fe753a5cf38ea2cd7d5463cd3c095ad308 Mon Sep 17 00:00:00 2001 From: "kmillikin@google.com" Date: Wed, 13 Mar 2013 10:06:14 +0000 Subject: [PATCH] Remove virtual functions on class InliningContext. There is only one implementation of InliningContext, so there is no need for virtual dispatch. R=fschneider@google.com Review URL: https://codereview.chromium.org//12518009 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19917 260f80e4-7a28-3924-810f-c04153c831b5 --- runtime/vm/flow_graph_builder.cc | 17 +++++-------- runtime/vm/flow_graph_builder.h | 41 +++++++++--------------------- runtime/vm/flow_graph_inliner.cc | 6 ++--- runtime/vm/intermediate_language.h | 2 +- 4 files changed, 22 insertions(+), 44 deletions(-) diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc index 1dd68304016..f9ebe6a39cb 100644 --- a/runtime/vm/flow_graph_builder.cc +++ b/runtime/vm/flow_graph_builder.cc @@ -62,11 +62,6 @@ void FlowGraphBuilder::AddCatchEntry(CatchBlockEntryInstr* entry) { } -InliningContext* InliningContext::Create(Definition* call) { - return new ValueInliningContext(); -} - - void InliningContext::PrepareGraphs(FlowGraph* caller_graph, Definition* call, FlowGraph* callee_graph) { @@ -97,18 +92,18 @@ void InliningContext::PrepareGraphs(FlowGraph* caller_graph, } -void ValueInliningContext::AddExit(ReturnInstr* exit) { +void InliningContext::AddExit(ReturnInstr* exit) { Data data = { NULL, exit }; exits_.Add(data); } -int ValueInliningContext::LowestBlockIdFirst(const Data* a, const Data* b) { +int InliningContext::LowestBlockIdFirst(const Data* a, const Data* b) { return (a->exit_block->block_id() - b->exit_block->block_id()); } -void ValueInliningContext::SortExits() { +void InliningContext::SortExits() { // Assign block entries here because we did not necessarily know them when // the return exit was added to the array. for (int i = 0; i < exits_.length(); ++i) { @@ -118,9 +113,9 @@ void ValueInliningContext::SortExits() { } -void ValueInliningContext::ReplaceCall(FlowGraph* caller_graph, - Definition* call, - FlowGraph* callee_graph) { +void InliningContext::ReplaceCall(FlowGraph* caller_graph, + Definition* call, + FlowGraph* callee_graph) { ASSERT(call->previous() != NULL); ASSERT(call->next() != NULL); PrepareGraphs(caller_graph, call, callee_graph); diff --git a/runtime/vm/flow_graph_builder.h b/runtime/vm/flow_graph_builder.h index 8c710f1e7d5..78a9460307f 100644 --- a/runtime/vm/flow_graph_builder.h +++ b/runtime/vm/flow_graph_builder.h @@ -16,14 +16,13 @@ class FlowGraph; class Instruction; class ParsedFunction; -// An abstraction of the graph context in which an inlined call occurs. -class InliningContext: public ZoneAllocated { +// An InliningContext collects the exits from an inlined function during +// graph construction so they can be plugged into the caller's flow graph. +class InliningContext: public ValueObject { public: - // Create the appropriate inlining context for the flow graph context of a - // call. - static InliningContext* Create(Definition* call); + InliningContext() : exits_(4) { } - virtual void AddExit(ReturnInstr* exit) = 0; + void AddExit(ReturnInstr* exit); // Inline a flow graph at a call site. // @@ -33,29 +32,9 @@ class InliningContext: public ZoneAllocated { // // After inlining the caller graph will correctly have adjusted the // pre/post orders, the dominator tree and the use lists. - virtual void ReplaceCall(FlowGraph* caller_graph, - Definition* call, - FlowGraph* callee_graph) = 0; - - protected: - static void PrepareGraphs(FlowGraph* caller_graph, - Definition* call, - FlowGraph* callee_graph); -}; - - -// The context of a call inlined for its value (including calls inlined for -// their effects, i.e., when the value is ignored). Collects normal exit -// blocks and return values. -class ValueInliningContext: public InliningContext { - public: - ValueInliningContext() : exits_(4) { } - - virtual void AddExit(ReturnInstr* exit); - - virtual void ReplaceCall(FlowGraph* caller_graph, - Definition* call, - FlowGraph* callee_graph); + void ReplaceCall(FlowGraph* caller_graph, + Definition* call, + FlowGraph* callee_graph); private: struct Data { @@ -63,6 +42,10 @@ class ValueInliningContext: public InliningContext { ReturnInstr* exit_return; }; + static void PrepareGraphs(FlowGraph* caller_graph, + Definition* call, + FlowGraph* callee_graph); + BlockEntryInstr* ExitBlockAt(intptr_t i) const { ASSERT(exits_[i].exit_block != NULL); return exits_[i].exit_block; diff --git a/runtime/vm/flow_graph_inliner.cc b/runtime/vm/flow_graph_inliner.cc index ebc2053968a..5de42248f05 100644 --- a/runtime/vm/flow_graph_inliner.cc +++ b/runtime/vm/flow_graph_inliner.cc @@ -436,8 +436,8 @@ class CallSiteInliner : public ValueObject { } // Build the callee graph. - InliningContext* inlining_context = InliningContext::Create(call); - FlowGraphBuilder builder(*parsed_function, inlining_context); + InliningContext inlining_context; + FlowGraphBuilder builder(*parsed_function, &inlining_context); builder.SetInitialBlockId(caller_graph_->max_block_id()); FlowGraph* callee_graph; { @@ -559,7 +559,7 @@ class CallSiteInliner : public ValueObject { isolate); // Plug result in the caller graph. - inlining_context->ReplaceCall(caller_graph_, call, callee_graph); + inlining_context.ReplaceCall(caller_graph_, call, callee_graph); // Replace each stub with the actual argument or the caller's constant. // Nulls denote optional parameters for which no actual was given. diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h index ad1cba0e366..027c4867334 100644 --- a/runtime/vm/intermediate_language.h +++ b/runtime/vm/intermediate_language.h @@ -1156,7 +1156,7 @@ class JoinEntryInstr : public BlockEntryInstr { private: // Classes that have access to predecessors_ when inlining. friend class BlockEntryInstr; - friend class ValueInliningContext; + friend class InliningContext; // Direct access to phis_ in order to resize it due to phi elimination. friend class ConstantPropagator;