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

Unified Diff: runtime/vm/flow_graph.cc

Issue 2894953002: Support inlining of calls where type arguments are passed to generic functions. (Closed)
Patch Set: address review comments Created 3 years, 5 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
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_allocator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph.cc
diff --git a/runtime/vm/flow_graph.cc b/runtime/vm/flow_graph.cc
index a9c8302bee439f3d8e3ba1cbfcc326311f7051ee..9314d92018da1d8d949ed4793cb5599bb6122968 100644
--- a/runtime/vm/flow_graph.cc
+++ b/runtime/vm/flow_graph.cc
@@ -990,12 +990,23 @@ 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];
+ // If inlined_type_args_param == 1, then (*inlining_parameters)[0]
+ // is the passed-in type args. We do not add it to env[0] but to
+ // env[parameter_count()] below.
+ Definition* defn = (*inlining_parameters)[inlined_type_args_param + i];
AllocateSSAIndexes(defn);
AddToInitialDefinitions(defn);
env.Add(defn);
@@ -1015,11 +1026,29 @@ 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);
+ Definition* defn;
+ if (inlining_parameters == NULL) {
+ defn = new SpecialParameterInstr(SpecialParameterInstr::kTypeArgs,
+ Thread::kNoDeoptId);
+ } else {
+ defn = (*inlining_parameters)[0];
+ }
+ AllocateSSAIndexes(defn);
+ AddToInitialDefinitions(defn);
+ env.Add(defn);
+ ++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);
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698