| 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" |
| 11 #include "vm/flags.h" | 11 #include "vm/flags.h" |
| 12 #include "vm/il_printer.h" | 12 #include "vm/il_printer.h" |
| 13 #include "vm/intermediate_language.h" | 13 #include "vm/intermediate_language.h" |
| 14 #include "vm/longjump.h" | 14 #include "vm/longjump.h" |
| 15 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
| 16 #include "vm/os.h" | 16 #include "vm/os.h" |
| 17 #include "vm/parser.h" | 17 #include "vm/parser.h" |
| 18 #include "vm/resolver.h" | 18 #include "vm/resolver.h" |
| 19 #include "vm/stub_code.h" | 19 #include "vm/stub_code.h" |
| 20 #include "vm/symbols.h" | 20 #include "vm/symbols.h" |
| 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 #if defined(TARGET_ARCH_X64) | |
| 31 DEFINE_FLAG(bool, use_ssa, true, "Use SSA form"); | |
| 32 #else | |
| 33 DEFINE_FLAG(bool, use_ssa, false, "Use SSA form"); | |
| 34 #endif | |
| 35 DECLARE_FLAG(bool, enable_type_checks); | 30 DECLARE_FLAG(bool, enable_type_checks); |
| 36 | 31 |
| 37 | 32 |
| 38 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function) | 33 FlowGraphBuilder::FlowGraphBuilder(const ParsedFunction& parsed_function) |
| 39 : parsed_function_(parsed_function), | 34 : parsed_function_(parsed_function), |
| 40 preorder_block_entries_(), | 35 preorder_block_entries_(), |
| 41 postorder_block_entries_(), | 36 postorder_block_entries_(), |
| 42 context_level_(0), | 37 context_level_(0), |
| 43 last_used_try_index_(CatchClauseNode::kInvalidTryIndex), | 38 last_used_try_index_(CatchClauseNode::kInvalidTryIndex), |
| 44 try_index_(CatchClauseNode::kInvalidTryIndex), | 39 try_index_(CatchClauseNode::kInvalidTryIndex), |
| (...skipping 2546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2591 } | 2586 } |
| 2592 } | 2587 } |
| 2593 } | 2588 } |
| 2594 } | 2589 } |
| 2595 | 2590 |
| 2596 // 2. Process normal instructions. | 2591 // 2. Process normal instructions. |
| 2597 for (ForwardInstructionIterator it(block_entry); !it.Done(); it.Advance()) { | 2592 for (ForwardInstructionIterator it(block_entry); !it.Done(); it.Advance()) { |
| 2598 Instruction* current = it.Current(); | 2593 Instruction* current = it.Current(); |
| 2599 // Attach current environment to the instruction. | 2594 // Attach current environment to the instruction. |
| 2600 // TODO(fschneider): Currently each instruction gets a full copy of the | 2595 // TODO(fschneider): Currently each instruction gets a full copy of the |
| 2601 // enviroment. This should be optimized: Only instructions that can | 2596 // environment. This should be optimized: Only instructions that can |
| 2602 // deoptimize will should have uses of the environment values. | 2597 // deoptimize should have uses of the environment values. |
| 2603 current->set_env(new Environment(*env)); | 2598 current->set_env(new Environment(*env)); |
| 2604 | 2599 |
| 2605 // 2a. Handle uses: | 2600 // 2a. Handle uses: |
| 2606 // Update expression stack environment for each use. | 2601 // Update expression stack environment for each use. |
| 2607 // For each use of a LoadLocal or StoreLocal: Replace it with the value | 2602 // For each use of a LoadLocal or StoreLocal: Replace it with the value |
| 2608 // from the environment. | 2603 // from the environment. |
| 2609 for (intptr_t i = 0; i < current->InputCount(); ++i) { | 2604 for (intptr_t i = 0; i < current->InputCount(); ++i) { |
| 2610 Value* v = current->InputAt(i); | 2605 Value* v = current->InputAt(i); |
| 2611 if (!v->IsUse()) continue; | 2606 if (!v->IsUse()) continue; |
| 2612 // Update expression stack. | 2607 // Update expression stack. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2701 char* chars = reinterpret_cast<char*>( | 2696 char* chars = reinterpret_cast<char*>( |
| 2702 Isolate::Current()->current_zone()->Allocate(len)); | 2697 Isolate::Current()->current_zone()->Allocate(len)); |
| 2703 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2698 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2704 const Error& error = Error::Handle( | 2699 const Error& error = Error::Handle( |
| 2705 LanguageError::New(String::Handle(String::New(chars)))); | 2700 LanguageError::New(String::Handle(String::New(chars)))); |
| 2706 Isolate::Current()->long_jump_base()->Jump(1, error); | 2701 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2707 } | 2702 } |
| 2708 | 2703 |
| 2709 | 2704 |
| 2710 } // namespace dart | 2705 } // namespace dart |
| OLD | NEW |