| 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/code_descriptors.h" | 8 #include "vm/code_descriptors.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| 11 #include "vm/il_printer.h" | 11 #include "vm/il_printer.h" |
| 12 #include "vm/intermediate_language.h" | 12 #include "vm/intermediate_language.h" |
| 13 #include "vm/longjump.h" | 13 #include "vm/longjump.h" |
| 14 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 15 #include "vm/os.h" | 15 #include "vm/os.h" |
| 16 #include "vm/parser.h" | 16 #include "vm/parser.h" |
| 17 #include "vm/resolver.h" | 17 #include "vm/resolver.h" |
| 18 #include "vm/stub_code.h" | 18 #include "vm/stub_code.h" |
| 19 #include "vm/symbols.h" | 19 #include "vm/symbols.h" |
| 20 | 20 |
| 21 namespace dart { | 21 namespace dart { |
| 22 | 22 |
| 23 DEFINE_FLAG(bool, eliminate_type_checks, true, | 23 DEFINE_FLAG(bool, eliminate_type_checks, true, |
| 24 "Eliminate type checks when allowed by static type analysis."); | 24 "Eliminate type checks when allowed by static type analysis."); |
| 25 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 25 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
| 26 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); | 26 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); |
| 27 DEFINE_FLAG(bool, trace_type_check_elimination, false, | 27 DEFINE_FLAG(bool, trace_type_check_elimination, false, |
| 28 "Trace type check elimination at compile time."); | 28 "Trace type check elimination at compile time."); |
| 29 DECLARE_FLAG(bool, enable_type_checks); | 29 DECLARE_FLAG(bool, enable_type_checks); |
| 30 DECLARE_FLAG(bool, use_ssa); | |
| 31 | 30 |
| 32 | 31 |
| 33 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function) | 32 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function) |
| 34 : parsed_function_(parsed_function), | 33 : parsed_function_(parsed_function), |
| 35 copied_parameter_count_(parsed_function.copied_parameter_count()), | 34 copied_parameter_count_(parsed_function.copied_parameter_count()), |
| 36 // All parameters are copied if any parameter is. | 35 // All parameters are copied if any parameter is. |
| 37 non_copied_parameter_count_((copied_parameter_count_ == 0) | 36 non_copied_parameter_count_((copied_parameter_count_ == 0) |
| 38 ? parsed_function.function().num_fixed_parameters() | 37 ? parsed_function.function().num_fixed_parameters() |
| 39 : 0), | 38 : 0), |
| 40 stack_local_count_(parsed_function.stack_local_count()), | 39 stack_local_count_(parsed_function.stack_local_count()), |
| (...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2217 if (!CanSkipTypeCheck(parameter.token_pos(), | 2216 if (!CanSkipTypeCheck(parameter.token_pos(), |
| 2218 NULL, | 2217 NULL, |
| 2219 parameter.type(), | 2218 parameter.type(), |
| 2220 parameter.name())) { | 2219 parameter.name())) { |
| 2221 Value* parameter_value = Bind(BuildLoadLocal(parameter)); | 2220 Value* parameter_value = Bind(BuildLoadLocal(parameter)); |
| 2222 AssertAssignableComp* assert_assignable = | 2221 AssertAssignableComp* assert_assignable = |
| 2223 BuildAssertAssignable(parameter.token_pos(), | 2222 BuildAssertAssignable(parameter.token_pos(), |
| 2224 parameter_value, | 2223 parameter_value, |
| 2225 parameter.type(), | 2224 parameter.type(), |
| 2226 parameter.name()); | 2225 parameter.name()); |
| 2227 if (FLAG_use_ssa) { | 2226 parameter_value = Bind(assert_assignable); |
| 2228 parameter_value = Bind(assert_assignable); | 2227 // Store the type checked argument back to its corresponding local |
| 2229 // Store the type checked argument back to its corresponding local | 2228 // variable so that ssa renaming detects the dependency and makes use |
| 2230 // variable so that ssa renaming detects the dependency and makes use | 2229 // of the checked type in type propagation. |
| 2231 // of the checked type in type propagation. | 2230 Do(BuildStoreLocal(parameter, parameter_value)); |
| 2232 Do(BuildStoreLocal(parameter, parameter_value)); | |
| 2233 } else { | |
| 2234 // No need to store the check parameter value back when not using ssa. | |
| 2235 Do(assert_assignable); | |
| 2236 } | |
| 2237 } | 2231 } |
| 2238 pos++; | 2232 pos++; |
| 2239 } | 2233 } |
| 2240 } | 2234 } |
| 2241 | 2235 |
| 2242 intptr_t i = 0; | 2236 intptr_t i = 0; |
| 2243 while (is_open() && (i < node->length())) { | 2237 while (is_open() && (i < node->length())) { |
| 2244 EffectGraphVisitor for_effect(owner(), temp_index()); | 2238 EffectGraphVisitor for_effect(owner(), temp_index()); |
| 2245 node->NodeAt(i++)->Visit(&for_effect); | 2239 node->NodeAt(i++)->Visit(&for_effect); |
| 2246 Append(for_effect); | 2240 Append(for_effect); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2415 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2409 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 2416 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2410 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2417 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2411 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2418 const Error& error = Error::Handle( | 2412 const Error& error = Error::Handle( |
| 2419 LanguageError::New(String::Handle(String::New(chars)))); | 2413 LanguageError::New(String::Handle(String::New(chars)))); |
| 2420 Isolate::Current()->long_jump_base()->Jump(1, error); | 2414 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2421 } | 2415 } |
| 2422 | 2416 |
| 2423 | 2417 |
| 2424 } // namespace dart | 2418 } // namespace dart |
| OLD | NEW |