Chromium Code Reviews| Index: runtime/vm/flow_graph.cc |
| diff --git a/runtime/vm/flow_graph.cc b/runtime/vm/flow_graph.cc |
| index a9c8302bee439f3d8e3ba1cbfcc326311f7051ee..ba7e8776dabcbb3ca2236b0e595f04eb7f82482b 100644 |
| --- a/runtime/vm/flow_graph.cc |
| +++ b/runtime/vm/flow_graph.cc |
| @@ -990,14 +990,25 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis, |
| constant_dead_ = GetConstant(Symbols::OptimizedOut()); |
| constant_empty_context_ = GetConstant(Object::empty_context()); |
| + // Check if inlining_parameters include a type argument vector parameter. |
| + const intptr_t inlined_type_args_param = |
| + (FLAG_reify_generic_functions && (inlining_parameters != NULL) && |
| + function().IsGeneric()) |
| + ? 1 |
| + : 0; |
| + |
| // Add parameters to the initial definitions and renaming environment. |
| if (inlining_parameters != NULL) { |
| // Use known parameters. |
| - ASSERT(parameter_count() == inlining_parameters->length()); |
| + ASSERT(inlined_type_args_param + parameter_count() == |
| + inlining_parameters->length()); |
| for (intptr_t i = 0; i < parameter_count(); ++i) { |
| - Definition* defn = (*inlining_parameters)[i]; |
| + Definition* defn = (*inlining_parameters)[inlined_type_args_param + i]; |
| AllocateSSAIndexes(defn); |
| AddToInitialDefinitions(defn); |
| + // If inlined_type_args_param == 1, then (*inlining_parameters)[0] |
|
Vyacheslav Egorov (Google)
2017/07/03 16:15:43
I think this comment is misplaced - it confused me
regis
2017/07/05 18:41:29
Done.
|
| + // is the passed-in type args. We do not add it to env[0] but to |
| + // env[parameter_count()] below. |
| env.Add(defn); |
| } |
| } else { |
| @@ -1015,11 +1026,32 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis, |
| // Initialize all locals in the renaming environment For OSR, the locals have |
| // already been handled as parameters. |
| if (!IsCompiledForOsr()) { |
| - for (intptr_t i = parameter_count(); i < variable_count(); ++i) { |
| + intptr_t i = parameter_count(); |
| + if (FLAG_reify_generic_functions && function().IsGeneric()) { |
| + // The first local is the slot holding the copied passed-in type args. |
| + // TODO(regis): Do we need the SpecialParameterInstr if the type_args_var |
| + // is not needed? Add an assert for now: |
| + ASSERT(parsed_function().function_type_arguments() != NULL); |
| + if (inlined_type_args_param > 0) { |
|
Vyacheslav Egorov (Google)
2017/07/03 16:15:43
maybe
Definition* defn;
if (inlining_parameters
regis
2017/07/05 18:41:29
Done.
|
| + Definition* defn = (*inlining_parameters)[0]; |
| + AllocateSSAIndexes(defn); |
| + AddToInitialDefinitions(defn); |
| + env.Add(defn); |
| + } else { |
| + ASSERT(inlining_parameters == NULL); |
| + SpecialParameterInstr* type_args = new SpecialParameterInstr( |
| + SpecialParameterInstr::kTypeArgs, Thread::kNoDeoptId); |
| + type_args->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. |
| + AddToInitialDefinitions(type_args); |
| + env.Add(type_args); |
| + } |
| + ++i; |
| + } |
| + for (; i < variable_count(); ++i) { |
| if (i == CurrentContextEnvIndex()) { |
| if (function().IsClosureFunction()) { |
| - CurrentContextInstr* context = |
| - new CurrentContextInstr(Thread::kNoDeoptId); |
| + SpecialParameterInstr* context = new SpecialParameterInstr( |
| + SpecialParameterInstr::kContext, Thread::kNoDeoptId); |
| context->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. |
| AddToInitialDefinitions(context); |
| env.Add(context); |