| 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/debugger.h" | 9 #include "vm/debugger.h" |
| 10 #include "vm/il_printer.h" | 10 #include "vm/il_printer.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 DECLARE_FLAG(bool, intrinsify); | 24 DECLARE_FLAG(bool, intrinsify); |
| 25 DECLARE_FLAG(bool, report_usage_count); | 25 DECLARE_FLAG(bool, report_usage_count); |
| 26 DECLARE_FLAG(bool, trace_functions); | 26 DECLARE_FLAG(bool, trace_functions); |
| 27 DECLARE_FLAG(int, optimization_counter_threshold); | 27 DECLARE_FLAG(int, optimization_counter_threshold); |
| 28 | 28 |
| 29 | 29 |
| 30 FlowGraphCompiler::FlowGraphCompiler( | 30 FlowGraphCompiler::FlowGraphCompiler( |
| 31 Assembler* assembler, | 31 Assembler* assembler, |
| 32 const ParsedFunction& parsed_function, | 32 const ParsedFunction& parsed_function, |
| 33 const GrowableArray<BlockEntryInstr*>& block_order, | 33 const GrowableArray<BlockEntryInstr*>& block_order, |
| 34 bool is_optimizing) | 34 bool is_optimizing, |
| 35 bool is_leaf) |
| 35 : assembler_(assembler), | 36 : assembler_(assembler), |
| 36 parsed_function_(parsed_function), | 37 parsed_function_(parsed_function), |
| 37 block_order_(block_order), | 38 block_order_(block_order), |
| 38 current_block_(NULL), | 39 current_block_(NULL), |
| 39 exception_handlers_list_(NULL), | 40 exception_handlers_list_(NULL), |
| 40 pc_descriptors_list_(NULL), | 41 pc_descriptors_list_(NULL), |
| 41 stackmap_builder_(NULL), | 42 stackmap_builder_(NULL), |
| 42 block_info_(block_order.length()), | 43 block_info_(block_order.length()), |
| 43 deopt_stubs_(), | 44 deopt_stubs_(), |
| 44 is_optimizing_(is_optimizing), | 45 is_optimizing_(is_optimizing), |
| 46 is_dart_leaf_(is_leaf), |
| 45 bool_true_(Bool::ZoneHandle(Bool::True())), | 47 bool_true_(Bool::ZoneHandle(Bool::True())), |
| 46 bool_false_(Bool::ZoneHandle(Bool::False())), | 48 bool_false_(Bool::ZoneHandle(Bool::False())), |
| 47 double_class_(Class::ZoneHandle( | 49 double_class_(Class::ZoneHandle( |
| 48 Isolate::Current()->object_store()->double_class())), | 50 Isolate::Current()->object_store()->double_class())), |
| 49 frame_register_allocator_(this, is_optimizing) { | 51 frame_register_allocator_(this, is_optimizing) { |
| 50 ASSERT(assembler != NULL); | 52 ASSERT(assembler != NULL); |
| 51 } | 53 } |
| 52 | 54 |
| 53 | 55 |
| 54 FlowGraphCompiler::~FlowGraphCompiler() { | 56 FlowGraphCompiler::~FlowGraphCompiler() { |
| 55 // BlockInfos are zone-allocated, so their destructors are not called. | 57 // BlockInfos are zone-allocated, so their destructors are not called. |
| 56 // Verify the labels explicitly here. | 58 // Verify the labels explicitly here. |
| 57 for (int i = 0; i < block_info_.length(); ++i) { | 59 for (int i = 0; i < block_info_.length(); ++i) { |
| 58 ASSERT(!block_info_[i]->label.IsLinked()); | 60 ASSERT(!block_info_[i]->label.IsLinked()); |
| 59 ASSERT(!block_info_[i]->label.HasNear()); | 61 ASSERT(!block_info_[i]->label.HasNear()); |
| 60 } | 62 } |
| 61 } | 63 } |
| 62 | 64 |
| 63 | 65 |
| 66 bool FlowGraphCompiler::IsLeaf() const { |
| 67 return is_dart_leaf_ && |
| 68 !parsed_function_.function().IsClosureFunction() && |
| 69 (parsed_function().copied_parameter_count() == 0); |
| 70 } |
| 71 |
| 72 |
| 64 void FlowGraphCompiler::InitCompiler() { | 73 void FlowGraphCompiler::InitCompiler() { |
| 65 pc_descriptors_list_ = new DescriptorList(); | 74 pc_descriptors_list_ = new DescriptorList(); |
| 66 exception_handlers_list_ = new ExceptionHandlerList(); | 75 exception_handlers_list_ = new ExceptionHandlerList(); |
| 67 block_info_.Clear(); | 76 block_info_.Clear(); |
| 68 for (int i = 0; i < block_order_.length(); ++i) { | 77 for (int i = 0; i < block_order_.length(); ++i) { |
| 69 block_info_.Add(new BlockInfo()); | 78 block_info_.Add(new BlockInfo()); |
| 70 } | 79 } |
| 71 } | 80 } |
| 72 | 81 |
| 73 | 82 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 280 |
| 272 | 281 |
| 273 void FlowGraphCompiler::GenerateInstanceCall( | 282 void FlowGraphCompiler::GenerateInstanceCall( |
| 274 intptr_t cid, | 283 intptr_t cid, |
| 275 intptr_t token_pos, | 284 intptr_t token_pos, |
| 276 intptr_t try_index, | 285 intptr_t try_index, |
| 277 const String& function_name, | 286 const String& function_name, |
| 278 intptr_t argument_count, | 287 intptr_t argument_count, |
| 279 const Array& argument_names, | 288 const Array& argument_names, |
| 280 intptr_t checked_argument_count) { | 289 intptr_t checked_argument_count) { |
| 290 ASSERT(!IsLeaf()); |
| 281 ASSERT(frame_register_allocator()->IsSpilled()); | 291 ASSERT(frame_register_allocator()->IsSpilled()); |
| 282 ICData& ic_data = | 292 ICData& ic_data = |
| 283 ICData::ZoneHandle(ICData::New(parsed_function().function(), | 293 ICData::ZoneHandle(ICData::New(parsed_function().function(), |
| 284 function_name, | 294 function_name, |
| 285 cid, | 295 cid, |
| 286 checked_argument_count)); | 296 checked_argument_count)); |
| 287 const Array& arguments_descriptor = | 297 const Array& arguments_descriptor = |
| 288 CodeGenerator::ArgumentsDescriptor(argument_count, argument_names); | 298 CodeGenerator::ArgumentsDescriptor(argument_count, argument_names); |
| 289 uword label_address = 0; | 299 uword label_address = 0; |
| 290 switch (checked_argument_count) { | 300 switch (checked_argument_count) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 | 621 |
| 612 | 622 |
| 613 void FrameRegisterAllocator::SpillInDeoptStub(DeoptimizationStub* stub) { | 623 void FrameRegisterAllocator::SpillInDeoptStub(DeoptimizationStub* stub) { |
| 614 for (int i = 0; i < stack_.length(); i++) { | 624 for (int i = 0; i < stack_.length(); i++) { |
| 615 stub->Push(stack_[i]); | 625 stub->Push(stack_[i]); |
| 616 } | 626 } |
| 617 } | 627 } |
| 618 | 628 |
| 619 | 629 |
| 620 } // namespace dart | 630 } // namespace dart |
| OLD | NEW |