| OLD | NEW | 
|     1 // Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file |     1 // Copyright (c) 2013, 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/globals.h"  // Needed here to get TARGET_ARCH_XXX. |     5 #include "vm/globals.h"  // Needed here to get TARGET_ARCH_XXX. | 
|     6  |     6  | 
|     7 #include "vm/flow_graph_compiler.h" |     7 #include "vm/flow_graph_compiler.h" | 
|     8  |     8  | 
|     9 #include "vm/bit_vector.h" |     9 #include "vm/bit_vector.h" | 
|    10 #include "vm/cha.h" |    10 #include "vm/cha.h" | 
|    11 #include "vm/dart_entry.h" |    11 #include "vm/dart_entry.h" | 
|    12 #include "vm/debugger.h" |    12 #include "vm/debugger.h" | 
|    13 #include "vm/deopt_instructions.h" |    13 #include "vm/deopt_instructions.h" | 
|    14 #include "vm/exceptions.h" |    14 #include "vm/exceptions.h" | 
|    15 #include "vm/flow_graph_allocator.h" |    15 #include "vm/flow_graph_allocator.h" | 
|    16 #include "vm/il_printer.h" |    16 #include "vm/il_printer.h" | 
|    17 #include "vm/intrinsifier.h" |    17 #include "vm/intrinsifier.h" | 
|    18 #include "vm/locations.h" |    18 #include "vm/locations.h" | 
|    19 #include "vm/longjump.h" |    19 #include "vm/longjump.h" | 
|    20 #include "vm/object_store.h" |    20 #include "vm/object_store.h" | 
|    21 #include "vm/parser.h" |    21 #include "vm/parser.h" | 
|    22 #include "vm/raw_object.h" |  | 
|    23 #include "vm/stack_frame.h" |    22 #include "vm/stack_frame.h" | 
|    24 #include "vm/stub_code.h" |    23 #include "vm/stub_code.h" | 
|    25 #include "vm/symbols.h" |    24 #include "vm/symbols.h" | 
|    26  |    25  | 
|    27 namespace dart { |    26 namespace dart { | 
|    28  |    27  | 
|    29 DECLARE_FLAG(bool, code_comments); |    28 DECLARE_FLAG(bool, code_comments); | 
|    30 DECLARE_FLAG(bool, disassemble); |    29 DECLARE_FLAG(bool, disassemble); | 
|    31 DECLARE_FLAG(bool, disassemble_optimized); |    30 DECLARE_FLAG(bool, disassemble_optimized); | 
|    32 DECLARE_FLAG(bool, emit_edge_counters); |    31 DECLARE_FLAG(bool, emit_edge_counters); | 
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   222     return true; |   221     return true; | 
|   223   } |   222   } | 
|   224   return false; |   223   return false; | 
|   225 } |   224 } | 
|   226  |   225  | 
|   227  |   226  | 
|   228 static bool IsEmptyBlock(BlockEntryInstr* block) { |   227 static bool IsEmptyBlock(BlockEntryInstr* block) { | 
|   229   return !block->IsCatchBlockEntry() && |   228   return !block->IsCatchBlockEntry() && | 
|   230          !block->HasNonRedundantParallelMove() && |   229          !block->HasNonRedundantParallelMove() && | 
|   231          block->next()->IsGoto() && |   230          block->next()->IsGoto() && | 
|   232          !block->next()->AsGoto()->HasNonRedundantParallelMove() && |   231          !block->next()->AsGoto()->HasNonRedundantParallelMove(); | 
|   233          !block->IsIndirectEntry(); |  | 
|   234 } |   232 } | 
|   235  |   233  | 
|   236  |   234  | 
|   237 void FlowGraphCompiler::CompactBlock(BlockEntryInstr* block) { |   235 void FlowGraphCompiler::CompactBlock(BlockEntryInstr* block) { | 
|   238   BlockInfo* block_info = block_info_[block->postorder_number()]; |   236   BlockInfo* block_info = block_info_[block->postorder_number()]; | 
|   239  |   237  | 
|   240   // Break out of cycles in the control flow graph. |   238   // Break out of cycles in the control flow graph. | 
|   241   if (block_info->is_marked()) { |   239   if (block_info->is_marked()) { | 
|   242     return; |   240     return; | 
|   243   } |   241   } | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   350     BlockEntryInstr* entry = block_order()[i]; |   348     BlockEntryInstr* entry = block_order()[i]; | 
|   351     assembler()->Comment("B%" Pd "", entry->block_id()); |   349     assembler()->Comment("B%" Pd "", entry->block_id()); | 
|   352     set_current_block(entry); |   350     set_current_block(entry); | 
|   353  |   351  | 
|   354     if (WasCompacted(entry)) { |   352     if (WasCompacted(entry)) { | 
|   355       continue; |   353       continue; | 
|   356     } |   354     } | 
|   357  |   355  | 
|   358     LoopInfoComment(assembler(), *entry, *loop_headers); |   356     LoopInfoComment(assembler(), *entry, *loop_headers); | 
|   359  |   357  | 
|   360     entry->set_offset(assembler()->CodeSize()); |  | 
|   361     entry->EmitNativeCode(this); |   358     entry->EmitNativeCode(this); | 
|   362     // Compile all successors until an exit, branch, or a block entry. |   359     // Compile all successors until an exit, branch, or a block entry. | 
|   363     for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { |   360     for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { | 
|   364       Instruction* instr = it.Current(); |   361       Instruction* instr = it.Current(); | 
|   365       if (FLAG_code_comments || |   362       if (FLAG_code_comments || | 
|   366           FLAG_disassemble || |   363           FLAG_disassemble || | 
|   367           FLAG_disassemble_optimized) { |   364           FLAG_disassemble_optimized) { | 
|   368         if (FLAG_source_lines) { |   365         if (FLAG_source_lines) { | 
|   369           EmitSourceLine(instr); |   366           EmitSourceLine(instr); | 
|   370         } |   367         } | 
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   823   } else { |   820   } else { | 
|   824     // Finalize the stack map array and add it to the code object. |   821     // Finalize the stack map array and add it to the code object. | 
|   825     ASSERT(is_optimizing()); |   822     ASSERT(is_optimizing()); | 
|   826     code.set_stackmaps( |   823     code.set_stackmaps( | 
|   827         Array::Handle(stackmap_table_builder_->FinalizeStackmaps(code))); |   824         Array::Handle(stackmap_table_builder_->FinalizeStackmaps(code))); | 
|   828   } |   825   } | 
|   829 } |   826 } | 
|   830  |   827  | 
|   831  |   828  | 
|   832 void FlowGraphCompiler::FinalizeVarDescriptors(const Code& code) { |   829 void FlowGraphCompiler::FinalizeVarDescriptors(const Code& code) { | 
|   833   LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle(); |   830   const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( | 
|   834   if (parsed_function().node_sequence() == NULL) { |   831           parsed_function_.node_sequence()->scope()->GetVarDescriptors( | 
|   835     ASSERT(flow_graph().IsIrregexpFunction()); |   832               parsed_function_.function())); | 
|   836     var_descs = LocalVarDescriptors::New(1); |  | 
|   837     RawLocalVarDescriptors::VarInfo info; |  | 
|   838     info.set_kind(RawLocalVarDescriptors::kSavedCurrentContext); |  | 
|   839     info.scope_id = 0; |  | 
|   840     info.begin_pos = 0; |  | 
|   841     info.end_pos = 0; |  | 
|   842     info.set_index(parsed_function().current_context_var()->index()); |  | 
|   843     var_descs.SetVar(0, Symbols::CurrentContextVar(), &info); |  | 
|   844   } else { |  | 
|   845     var_descs = |  | 
|   846         parsed_function_.node_sequence()->scope()->GetVarDescriptors( |  | 
|   847             parsed_function_.function()); |  | 
|   848   } |  | 
|   849   code.set_var_descriptors(var_descs); |   833   code.set_var_descriptors(var_descs); | 
|   850 } |   834 } | 
|   851  |   835  | 
|   852  |   836  | 
|   853 void FlowGraphCompiler::FinalizeStaticCallTargetsTable(const Code& code) { |   837 void FlowGraphCompiler::FinalizeStaticCallTargetsTable(const Code& code) { | 
|   854   ASSERT(code.static_calls_target_table() == Array::null()); |   838   ASSERT(code.static_calls_target_table() == Array::null()); | 
|   855   code.set_static_calls_target_table( |   839   code.set_static_calls_target_table( | 
|   856       Array::Handle(Array::MakeArray(static_calls_target_table_))); |   840       Array::Handle(Array::MakeArray(static_calls_target_table_))); | 
|   857 } |   841 } | 
|   858  |   842  | 
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1526     case kUnboxedMint: |  1510     case kUnboxedMint: | 
|  1527       return mint_class(); |  1511       return mint_class(); | 
|  1528     default: |  1512     default: | 
|  1529       UNREACHABLE(); |  1513       UNREACHABLE(); | 
|  1530       return Class::ZoneHandle(); |  1514       return Class::ZoneHandle(); | 
|  1531   } |  1515   } | 
|  1532 } |  1516 } | 
|  1533  |  1517  | 
|  1534  |  1518  | 
|  1535 }  // namespace dart |  1519 }  // namespace dart | 
| OLD | NEW |