Chromium Code Reviews| Index: runtime/vm/flow_graph_inliner.cc |
| =================================================================== |
| --- runtime/vm/flow_graph_inliner.cc (revision 43075) |
| +++ runtime/vm/flow_graph_inliner.cc (working copy) |
| @@ -438,6 +438,7 @@ |
| TargetEntryInstr* BuildDecisionGraph(); |
| Isolate* isolate() const; |
| + Zone* zone() const; |
| CallSiteInliner* const owner_; |
| PolymorphicInstanceCallInstr* const call_; |
| @@ -490,7 +491,9 @@ |
| FlowGraph* caller_graph() const { return caller_graph_; } |
| + Thread* thread() const { return caller_graph_->thread(); } |
| Isolate* isolate() const { return caller_graph_->isolate(); } |
| + Zone* zone() const { return caller_graph_->zone(); } |
| // Inlining heuristics based on Cooper et al. 2008. |
| bool ShouldWeInline(const Function& callee, |
| @@ -585,9 +588,9 @@ |
| FlowGraph* graph) { |
| ConstantInstr* constant = argument->definition()->AsConstant(); |
| if (constant != NULL) { |
| - return new(isolate()) ConstantInstr(constant->value()); |
| + return new(zone()) ConstantInstr(constant->value()); |
| } else { |
| - return new(isolate()) ParameterInstr(i, graph->graph_entry()); |
| + return new(zone()) ParameterInstr(i, graph->graph_entry()); |
| } |
| } |
| @@ -674,12 +677,12 @@ |
| // Load IC data for the callee. |
| ZoneGrowableArray<const ICData*>* ic_data_array = |
| - new(isolate()) ZoneGrowableArray<const ICData*>(); |
| + new(zone()) ZoneGrowableArray<const ICData*>(); |
| function.RestoreICDataMap(ic_data_array); |
| // Build the callee graph. |
| InlineExitCollector* exit_collector = |
| - new(isolate()) InlineExitCollector(caller_graph_, call); |
| + new(zone()) InlineExitCollector(caller_graph_, call); |
|
Ivan Posva
2015/01/23 19:49:24
#define Z (zone())
koda
2015/01/23 21:09:42
Done.
|
| FlowGraphBuilder builder(parsed_function, |
| *ic_data_array, |
| exit_collector, |
| @@ -698,7 +701,7 @@ |
| // without linking between the caller and callee graphs. |
| // TODO(zerny): Put more information in the stubs, eg, type information. |
| ZoneGrowableArray<Definition*>* param_stubs = |
| - new(isolate()) ZoneGrowableArray<Definition*>( |
| + new(zone()) ZoneGrowableArray<Definition*>( |
| function.NumParameters()); |
| // Create a parameter stub for each fixed positional parameter. |
| @@ -973,7 +976,7 @@ |
| CurrentContextInstr* context = (*defns)[i]->AsCurrentContext(); |
| if ((context != NULL) && context->HasUses()) { |
| ASSERT(call->IsClosureCall()); |
| - LoadFieldInstr* context_load = new(isolate()) LoadFieldInstr( |
| + LoadFieldInstr* context_load = new(zone()) LoadFieldInstr( |
| new Value((*arguments)[0]->definition()), |
| Closure::context_offset(), |
| AbstractType::ZoneHandle(isolate(), AbstractType::null()), |
| @@ -1010,7 +1013,7 @@ |
| } |
| *in_cache = false; |
| ParsedFunction* parsed_function = |
| - new(isolate()) ParsedFunction(isolate(), function); |
| + new(zone()) ParsedFunction(thread(), function); |
| Parser::ParseFunction(parsed_function); |
| parsed_function->AllocateVariables(); |
| return parsed_function; |
| @@ -1172,7 +1175,7 @@ |
| Object::ZoneHandle( |
| parsed_function.default_parameter_values().At( |
| i - fixed_param_count)); |
| - ConstantInstr* constant = new(isolate()) ConstantInstr(object); |
| + ConstantInstr* constant = new(zone()) ConstantInstr(object); |
| arguments->Add(NULL); |
| param_stubs->Add(constant); |
| } |
| @@ -1260,7 +1263,7 @@ |
| inlined_variants_(num_variants_), |
| non_inlined_variants_(num_variants_), |
| inlined_entries_(num_variants_), |
| - exit_collector_(new(isolate()) |
| + exit_collector_(new(zone()) |
| InlineExitCollector(owner->caller_graph(), call)), |
| caller_function_(caller_function) { |
| } |
| @@ -1271,6 +1274,11 @@ |
| } |
| +Zone* PolymorphicInliner::zone() const { |
| + return owner_->caller_graph()->zone(); |
| +} |
| + |
| + |
| // Inlined bodies are shared if two different class ids have the same |
| // inlined target. This sharing is represented by using three different |
| // types of entries in the inlined_entries_ array: |
| @@ -1310,7 +1318,7 @@ |
| new TargetEntryInstr(owner_->caller_graph()->allocate_block_id(), |
| old_target->try_index()); |
| new_target->InheritDeoptTarget(isolate(), new_join); |
| - GotoInstr* new_goto = new(isolate()) GotoInstr(new_join); |
| + GotoInstr* new_goto = new(zone()) GotoInstr(new_join); |
| new_goto->InheritDeoptTarget(isolate(), new_join); |
| new_target->LinkTo(new_goto); |
| new_target->set_last_instruction(new_goto); |
| @@ -1372,7 +1380,7 @@ |
| // hoisted above the inlined entry. |
| ASSERT(arguments.length() > 0); |
| Value* actual = arguments[0]; |
| - RedefinitionInstr* redefinition = new(isolate()) |
| + RedefinitionInstr* redefinition = new(zone()) |
| RedefinitionInstr(actual->Copy(isolate())); |
| redefinition->set_ssa_temp_index( |
| owner_->caller_graph()->alloc_ssa_temp_index()); |
| @@ -1399,7 +1407,7 @@ |
| CurrentContextInstr* context = (*defns)[i]->AsCurrentContext(); |
| if ((context != NULL) && context->HasUses()) { |
| ASSERT(call_data.call->IsClosureCall()); |
| - LoadFieldInstr* context_load = new(isolate()) LoadFieldInstr( |
| + LoadFieldInstr* context_load = new(zone()) LoadFieldInstr( |
| new Value(redefinition), |
| Closure::context_offset(), |
| AbstractType::ZoneHandle(isolate(), AbstractType::null()), |
| @@ -1436,7 +1444,7 @@ |
| GrowableArray<Definition*> arguments(call_->ArgumentCount()); |
| Definition* receiver = call_->ArgumentAt(0); |
| RedefinitionInstr* redefinition = |
| - new(isolate()) RedefinitionInstr(new(isolate()) Value(receiver)); |
| + new(zone()) RedefinitionInstr(new(zone()) Value(receiver)); |
| redefinition->set_ssa_temp_index( |
| owner_->caller_graph()->alloc_ssa_temp_index()); |
| if (optimizer.TryInlineRecognizedMethod(receiver_cid, |
| @@ -1449,11 +1457,11 @@ |
| // Create a graph fragment. |
| redefinition->InsertAfter(entry); |
| InlineExitCollector* exit_collector = |
| - new(isolate()) InlineExitCollector(owner_->caller_graph(), call_); |
| + new(zone()) InlineExitCollector(owner_->caller_graph(), call_); |
| ReturnInstr* result = |
| - new(isolate()) ReturnInstr(call_->instance_call()->token_pos(), |
| - new(isolate()) Value(last)); |
| + new(zone()) ReturnInstr(call_->instance_call()->token_pos(), |
| + new(zone()) Value(last)); |
| owner_->caller_graph()->AppendTo( |
| last, |
| result, |
| @@ -1462,7 +1470,7 @@ |
| entry->set_last_instruction(result); |
| exit_collector->AddExit(result); |
| GraphEntryInstr* graph_entry = |
| - new(isolate()) GraphEntryInstr(NULL, // No parsed function. |
| + new(zone()) GraphEntryInstr(NULL, // No parsed function. |
| entry, |
| Isolate::kNoDeoptId); // No OSR id. |
| // Update polymorphic inliner state. |
| @@ -1483,7 +1491,7 @@ |
| TargetEntryInstr* PolymorphicInliner::BuildDecisionGraph() { |
| // Start with a fresh target entry. |
| TargetEntryInstr* entry = |
| - new(isolate()) TargetEntryInstr( |
| + new(zone()) TargetEntryInstr( |
| owner_->caller_graph()->allocate_block_id(), |
| call_->GetBlock()->try_index()); |
| entry->InheritDeoptTarget(isolate(), call_); |
| @@ -1498,7 +1506,7 @@ |
| // There are at least two variants including non-inlined ones, so we have |
| // at least one branch on the class id. |
| LoadClassIdInstr* load_cid = |
| - new(isolate()) LoadClassIdInstr(new(isolate()) Value(receiver)); |
| + new(zone()) LoadClassIdInstr(new(zone()) Value(receiver)); |
| load_cid->set_ssa_temp_index(owner_->caller_graph()->alloc_ssa_temp_index()); |
| cursor = AppendInstruction(cursor, load_cid); |
| for (intptr_t i = 0; i < inlined_variants_.length(); ++i) { |
| @@ -1508,12 +1516,12 @@ |
| // If it is the last variant use a check class id instruction which can |
| // deoptimize, followed unconditionally by the body. |
| RedefinitionInstr* cid_redefinition = |
| - new RedefinitionInstr(new(isolate()) Value(load_cid)); |
| + new RedefinitionInstr(new(zone()) Value(load_cid)); |
| cid_redefinition->set_ssa_temp_index( |
| owner_->caller_graph()->alloc_ssa_temp_index()); |
| cursor = AppendInstruction(cursor, cid_redefinition); |
| - CheckClassIdInstr* check_class_id = new(isolate()) CheckClassIdInstr( |
| - new(isolate()) Value(cid_redefinition), |
| + CheckClassIdInstr* check_class_id = new(zone()) CheckClassIdInstr( |
| + new(zone()) Value(cid_redefinition), |
| inlined_variants_[i].cid, |
| call_->deopt_id()); |
| check_class_id->InheritDeoptTarget(isolate(), call_); |