Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 13932005: Refactor the code for making inlining decisions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/flow_graph_builder.cc
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc
index 00b3932c09bf4f402d252214d97b851dfc199de4..d24afa480080d664a212bfdc0897565283740878 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -41,7 +41,7 @@ static const String& PrivateCoreLibName(const String& str) {
FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function,
- InliningContext* inlining_context)
+ InlineExitCollector* exit_collector)
: parsed_function_(parsed_function),
num_copied_params_(parsed_function.num_copied_params()),
// All parameters are copied if any parameter is.
@@ -49,7 +49,7 @@ FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function,
? parsed_function.function().num_fixed_parameters()
: 0),
num_stack_locals_(parsed_function.num_stack_locals()),
- inlining_context_(inlining_context),
+ exit_collector_(exit_collector),
last_used_block_id_(0), // 0 is used for the graph entry.
context_level_(0),
last_used_try_index_(CatchClauseNode::kInvalidTryIndex),
@@ -62,7 +62,7 @@ void FlowGraphBuilder::AddCatchEntry(CatchBlockEntryInstr* entry) {
}
-void InliningContext::PrepareGraphs(FlowGraph* callee_graph) {
+void InlineExitCollector::PrepareGraphs(FlowGraph* callee_graph) {
ASSERT(callee_graph->graph_entry()->SuccessorCount() == 1);
ASSERT(callee_graph->max_block_id() > caller_graph_->max_block_id());
ASSERT(callee_graph->max_virtual_register_number() >
@@ -90,18 +90,18 @@ void InliningContext::PrepareGraphs(FlowGraph* callee_graph) {
}
-void InliningContext::AddExit(ReturnInstr* exit) {
+void InlineExitCollector::AddExit(ReturnInstr* exit) {
Data data = { NULL, exit };
exits_.Add(data);
}
-int InliningContext::LowestBlockIdFirst(const Data* a, const Data* b) {
+int InlineExitCollector::LowestBlockIdFirst(const Data* a, const Data* b) {
return (a->exit_block->block_id() - b->exit_block->block_id());
}
-void InliningContext::SortExits() {
+void InlineExitCollector::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) {
@@ -111,8 +111,8 @@ void InliningContext::SortExits() {
}
-Definition* InliningContext::JoinReturns(BlockEntryInstr** exit_block,
- Instruction** last_instruction) {
+Definition* InlineExitCollector::JoinReturns(BlockEntryInstr** exit_block,
+ Instruction** last_instruction) {
// First sort the list of exits by block id (caching return instruction
// block entries as a side effect).
SortExits();
@@ -217,13 +217,10 @@ Definition* InliningContext::JoinReturns(BlockEntryInstr** exit_block,
}
-void InliningContext::ReplaceCall(FlowGraph* callee_graph) {
+void InlineExitCollector::ReplaceCall(TargetEntryInstr* callee_entry) {
ASSERT(call_->previous() != NULL);
ASSERT(call_->next() != NULL);
- PrepareGraphs(callee_graph);
-
BlockEntryInstr* call_block = call_->GetBlock();
- TargetEntryInstr* callee_entry = callee_graph->graph_entry()->normal_entry();
// Insert the callee graph into the caller graph.
BlockEntryInstr* callee_exit = NULL;
@@ -350,9 +347,9 @@ void EffectGraphVisitor::AddReturnExit(intptr_t token_pos, Value* value) {
ASSERT(is_open());
ReturnInstr* return_instr = new ReturnInstr(token_pos, value);
AddInstruction(return_instr);
- InliningContext* inlining_context = owner()->inlining_context();
- if (inlining_context != NULL) {
- inlining_context->AddExit(return_instr);
+ InlineExitCollector* exit_collector = owner()->exit_collector();
+ if (exit_collector != NULL) {
+ exit_collector->AddExit(return_instr);
}
CloseFragment();
}
@@ -710,7 +707,7 @@ void EffectGraphVisitor::Bailout(const char* reason) {
void EffectGraphVisitor::InlineBailout(const char* reason) {
owner()->parsed_function().function().set_is_inlinable(false);
- if (owner()->InInliningContext()) owner()->Bailout(reason);
+ if (owner()->IsInlining()) owner()->Bailout(reason);
}
@@ -3390,8 +3387,8 @@ FlowGraph* FlowGraphBuilder::BuildGraph() {
// stack check on entry for leaf routines).
Instruction* check = new CheckStackOverflowInstr(function.token_pos());
// If we are inlining don't actually attach the stack check. We must still
- // create the stack check inorder to allocate a deopt id.
- if (!InInliningContext()) for_effect.AddInstruction(check);
+ // create the stack check in order to allocate a deopt id.
+ if (!IsInlining()) for_effect.AddInstruction(check);
parsed_function().node_sequence()->Visit(&for_effect);
AppendFragment(normal_entry, for_effect);
// Check that the graph is properly terminated.

Powered by Google App Engine
This is Rietveld 408576698