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
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user