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

Side by Side Diff: runtime/vm/flow_graph.cc

Issue 2894953002: Support inlining of calls where type arguments are passed to generic functions. (Closed)
Patch Set: Merge branch 'master' into slave 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph.h" 5 #include "vm/flow_graph.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 GraphEntryInstr* entry = graph_entry(); 983 GraphEntryInstr* entry = graph_entry();
984 984
985 // Initial renaming environment. 985 // Initial renaming environment.
986 GrowableArray<Definition*> env(variable_count()); 986 GrowableArray<Definition*> env(variable_count());
987 987
988 // Add global constants to the initial definitions. 988 // Add global constants to the initial definitions.
989 constant_null_ = GetConstant(Object::ZoneHandle()); 989 constant_null_ = GetConstant(Object::ZoneHandle());
990 constant_dead_ = GetConstant(Symbols::OptimizedOut()); 990 constant_dead_ = GetConstant(Symbols::OptimizedOut());
991 constant_empty_context_ = GetConstant(Object::empty_context()); 991 constant_empty_context_ = GetConstant(Object::empty_context());
992 992
993 // Check if inlining_parameters include a type argument vector parameter.
994 const intptr_t inlined_type_args_param =
995 (FLAG_reify_generic_functions && (inlining_parameters != NULL) &&
996 function().IsGeneric())
997 ? 1
998 : 0;
999
993 // Add parameters to the initial definitions and renaming environment. 1000 // Add parameters to the initial definitions and renaming environment.
994 if (inlining_parameters != NULL) { 1001 if (inlining_parameters != NULL) {
995 // Use known parameters. 1002 // Use known parameters.
996 ASSERT(parameter_count() == inlining_parameters->length()); 1003 ASSERT(inlined_type_args_param + parameter_count() ==
1004 inlining_parameters->length());
997 for (intptr_t i = 0; i < parameter_count(); ++i) { 1005 for (intptr_t i = 0; i < parameter_count(); ++i) {
998 Definition* defn = (*inlining_parameters)[i]; 1006 Definition* defn = (*inlining_parameters)[inlined_type_args_param + i];
999 AllocateSSAIndexes(defn); 1007 AllocateSSAIndexes(defn);
1000 AddToInitialDefinitions(defn); 1008 AddToInitialDefinitions(defn);
1009 // 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.
1010 // is the passed-in type args. We do not add it to env[0] but to
1011 // env[parameter_count()] below.
1001 env.Add(defn); 1012 env.Add(defn);
1002 } 1013 }
1003 } else { 1014 } else {
1004 // Create new parameters. For functions compiled for OSR, the locals 1015 // Create new parameters. For functions compiled for OSR, the locals
1005 // are unknown and so treated like parameters. 1016 // are unknown and so treated like parameters.
1006 intptr_t count = IsCompiledForOsr() ? variable_count() : parameter_count(); 1017 intptr_t count = IsCompiledForOsr() ? variable_count() : parameter_count();
1007 for (intptr_t i = 0; i < count; ++i) { 1018 for (intptr_t i = 0; i < count; ++i) {
1008 ParameterInstr* param = new (zone()) ParameterInstr(i, entry); 1019 ParameterInstr* param = new (zone()) ParameterInstr(i, entry);
1009 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. 1020 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
1010 AddToInitialDefinitions(param); 1021 AddToInitialDefinitions(param);
1011 env.Add(param); 1022 env.Add(param);
1012 } 1023 }
1013 } 1024 }
1014 1025
1015 // Initialize all locals in the renaming environment For OSR, the locals have 1026 // Initialize all locals in the renaming environment For OSR, the locals have
1016 // already been handled as parameters. 1027 // already been handled as parameters.
1017 if (!IsCompiledForOsr()) { 1028 if (!IsCompiledForOsr()) {
1018 for (intptr_t i = parameter_count(); i < variable_count(); ++i) { 1029 intptr_t i = parameter_count();
1030 if (FLAG_reify_generic_functions && function().IsGeneric()) {
1031 // The first local is the slot holding the copied passed-in type args.
1032 // TODO(regis): Do we need the SpecialParameterInstr if the type_args_var
1033 // is not needed? Add an assert for now:
1034 ASSERT(parsed_function().function_type_arguments() != NULL);
1035 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.
1036 Definition* defn = (*inlining_parameters)[0];
1037 AllocateSSAIndexes(defn);
1038 AddToInitialDefinitions(defn);
1039 env.Add(defn);
1040 } else {
1041 ASSERT(inlining_parameters == NULL);
1042 SpecialParameterInstr* type_args = new SpecialParameterInstr(
1043 SpecialParameterInstr::kTypeArgs, Thread::kNoDeoptId);
1044 type_args->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
1045 AddToInitialDefinitions(type_args);
1046 env.Add(type_args);
1047 }
1048 ++i;
1049 }
1050 for (; i < variable_count(); ++i) {
1019 if (i == CurrentContextEnvIndex()) { 1051 if (i == CurrentContextEnvIndex()) {
1020 if (function().IsClosureFunction()) { 1052 if (function().IsClosureFunction()) {
1021 CurrentContextInstr* context = 1053 SpecialParameterInstr* context = new SpecialParameterInstr(
1022 new CurrentContextInstr(Thread::kNoDeoptId); 1054 SpecialParameterInstr::kContext, Thread::kNoDeoptId);
1023 context->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. 1055 context->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
1024 AddToInitialDefinitions(context); 1056 AddToInitialDefinitions(context);
1025 env.Add(context); 1057 env.Add(context);
1026 } else { 1058 } else {
1027 env.Add(constant_empty_context()); 1059 env.Add(constant_empty_context());
1028 } 1060 }
1029 } else { 1061 } else {
1030 env.Add(constant_null()); 1062 env.Add(constant_null());
1031 } 1063 }
1032 } 1064 }
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 Representation rep, 2343 Representation rep,
2312 intptr_t cid) { 2344 intptr_t cid) {
2313 ExtractNthOutputInstr* extract = 2345 ExtractNthOutputInstr* extract =
2314 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid); 2346 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid);
2315 instr->ReplaceUsesWith(extract); 2347 instr->ReplaceUsesWith(extract);
2316 InsertAfter(instr, extract, NULL, FlowGraph::kValue); 2348 InsertAfter(instr, extract, NULL, FlowGraph::kValue);
2317 } 2349 }
2318 2350
2319 2351
2320 } // namespace dart 2352 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698