| 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_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
| 8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/code_descriptors.h" | 9 #include "vm/code_descriptors.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace dart { | 22 namespace dart { |
| 23 | 23 |
| 24 DEFINE_FLAG(bool, eliminate_type_checks, true, | 24 DEFINE_FLAG(bool, eliminate_type_checks, true, |
| 25 "Eliminate type checks when allowed by static type analysis."); | 25 "Eliminate type checks when allowed by static type analysis."); |
| 26 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 26 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
| 27 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); | 27 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); |
| 28 DEFINE_FLAG(bool, trace_type_check_elimination, false, | 28 DEFINE_FLAG(bool, trace_type_check_elimination, false, |
| 29 "Trace type check elimination at compile time."); | 29 "Trace type check elimination at compile time."); |
| 30 DECLARE_FLAG(bool, enable_type_checks); | 30 DECLARE_FLAG(bool, enable_type_checks); |
| 31 DECLARE_FLAG(bool, use_ssa); |
| 31 | 32 |
| 32 | 33 |
| 33 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function) | 34 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function) |
| 34 : parsed_function_(parsed_function), | 35 : parsed_function_(parsed_function), |
| 35 copied_parameter_count_(parsed_function.copied_parameter_count()), | 36 copied_parameter_count_(parsed_function.copied_parameter_count()), |
| 36 // All parameters are copied if any parameter is. | 37 // All parameters are copied if any parameter is. |
| 37 non_copied_parameter_count_((copied_parameter_count_ == 0) | 38 non_copied_parameter_count_((copied_parameter_count_ == 0) |
| 38 ? parsed_function.function().num_fixed_parameters() | 39 ? parsed_function.function().num_fixed_parameters() |
| 39 : 0), | 40 : 0), |
| 40 stack_local_count_(parsed_function.stack_local_count()), | 41 stack_local_count_(parsed_function.stack_local_count()), |
| (...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2188 // Skip type checking of receiver for instance functions. | 2189 // Skip type checking of receiver for instance functions. |
| 2189 pos = 1; | 2190 pos = 1; |
| 2190 } | 2191 } |
| 2191 while (pos < num_params) { | 2192 while (pos < num_params) { |
| 2192 const LocalVariable& parameter = *scope->VariableAt(pos); | 2193 const LocalVariable& parameter = *scope->VariableAt(pos); |
| 2193 ASSERT(parameter.owner() == scope); | 2194 ASSERT(parameter.owner() == scope); |
| 2194 if (!CanSkipTypeCheck(parameter.token_pos(), | 2195 if (!CanSkipTypeCheck(parameter.token_pos(), |
| 2195 NULL, | 2196 NULL, |
| 2196 parameter.type(), | 2197 parameter.type(), |
| 2197 parameter.name())) { | 2198 parameter.name())) { |
| 2198 Value* load = Bind(BuildLoadLocal(parameter)); | 2199 Value* parameter_value = Bind(BuildLoadLocal(parameter)); |
| 2199 Do(BuildAssertAssignable(parameter.token_pos(), | 2200 AssertAssignableComp* assert_assignable = |
| 2200 load, | 2201 BuildAssertAssignable(parameter.token_pos(), |
| 2201 parameter.type(), | 2202 parameter_value, |
| 2202 parameter.name())); | 2203 parameter.type(), |
| 2204 parameter.name()); |
| 2205 if (FLAG_use_ssa) { |
| 2206 parameter_value = Bind(assert_assignable); |
| 2207 // Store the type checked argument back to its corresponding local |
| 2208 // variable so that ssa renaming detects the dependency and makes use |
| 2209 // of the checked type in type propagation. |
| 2210 Do(BuildStoreLocal(parameter, parameter_value)); |
| 2211 } else { |
| 2212 // No need to store the check parameter value back when not using ssa. |
| 2213 Do(assert_assignable); |
| 2214 } |
| 2203 } | 2215 } |
| 2204 pos++; | 2216 pos++; |
| 2205 } | 2217 } |
| 2206 } | 2218 } |
| 2207 | 2219 |
| 2208 intptr_t i = 0; | 2220 intptr_t i = 0; |
| 2209 while (is_open() && (i < node->length())) { | 2221 while (is_open() && (i < node->length())) { |
| 2210 EffectGraphVisitor for_effect(owner(), temp_index()); | 2222 EffectGraphVisitor for_effect(owner(), temp_index()); |
| 2211 node->NodeAt(i++)->Visit(&for_effect); | 2223 node->NodeAt(i++)->Visit(&for_effect); |
| 2212 Append(for_effect); | 2224 Append(for_effect); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2811 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2823 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 2812 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2824 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2813 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2825 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2814 const Error& error = Error::Handle( | 2826 const Error& error = Error::Handle( |
| 2815 LanguageError::New(String::Handle(String::New(chars)))); | 2827 LanguageError::New(String::Handle(String::New(chars)))); |
| 2816 Isolate::Current()->long_jump_base()->Jump(1, error); | 2828 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2817 } | 2829 } |
| 2818 | 2830 |
| 2819 | 2831 |
| 2820 } // namespace dart | 2832 } // namespace dart |
| OLD | NEW |