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/intermediate_language.h" | 11 #include "vm/intermediate_language.h" |
12 #include "vm/longjump.h" | 12 #include "vm/longjump.h" |
13 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
14 #include "vm/os.h" | 14 #include "vm/os.h" |
15 #include "vm/parser.h" | 15 #include "vm/parser.h" |
16 #include "vm/resolver.h" | 16 #include "vm/resolver.h" |
17 #include "vm/stub_code.h" | 17 #include "vm/stub_code.h" |
18 | 18 |
19 namespace dart { | 19 namespace dart { |
20 | 20 |
21 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); | 21 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); |
22 DECLARE_FLAG(bool, enable_type_checks); | 22 DECLARE_FLAG(bool, enable_type_checks); |
23 DECLARE_FLAG(bool, print_ast); | 23 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
24 | 24 |
25 | 25 |
26 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function) | 26 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function) |
27 : parsed_function_(parsed_function), | 27 : parsed_function_(parsed_function), |
28 preorder_block_entries_(), | 28 preorder_block_entries_(), |
29 postorder_block_entries_(), | 29 postorder_block_entries_(), |
30 context_level_(0), | 30 context_level_(0), |
31 last_used_try_index_(CatchClauseNode::kInvalidTryIndex), | 31 last_used_try_index_(CatchClauseNode::kInvalidTryIndex), |
32 try_index_(CatchClauseNode::kInvalidTryIndex), | 32 try_index_(CatchClauseNode::kInvalidTryIndex), |
33 catch_entries_() {} | 33 catch_entries_() {} |
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1995 | 1995 |
1996 ChainContextComp* chain_context = new ChainContextComp( | 1996 ChainContextComp* chain_context = new ChainContextComp( |
1997 allocated_context_value); | 1997 allocated_context_value); |
1998 AddInstruction(new DoInstr(chain_context)); | 1998 AddInstruction(new DoInstr(chain_context)); |
1999 owner()->set_context_level(scope->context_level()); | 1999 owner()->set_context_level(scope->context_level()); |
2000 | 2000 |
2001 // If this node_sequence is the body of the function being compiled, copy | 2001 // If this node_sequence is the body of the function being compiled, copy |
2002 // the captured parameters from the frame into the context. | 2002 // the captured parameters from the frame into the context. |
2003 if (node == owner()->parsed_function().node_sequence()) { | 2003 if (node == owner()->parsed_function().node_sequence()) { |
2004 ASSERT(scope->context_level() == 1); | 2004 ASSERT(scope->context_level() == 1); |
2005 const Immediate raw_null = | |
2006 Immediate(reinterpret_cast<intptr_t>(Object::null())); | |
2007 const Function& function = owner()->parsed_function().function(); | 2005 const Function& function = owner()->parsed_function().function(); |
2008 const int num_params = function.NumberOfParameters(); | 2006 const int num_params = function.NumberOfParameters(); |
2009 int param_frame_index = | 2007 int param_frame_index = |
2010 (num_params == function.num_fixed_parameters()) ? 1 + num_params : -1; | 2008 (num_params == function.num_fixed_parameters()) ? 1 + num_params : -1; |
2011 for (int pos = 0; pos < num_params; param_frame_index--, pos++) { | 2009 for (int pos = 0; pos < num_params; param_frame_index--, pos++) { |
2012 const LocalVariable& parameter = *scope->VariableAt(pos); | 2010 const LocalVariable& parameter = *scope->VariableAt(pos); |
2013 ASSERT(parameter.owner() == scope); | 2011 ASSERT(parameter.owner() == scope); |
2014 if (parameter.is_captured()) { | 2012 if (parameter.is_captured()) { |
2015 // Create a temporary local describing the original position. | 2013 // Create a temporary local describing the original position. |
2016 const String& temp_name = String::ZoneHandle(String::Concat( | 2014 const String& temp_name = String::ZoneHandle(String::Concat( |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2770 char* chars = reinterpret_cast<char*>( | 2768 char* chars = reinterpret_cast<char*>( |
2771 Isolate::Current()->current_zone()->Allocate(len)); | 2769 Isolate::Current()->current_zone()->Allocate(len)); |
2772 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2770 OS::SNPrint(chars, len, kFormat, function_name, reason); |
2773 const Error& error = Error::Handle( | 2771 const Error& error = Error::Handle( |
2774 LanguageError::New(String::Handle(String::New(chars)))); | 2772 LanguageError::New(String::Handle(String::New(chars)))); |
2775 Isolate::Current()->long_jump_base()->Jump(1, error); | 2773 Isolate::Current()->long_jump_base()->Jump(1, error); |
2776 } | 2774 } |
2777 | 2775 |
2778 | 2776 |
2779 } // namespace dart | 2777 } // namespace dart |
OLD | NEW |