| 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/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/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 builder.AddCopy(inner->LocationAt(i), *inner->ValueAt(i), slot_ix++); | 132 builder.AddCopy(inner->LocationAt(i), *inner->ValueAt(i), slot_ix++); |
| 133 } | 133 } |
| 134 | 134 |
| 135 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder.CreateDeoptInfo()); | 135 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder.CreateDeoptInfo()); |
| 136 return deopt_info.raw(); | 136 return deopt_info.raw(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 | 139 |
| 140 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, | 140 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, |
| 141 const FlowGraph& flow_graph, | 141 const FlowGraph& flow_graph, |
| 142 bool is_optimizing, | 142 bool is_optimizing) |
| 143 bool is_leaf) | |
| 144 : assembler_(assembler), | 143 : assembler_(assembler), |
| 145 parsed_function_(flow_graph.parsed_function()), | 144 parsed_function_(flow_graph.parsed_function()), |
| 146 block_order_(flow_graph.reverse_postorder()), | 145 block_order_(flow_graph.reverse_postorder()), |
| 147 current_block_(NULL), | 146 current_block_(NULL), |
| 148 exception_handlers_list_(NULL), | 147 exception_handlers_list_(NULL), |
| 149 pc_descriptors_list_(NULL), | 148 pc_descriptors_list_(NULL), |
| 150 stackmap_table_builder_( | 149 stackmap_table_builder_( |
| 151 is_optimizing ? new StackmapTableBuilder() : NULL), | 150 is_optimizing ? new StackmapTableBuilder() : NULL), |
| 152 block_info_(block_order_.length()), | 151 block_info_(block_order_.length()), |
| 153 deopt_infos_(), | 152 deopt_infos_(), |
| 154 object_table_(GrowableObjectArray::Handle(GrowableObjectArray::New())), | 153 object_table_(GrowableObjectArray::Handle(GrowableObjectArray::New())), |
| 155 is_optimizing_(is_optimizing), | 154 is_optimizing_(is_optimizing), |
| 156 is_dart_leaf_(is_leaf), | |
| 157 bool_true_(Bool::ZoneHandle(Bool::True())), | 155 bool_true_(Bool::ZoneHandle(Bool::True())), |
| 158 bool_false_(Bool::ZoneHandle(Bool::False())), | 156 bool_false_(Bool::ZoneHandle(Bool::False())), |
| 159 double_class_(Class::ZoneHandle( | 157 double_class_(Class::ZoneHandle( |
| 160 Isolate::Current()->object_store()->double_class())), | 158 Isolate::Current()->object_store()->double_class())), |
| 161 parallel_move_resolver_(this) { | 159 parallel_move_resolver_(this) { |
| 162 ASSERT(assembler != NULL); | 160 ASSERT(assembler != NULL); |
| 163 } | 161 } |
| 164 | 162 |
| 165 | 163 |
| 166 FlowGraphCompiler::~FlowGraphCompiler() { | 164 FlowGraphCompiler::~FlowGraphCompiler() { |
| 167 // BlockInfos are zone-allocated, so their destructors are not called. | 165 // BlockInfos are zone-allocated, so their destructors are not called. |
| 168 // Verify the labels explicitly here. | 166 // Verify the labels explicitly here. |
| 169 for (int i = 0; i < block_info_.length(); ++i) { | 167 for (int i = 0; i < block_info_.length(); ++i) { |
| 170 ASSERT(!block_info_[i]->label.IsLinked()); | 168 ASSERT(!block_info_[i]->label.IsLinked()); |
| 171 ASSERT(!block_info_[i]->label.HasNear()); | 169 ASSERT(!block_info_[i]->label.HasNear()); |
| 172 } | 170 } |
| 173 } | 171 } |
| 174 | 172 |
| 175 | 173 |
| 176 bool FlowGraphCompiler::IsLeaf() const { | |
| 177 return is_dart_leaf_ && | |
| 178 !parsed_function_.function().IsClosureFunction() && | |
| 179 (parsed_function().num_copied_params() == 0); | |
| 180 } | |
| 181 | |
| 182 | |
| 183 bool FlowGraphCompiler::HasFinally() const { | 174 bool FlowGraphCompiler::HasFinally() const { |
| 184 return parsed_function().function().has_finally(); | 175 return parsed_function().function().has_finally(); |
| 185 } | 176 } |
| 186 | 177 |
| 187 | 178 |
| 188 void FlowGraphCompiler::InitCompiler() { | 179 void FlowGraphCompiler::InitCompiler() { |
| 189 pc_descriptors_list_ = new DescriptorList(64); | 180 pc_descriptors_list_ = new DescriptorList(64); |
| 190 exception_handlers_list_ = new ExceptionHandlerList(); | 181 exception_handlers_list_ = new ExceptionHandlerList(); |
| 191 block_info_.Clear(); | 182 block_info_.Clear(); |
| 192 for (int i = 0; i < block_order_.length(); ++i) { | 183 for (int i = 0; i < block_order_.length(); ++i) { |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 466 |
| 476 | 467 |
| 477 const ICData& FlowGraphCompiler::GenerateInstanceCall( | 468 const ICData& FlowGraphCompiler::GenerateInstanceCall( |
| 478 intptr_t deopt_id, | 469 intptr_t deopt_id, |
| 479 intptr_t token_pos, | 470 intptr_t token_pos, |
| 480 const String& function_name, | 471 const String& function_name, |
| 481 intptr_t argument_count, | 472 intptr_t argument_count, |
| 482 const Array& argument_names, | 473 const Array& argument_names, |
| 483 intptr_t checked_argument_count, | 474 intptr_t checked_argument_count, |
| 484 LocationSummary* locs) { | 475 LocationSummary* locs) { |
| 485 ASSERT(!IsLeaf()); | |
| 486 ICData& ic_data = | 476 ICData& ic_data = |
| 487 ICData::ZoneHandle(ICData::New(parsed_function().function(), | 477 ICData::ZoneHandle(ICData::New(parsed_function().function(), |
| 488 function_name, | 478 function_name, |
| 489 deopt_id, | 479 deopt_id, |
| 490 checked_argument_count)); | 480 checked_argument_count)); |
| 491 const Array& arguments_descriptor = | 481 const Array& arguments_descriptor = |
| 492 DartEntry::ArgumentsDescriptor(argument_count, argument_names); | 482 DartEntry::ArgumentsDescriptor(argument_count, argument_names); |
| 493 uword label_address = 0; | 483 uword label_address = 0; |
| 494 switch (checked_argument_count) { | 484 switch (checked_argument_count) { |
| 495 case 1: | 485 case 1: |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 case ABOVE: return unsigned_left > unsigned_right; | 890 case ABOVE: return unsigned_left > unsigned_right; |
| 901 case ABOVE_EQUAL: return unsigned_left >= unsigned_right; | 891 case ABOVE_EQUAL: return unsigned_left >= unsigned_right; |
| 902 default: | 892 default: |
| 903 UNIMPLEMENTED(); | 893 UNIMPLEMENTED(); |
| 904 return false; | 894 return false; |
| 905 } | 895 } |
| 906 } | 896 } |
| 907 | 897 |
| 908 | 898 |
| 909 } // namespace dart | 899 } // namespace dart |
| OLD | NEW |