| 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/debugger.h" | 10 #include "vm/debugger.h" |
| 10 #include "vm/il_printer.h" | 11 #include "vm/il_printer.h" |
| 11 #include "vm/intrinsifier.h" | 12 #include "vm/intrinsifier.h" |
| 12 #include "vm/locations.h" | 13 #include "vm/locations.h" |
| 13 #include "vm/longjump.h" | 14 #include "vm/longjump.h" |
| 14 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
| 15 #include "vm/parser.h" | 16 #include "vm/parser.h" |
| 16 #include "vm/stub_code.h" | 17 #include "vm/stub_code.h" |
| 17 | 18 |
| 18 namespace dart { | 19 namespace dart { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void FlowGraphCompiler::InitCompiler() { | 74 void FlowGraphCompiler::InitCompiler() { |
| 74 pc_descriptors_list_ = new DescriptorList(); | 75 pc_descriptors_list_ = new DescriptorList(); |
| 75 exception_handlers_list_ = new ExceptionHandlerList(); | 76 exception_handlers_list_ = new ExceptionHandlerList(); |
| 76 block_info_.Clear(); | 77 block_info_.Clear(); |
| 77 for (int i = 0; i < block_order_.length(); ++i) { | 78 for (int i = 0; i < block_order_.length(); ++i) { |
| 78 block_info_.Add(new BlockInfo()); | 79 block_info_.Add(new BlockInfo()); |
| 79 } | 80 } |
| 80 } | 81 } |
| 81 | 82 |
| 82 | 83 |
| 84 bool FlowGraphCompiler::CanOptimize() { |
| 85 return !FLAG_report_usage_count && |
| 86 (FLAG_optimization_counter_threshold >= 0) && |
| 87 !Isolate::Current()->debugger()->IsActive(); |
| 88 } |
| 89 |
| 90 |
| 83 void FlowGraphCompiler::VisitBlocks() { | 91 void FlowGraphCompiler::VisitBlocks() { |
| 84 for (intptr_t i = 0; i < block_order().length(); ++i) { | 92 for (intptr_t i = 0; i < block_order().length(); ++i) { |
| 85 ASSERT(frame_register_allocator()->IsSpilled()); | 93 ASSERT(frame_register_allocator()->IsSpilled()); |
| 86 assembler()->Comment("B%d", i); | 94 assembler()->Comment("B%d", i); |
| 87 // Compile the block entry. | 95 // Compile the block entry. |
| 88 set_current_block(block_order()[i]); | 96 set_current_block(block_order()[i]); |
| 89 current_block()->PrepareEntry(this); | 97 current_block()->PrepareEntry(this); |
| 90 Instruction* instr = current_block()->StraightLineSuccessor(); | 98 Instruction* instr = current_block()->StraightLineSuccessor(); |
| 91 // Compile all successors until an exit, branch, or a block entry. | 99 // Compile all successors until an exit, branch, or a block entry. |
| 92 while ((instr != NULL) && !instr->IsBlockEntry()) { | 100 while ((instr != NULL) && !instr->IsBlockEntry()) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 parsed_function_.function())); | 232 parsed_function_.function())); |
| 225 code.set_var_descriptors(var_descs); | 233 code.set_var_descriptors(var_descs); |
| 226 } | 234 } |
| 227 | 235 |
| 228 | 236 |
| 229 void FlowGraphCompiler::FinalizeComments(const Code& code) { | 237 void FlowGraphCompiler::FinalizeComments(const Code& code) { |
| 230 code.set_comments(assembler()->GetCodeComments()); | 238 code.set_comments(assembler()->GetCodeComments()); |
| 231 } | 239 } |
| 232 | 240 |
| 233 | 241 |
| 234 static bool CanOptimize() { | |
| 235 return !FLAG_report_usage_count && | |
| 236 (FLAG_optimization_counter_threshold >= 0) && | |
| 237 !Isolate::Current()->debugger()->IsActive(); | |
| 238 } | |
| 239 | |
| 240 | |
| 241 // Returns 'true' if code generation for this function is complete, i.e., | 242 // Returns 'true' if code generation for this function is complete, i.e., |
| 242 // no fall-through to regular code is needed. | 243 // no fall-through to regular code is needed. |
| 243 bool FlowGraphCompiler::TryIntrinsify() { | 244 bool FlowGraphCompiler::TryIntrinsify() { |
| 244 if (!CanOptimize()) return false; | 245 if (!CanOptimize()) return false; |
| 245 // Intrinsification skips arguments checks, therefore disable if in checked | 246 // Intrinsification skips arguments checks, therefore disable if in checked |
| 246 // mode. | 247 // mode. |
| 247 if (FLAG_intrinsify && !FLAG_trace_functions && !FLAG_enable_type_checks) { | 248 if (FLAG_intrinsify && !FLAG_trace_functions && !FLAG_enable_type_checks) { |
| 248 if ((parsed_function().function().kind() == RawFunction::kImplicitGetter)) { | 249 if ((parsed_function().function().kind() == RawFunction::kImplicitGetter)) { |
| 249 // An implicit getter must have a specific AST structure. | 250 // An implicit getter must have a specific AST structure. |
| 250 const SequenceNode& sequence_node = *parsed_function().node_sequence(); | 251 const SequenceNode& sequence_node = *parsed_function().node_sequence(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 const Array& argument_names, | 289 const Array& argument_names, |
| 289 intptr_t checked_argument_count) { | 290 intptr_t checked_argument_count) { |
| 290 ASSERT(!IsLeaf()); | 291 ASSERT(!IsLeaf()); |
| 291 ASSERT(frame_register_allocator()->IsSpilled()); | 292 ASSERT(frame_register_allocator()->IsSpilled()); |
| 292 ICData& ic_data = | 293 ICData& ic_data = |
| 293 ICData::ZoneHandle(ICData::New(parsed_function().function(), | 294 ICData::ZoneHandle(ICData::New(parsed_function().function(), |
| 294 function_name, | 295 function_name, |
| 295 cid, | 296 cid, |
| 296 checked_argument_count)); | 297 checked_argument_count)); |
| 297 const Array& arguments_descriptor = | 298 const Array& arguments_descriptor = |
| 298 CodeGenerator::ArgumentsDescriptor(argument_count, argument_names); | 299 DartEntry::ArgumentsDescriptor(argument_count, argument_names); |
| 299 uword label_address = 0; | 300 uword label_address = 0; |
| 300 switch (checked_argument_count) { | 301 switch (checked_argument_count) { |
| 301 case 1: | 302 case 1: |
| 302 label_address = StubCode::OneArgCheckInlineCacheEntryPoint(); | 303 label_address = StubCode::OneArgCheckInlineCacheEntryPoint(); |
| 303 break; | 304 break; |
| 304 case 2: | 305 case 2: |
| 305 label_address = StubCode::TwoArgsCheckInlineCacheEntryPoint(); | 306 label_address = StubCode::TwoArgsCheckInlineCacheEntryPoint(); |
| 306 break; | 307 break; |
| 307 default: | 308 default: |
| 308 UNIMPLEMENTED(); | 309 UNIMPLEMENTED(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 323 | 324 |
| 324 void FlowGraphCompiler::GenerateStaticCall(intptr_t cid, | 325 void FlowGraphCompiler::GenerateStaticCall(intptr_t cid, |
| 325 intptr_t token_pos, | 326 intptr_t token_pos, |
| 326 intptr_t try_index, | 327 intptr_t try_index, |
| 327 const Function& function, | 328 const Function& function, |
| 328 intptr_t argument_count, | 329 intptr_t argument_count, |
| 329 const Array& argument_names) { | 330 const Array& argument_names) { |
| 330 ASSERT(frame_register_allocator()->IsSpilled()); | 331 ASSERT(frame_register_allocator()->IsSpilled()); |
| 331 | 332 |
| 332 const Array& arguments_descriptor = | 333 const Array& arguments_descriptor = |
| 333 CodeGenerator::ArgumentsDescriptor(argument_count, argument_names); | 334 DartEntry::ArgumentsDescriptor(argument_count, argument_names); |
| 334 const intptr_t descr_offset = EmitStaticCall(function, | 335 const intptr_t descr_offset = EmitStaticCall(function, |
| 335 arguments_descriptor, | 336 arguments_descriptor, |
| 336 argument_count); | 337 argument_count); |
| 337 pc_descriptors_list()->AddDescriptor(PcDescriptors::kFuncCall, | 338 pc_descriptors_list()->AddDescriptor(PcDescriptors::kFuncCall, |
| 338 descr_offset, | 339 descr_offset, |
| 339 cid, | 340 cid, |
| 340 token_pos, | 341 token_pos, |
| 341 try_index); | 342 try_index); |
| 342 } | 343 } |
| 343 | 344 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 | 622 |
| 622 | 623 |
| 623 void FrameRegisterAllocator::SpillInDeoptStub(DeoptimizationStub* stub) { | 624 void FrameRegisterAllocator::SpillInDeoptStub(DeoptimizationStub* stub) { |
| 624 for (int i = 0; i < stack_.length(); i++) { | 625 for (int i = 0; i < stack_.length(); i++) { |
| 625 stub->Push(stack_[i]); | 626 stub->Push(stack_[i]); |
| 626 } | 627 } |
| 627 } | 628 } |
| 628 | 629 |
| 629 | 630 |
| 630 } // namespace dart | 631 } // namespace dart |
| OLD | NEW |