| 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/cha.h" | 10 #include "vm/cha.h" |
| 10 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 11 #include "vm/debugger.h" | 12 #include "vm/debugger.h" |
| 12 #include "vm/deopt_instructions.h" | 13 #include "vm/deopt_instructions.h" |
| 13 #include "vm/exceptions.h" | 14 #include "vm/exceptions.h" |
| 14 #include "vm/flow_graph_allocator.h" | 15 #include "vm/flow_graph_allocator.h" |
| 15 #include "vm/il_printer.h" | 16 #include "vm/il_printer.h" |
| 16 #include "vm/intrinsifier.h" | 17 #include "vm/intrinsifier.h" |
| 17 #include "vm/locations.h" | 18 #include "vm/locations.h" |
| 18 #include "vm/longjump.h" | 19 #include "vm/longjump.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 const Script& s = Script::Handle(function.script()); | 307 const Script& s = Script::Handle(function.script()); |
| 307 intptr_t line_nr; | 308 intptr_t line_nr; |
| 308 intptr_t column_nr; | 309 intptr_t column_nr; |
| 309 s.GetTokenLocation(instr->token_pos(), &line_nr, &column_nr); | 310 s.GetTokenLocation(instr->token_pos(), &line_nr, &column_nr); |
| 310 const String& line = String::Handle(s.GetLine(line_nr)); | 311 const String& line = String::Handle(s.GetLine(line_nr)); |
| 311 assembler()->Comment("Line %" Pd " in '%s':\n %s", | 312 assembler()->Comment("Line %" Pd " in '%s':\n %s", |
| 312 line_nr, function.ToFullyQualifiedCString(), line.ToCString()); | 313 line_nr, function.ToFullyQualifiedCString(), line.ToCString()); |
| 313 } | 314 } |
| 314 | 315 |
| 315 | 316 |
| 317 static void LoopInfoComment( |
| 318 Assembler* assembler, |
| 319 const BlockEntryInstr& block, |
| 320 const ZoneGrowableArray<BlockEntryInstr*>& loop_headers) { |
| 321 if (Assembler::EmittingComments()) { |
| 322 for (intptr_t loop_id = 0; loop_id < loop_headers.length(); ++loop_id) { |
| 323 for (BitVector::Iterator loop_it(loop_headers[loop_id]->loop_info()); |
| 324 !loop_it.Done(); |
| 325 loop_it.Advance()) { |
| 326 if (loop_it.Current() == block.preorder_number()) { |
| 327 assembler->Comment(" Loop %" Pd "", loop_id); |
| 328 } |
| 329 } |
| 330 } |
| 331 } |
| 332 } |
| 333 |
| 334 |
| 316 void FlowGraphCompiler::VisitBlocks() { | 335 void FlowGraphCompiler::VisitBlocks() { |
| 317 CompactBlocks(); | 336 CompactBlocks(); |
| 337 const ZoneGrowableArray<BlockEntryInstr*>* loop_headers = NULL; |
| 338 if (Assembler::EmittingComments()) { |
| 339 // 'loop_headers' were cleared, recompute. |
| 340 loop_headers = flow_graph().ComputeLoops(); |
| 341 ASSERT(loop_headers != NULL); |
| 342 } |
| 318 | 343 |
| 319 for (intptr_t i = 0; i < block_order().length(); ++i) { | 344 for (intptr_t i = 0; i < block_order().length(); ++i) { |
| 320 // Compile the block entry. | 345 // Compile the block entry. |
| 321 BlockEntryInstr* entry = block_order()[i]; | 346 BlockEntryInstr* entry = block_order()[i]; |
| 322 assembler()->Comment("B%" Pd "", entry->block_id()); | 347 assembler()->Comment("B%" Pd "", entry->block_id()); |
| 323 set_current_block(entry); | 348 set_current_block(entry); |
| 324 | 349 |
| 325 if (WasCompacted(entry)) { | 350 if (WasCompacted(entry)) { |
| 326 continue; | 351 continue; |
| 327 } | 352 } |
| 328 | 353 |
| 354 LoopInfoComment(assembler(), *entry, *loop_headers); |
| 355 |
| 329 entry->EmitNativeCode(this); | 356 entry->EmitNativeCode(this); |
| 330 // Compile all successors until an exit, branch, or a block entry. | 357 // Compile all successors until an exit, branch, or a block entry. |
| 331 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { | 358 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { |
| 332 Instruction* instr = it.Current(); | 359 Instruction* instr = it.Current(); |
| 333 if (FLAG_code_comments || | 360 if (FLAG_code_comments || |
| 334 FLAG_disassemble || | 361 FLAG_disassemble || |
| 335 FLAG_disassemble_optimized) { | 362 FLAG_disassemble_optimized) { |
| 336 if (FLAG_source_lines) { | 363 if (FLAG_source_lines) { |
| 337 EmitSourceLine(instr); | 364 EmitSourceLine(instr); |
| 338 } | 365 } |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 } | 1423 } |
| 1397 const ICData& ic_data = ICData::ZoneHandle(isolate(), ICData::New( | 1424 const ICData& ic_data = ICData::ZoneHandle(isolate(), ICData::New( |
| 1398 parsed_function().function(), String::Handle(isolate(), target.name()), | 1425 parsed_function().function(), String::Handle(isolate(), target.name()), |
| 1399 arguments_descriptor, deopt_id, num_args_tested)); | 1426 arguments_descriptor, deopt_id, num_args_tested)); |
| 1400 ic_data.AddTarget(target); | 1427 ic_data.AddTarget(target); |
| 1401 (*deopt_id_to_ic_data_)[deopt_id] = &ic_data; | 1428 (*deopt_id_to_ic_data_)[deopt_id] = &ic_data; |
| 1402 return &ic_data; | 1429 return &ic_data; |
| 1403 } | 1430 } |
| 1404 | 1431 |
| 1405 } // namespace dart | 1432 } // namespace dart |
| OLD | NEW |