| OLD | NEW |
| 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 Loading... |
| 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 // If inlined_type_args_param == 1, then (*inlining_parameters)[0] |
| 1007 // is the passed-in type args. We do not add it to env[0] but to |
| 1008 // env[parameter_count()] below. |
| 1009 Definition* defn = (*inlining_parameters)[inlined_type_args_param + i]; |
| 999 AllocateSSAIndexes(defn); | 1010 AllocateSSAIndexes(defn); |
| 1000 AddToInitialDefinitions(defn); | 1011 AddToInitialDefinitions(defn); |
| 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 Definition* defn; |
| 1036 if (inlining_parameters == NULL) { |
| 1037 defn = new SpecialParameterInstr(SpecialParameterInstr::kTypeArgs, |
| 1038 Thread::kNoDeoptId); |
| 1039 } else { |
| 1040 defn = (*inlining_parameters)[0]; |
| 1041 } |
| 1042 AllocateSSAIndexes(defn); |
| 1043 AddToInitialDefinitions(defn); |
| 1044 env.Add(defn); |
| 1045 ++i; |
| 1046 } |
| 1047 for (; i < variable_count(); ++i) { |
| 1019 if (i == CurrentContextEnvIndex()) { | 1048 if (i == CurrentContextEnvIndex()) { |
| 1020 if (function().IsClosureFunction()) { | 1049 if (function().IsClosureFunction()) { |
| 1021 CurrentContextInstr* context = | 1050 SpecialParameterInstr* context = new SpecialParameterInstr( |
| 1022 new CurrentContextInstr(Thread::kNoDeoptId); | 1051 SpecialParameterInstr::kContext, Thread::kNoDeoptId); |
| 1023 context->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. | 1052 context->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. |
| 1024 AddToInitialDefinitions(context); | 1053 AddToInitialDefinitions(context); |
| 1025 env.Add(context); | 1054 env.Add(context); |
| 1026 } else { | 1055 } else { |
| 1027 env.Add(constant_empty_context()); | 1056 env.Add(constant_empty_context()); |
| 1028 } | 1057 } |
| 1029 } else { | 1058 } else { |
| 1030 env.Add(constant_null()); | 1059 env.Add(constant_null()); |
| 1031 } | 1060 } |
| 1032 } | 1061 } |
| (...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 Representation rep, | 2340 Representation rep, |
| 2312 intptr_t cid) { | 2341 intptr_t cid) { |
| 2313 ExtractNthOutputInstr* extract = | 2342 ExtractNthOutputInstr* extract = |
| 2314 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid); | 2343 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid); |
| 2315 instr->ReplaceUsesWith(extract); | 2344 instr->ReplaceUsesWith(extract); |
| 2316 InsertAfter(instr, extract, NULL, FlowGraph::kValue); | 2345 InsertAfter(instr, extract, NULL, FlowGraph::kValue); |
| 2317 } | 2346 } |
| 2318 | 2347 |
| 2319 | 2348 |
| 2320 } // namespace dart | 2349 } // namespace dart |
| OLD | NEW |