Index: runtime/vm/flow_graph_inliner.cc |
=================================================================== |
--- runtime/vm/flow_graph_inliner.cc (revision 27690) |
+++ runtime/vm/flow_graph_inliner.cc (working copy) |
@@ -382,8 +382,7 @@ |
class CallSiteInliner : public ValueObject { |
public: |
- CallSiteInliner(FlowGraph* flow_graph, |
- GrowableArray<const Field*>* guarded_fields) |
+ explicit CallSiteInliner(FlowGraph* flow_graph) |
: caller_graph_(flow_graph), |
inlined_(false), |
initial_size_(flow_graph->InstructionCount()), |
@@ -391,8 +390,7 @@ |
inlining_depth_(1), |
collected_call_sites_(NULL), |
inlining_call_sites_(NULL), |
- function_cache_(), |
- guarded_fields_(guarded_fields) { } |
+ function_cache_() { } |
FlowGraph* caller_graph() const { return caller_graph_; } |
@@ -544,17 +542,19 @@ |
// Build the callee graph. |
InlineExitCollector* exit_collector = |
new InlineExitCollector(caller_graph_, call); |
- FlowGraphBuilder builder(parsed_function, |
- ic_data_array, |
- exit_collector, |
- Isolate::kNoDeoptId); |
- builder.SetInitialBlockId(caller_graph_->max_block_id()); |
+ GrowableArray<const Field*> inlined_guarded_fields; |
+ FlowGraphBuilder* builder = new FlowGraphBuilder(parsed_function, |
+ ic_data_array, |
+ exit_collector, |
+ &inlined_guarded_fields, |
+ Isolate::kNoDeoptId); |
+ builder->SetInitialBlockId(caller_graph_->max_block_id()); |
FlowGraph* callee_graph; |
{ |
TimerScope timer(FLAG_compiler_stats, |
&CompilerStats::graphinliner_build_timer, |
isolate); |
- callee_graph = builder.BuildGraph(); |
+ callee_graph = builder->BuildGraph(); |
} |
// The parameter stubs are a copy of the actual arguments providing |
@@ -607,7 +607,7 @@ |
&CompilerStats::graphinliner_opt_timer, |
isolate); |
// TODO(zerny): Do more optimization passes on the callee graph. |
- FlowGraphOptimizer optimizer(callee_graph, guarded_fields_); |
+ FlowGraphOptimizer optimizer(callee_graph); |
optimizer.ApplyICData(); |
DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
} |
@@ -668,6 +668,13 @@ |
call_data->callee_graph = callee_graph; |
call_data->parameter_stubs = param_stubs; |
call_data->exit_collector = exit_collector; |
+ |
+ // When inlined, we add the guarded fields of the callee to the caller's |
+ // list of guarded fields. |
+ for (intptr_t i = 0; i < inlined_guarded_fields.length(); ++i) { |
+ caller_graph_->builder().AddToGuardedFields(*inlined_guarded_fields[i]); |
+ } |
+ |
TRACE_INLINING(OS::Print(" Success\n")); |
return true; |
} else { |
@@ -998,7 +1005,6 @@ |
CallSites* collected_call_sites_; |
CallSites* inlining_call_sites_; |
GrowableArray<ParsedFunction*> function_cache_; |
- GrowableArray<const Field*>* guarded_fields_; |
DISALLOW_COPY_AND_ASSIGN(CallSiteInliner); |
}; |
@@ -1153,8 +1159,7 @@ |
bool PolymorphicInliner::TryInlineRecognizedMethod(const Function& target) { |
- FlowGraphOptimizer optimizer(owner_->caller_graph(), |
- NULL); // No guarded fields needed. |
+ FlowGraphOptimizer optimizer(owner_->caller_graph()); |
TargetEntryInstr* entry; |
Definition* last; |
if (optimizer.TryInlineRecognizedMethod(target, |
@@ -1475,7 +1480,7 @@ |
printer.PrintBlocks(); |
} |
- CallSiteInliner inliner(flow_graph_, guarded_fields_); |
+ CallSiteInliner inliner(flow_graph_); |
inliner.InlineCalls(); |
if (inliner.inlined()) { |