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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
10 #include "vm/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
12 #include "vm/flags.h" | 12 #include "vm/flags.h" |
13 #include "vm/flow_graph_compiler.h" | 13 #include "vm/flow_graph_compiler.h" |
14 #include "vm/il_printer.h" | 14 #include "vm/il_printer.h" |
15 #include "vm/intermediate_language.h" | 15 #include "vm/intermediate_language.h" |
16 #include "vm/longjump.h" | 16 #include "vm/longjump.h" |
17 #include "vm/object_store.h" | 17 #include "vm/object_store.h" |
18 #include "vm/os.h" | 18 #include "vm/os.h" |
19 #include "vm/parser.h" | 19 #include "vm/parser.h" |
20 #include "vm/resolver.h" | 20 #include "vm/resolver.h" |
21 #include "vm/stack_frame.h" | 21 #include "vm/stack_frame.h" |
22 #include "vm/stub_code.h" | 22 #include "vm/stub_code.h" |
23 #include "vm/symbols.h" | 23 #include "vm/symbols.h" |
24 | 24 |
25 namespace dart { | 25 namespace dart { |
26 | 26 |
27 DEFINE_FLAG(bool, eliminate_type_checks, true, | 27 DEFINE_FLAG(bool, eliminate_type_checks, true, |
28 "Eliminate type checks when allowed by static type analysis."); | 28 "Eliminate type checks when allowed by static type analysis."); |
29 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 29 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
| 30 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); |
30 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); | 31 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); |
31 DEFINE_FLAG(bool, print_flow_graph_optimized, false, | 32 DEFINE_FLAG(bool, print_flow_graph_optimized, false, |
32 "Print the IR flow graph when optimizing."); | 33 "Print the IR flow graph when optimizing."); |
33 DEFINE_FLAG(bool, trace_type_check_elimination, false, | 34 DEFINE_FLAG(bool, trace_type_check_elimination, false, |
34 "Trace type check elimination at compile time."); | 35 "Trace type check elimination at compile time."); |
35 DECLARE_FLAG(bool, enable_type_checks); | 36 DECLARE_FLAG(bool, enable_type_checks); |
36 | 37 |
37 | 38 |
38 FlowGraphBuilder::FlowGraphBuilder(ParsedFunction* parsed_function, | 39 FlowGraphBuilder::FlowGraphBuilder(ParsedFunction* parsed_function, |
39 const Array& ic_data_array, | 40 const Array& ic_data_array, |
(...skipping 3759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3799 AppendFragment(finally_entry, for_finally_block); | 3800 AppendFragment(finally_entry, for_finally_block); |
3800 exit_ = for_finally_block.exit_; | 3801 exit_ = for_finally_block.exit_; |
3801 } | 3802 } |
3802 | 3803 |
3803 | 3804 |
3804 FlowGraph* FlowGraphBuilder::BuildGraph() { | 3805 FlowGraph* FlowGraphBuilder::BuildGraph() { |
3805 if (FLAG_print_ast) { | 3806 if (FLAG_print_ast) { |
3806 // Print the function ast before IL generation. | 3807 // Print the function ast before IL generation. |
3807 AstPrinter::PrintFunctionNodes(*parsed_function()); | 3808 AstPrinter::PrintFunctionNodes(*parsed_function()); |
3808 } | 3809 } |
| 3810 if (FLAG_print_scopes) { |
| 3811 AstPrinter::PrintFunctionScope(*parsed_function()); |
| 3812 } |
3809 const Function& function = parsed_function()->function(); | 3813 const Function& function = parsed_function()->function(); |
3810 TargetEntryInstr* normal_entry = | 3814 TargetEntryInstr* normal_entry = |
3811 new TargetEntryInstr(AllocateBlockId(), | 3815 new TargetEntryInstr(AllocateBlockId(), |
3812 CatchClauseNode::kInvalidTryIndex); | 3816 CatchClauseNode::kInvalidTryIndex); |
3813 graph_entry_ = new GraphEntryInstr(parsed_function(), normal_entry, osr_id_); | 3817 graph_entry_ = new GraphEntryInstr(parsed_function(), normal_entry, osr_id_); |
3814 EffectGraphVisitor for_effect(this, 0); | 3818 EffectGraphVisitor for_effect(this, 0); |
3815 // This check may be deleted if the generated code is leaf. | 3819 // This check may be deleted if the generated code is leaf. |
3816 // Native functions don't need a stack check at entry. | 3820 // Native functions don't need a stack check at entry. |
3817 if (!function.is_native()) { | 3821 if (!function.is_native()) { |
3818 CheckStackOverflowInstr* check = | 3822 CheckStackOverflowInstr* check = |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3856 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3860 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
3857 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3861 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
3858 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3862 OS::SNPrint(chars, len, kFormat, function_name, reason); |
3859 const Error& error = Error::Handle( | 3863 const Error& error = Error::Handle( |
3860 LanguageError::New(String::Handle(String::New(chars)))); | 3864 LanguageError::New(String::Handle(String::New(chars)))); |
3861 Isolate::Current()->long_jump_base()->Jump(1, error); | 3865 Isolate::Current()->long_jump_base()->Jump(1, error); |
3862 } | 3866 } |
3863 | 3867 |
3864 | 3868 |
3865 } // namespace dart | 3869 } // namespace dart |
OLD | NEW |