Chromium Code Reviews| 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/flow_graph_allocator.h" | 5 #include "vm/flow_graph_allocator.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 #include "vm/il_printer.h" | 9 #include "vm/il_printer.h" |
| 10 #include "vm/flow_graph.h" | 10 #include "vm/flow_graph.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 static intptr_t ToInstructionStart(intptr_t pos) { | 53 static intptr_t ToInstructionStart(intptr_t pos) { |
| 54 return (pos & ~1); | 54 return (pos & ~1); |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 static intptr_t ToInstructionEnd(intptr_t pos) { | 58 static intptr_t ToInstructionEnd(intptr_t pos) { |
| 59 return (pos | 1); | 59 return (pos | 1); |
| 60 } | 60 } |
| 61 | 61 |
| 62 | 62 |
| 63 static intptr_t NextInstructionPos(intptr_t pos) { | |
| 64 ASSERT(IsInstructionStartPosition(pos)); | |
| 65 return pos + 2; | |
| 66 } | |
| 67 | |
| 68 | |
| 63 FlowGraphAllocator::FlowGraphAllocator(const FlowGraph& flow_graph) | 69 FlowGraphAllocator::FlowGraphAllocator(const FlowGraph& flow_graph) |
| 64 : flow_graph_(flow_graph), | 70 : flow_graph_(flow_graph), |
| 65 reaching_defs_(flow_graph), | 71 reaching_defs_(flow_graph), |
| 66 value_representations_(flow_graph.max_virtual_register_number()), | 72 value_representations_(flow_graph.max_virtual_register_number()), |
| 67 block_order_(flow_graph.reverse_postorder()), | 73 block_order_(flow_graph.reverse_postorder()), |
| 68 postorder_(flow_graph.postorder()), | 74 postorder_(flow_graph.postorder()), |
| 69 liveness_(flow_graph), | 75 liveness_(flow_graph), |
| 70 vreg_count_(flow_graph.max_virtual_register_number()), | 76 vreg_count_(flow_graph.max_virtual_register_number()), |
| 71 live_ranges_(flow_graph.max_virtual_register_number()), | 77 live_ranges_(flow_graph.max_virtual_register_number()), |
| 72 cpu_regs_(), | 78 cpu_regs_(), |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 // Process initial definitions. | 511 // Process initial definitions. |
| 506 CatchBlockEntryInstr* catch_entry = block->AsCatchBlockEntry(); | 512 CatchBlockEntryInstr* catch_entry = block->AsCatchBlockEntry(); |
| 507 for (intptr_t i = 0; | 513 for (intptr_t i = 0; |
| 508 i < catch_entry->initial_definitions()->length(); | 514 i < catch_entry->initial_definitions()->length(); |
| 509 i++) { | 515 i++) { |
| 510 Definition* defn = (*catch_entry->initial_definitions())[i]; | 516 Definition* defn = (*catch_entry->initial_definitions())[i]; |
| 511 LiveRange* range = GetLiveRange(defn->ssa_temp_index()); | 517 LiveRange* range = GetLiveRange(defn->ssa_temp_index()); |
| 512 range->DefineAt(catch_entry->start_pos()); // Defined at block entry. | 518 range->DefineAt(catch_entry->start_pos()); // Defined at block entry. |
| 513 ProcessInitialDefinition(defn, range, catch_entry); | 519 ProcessInitialDefinition(defn, range, catch_entry); |
| 514 } | 520 } |
| 521 // Block the two registers used by CatchEntryInstr from the block start to | |
| 522 // until the end of the instruction so that they are preserved. | |
| 523 intptr_t start = catch_entry->start_pos(); | |
| 524 BlockLocation(Location::RegisterLocation(kExceptionObjectReg), | |
| 525 start, | |
| 526 ToInstructionEnd(NextInstructionPos(start))); | |
| 527 BlockLocation(Location::RegisterLocation(kStackTraceObjectReg), | |
| 528 start, | |
| 529 ToInstructionEnd(NextInstructionPos(start))); | |
|
Vyacheslav Egorov (Google)
2013/06/17 15:11:39
Assert that the next instruction is actually Catch
Florian Schneider
2013/06/17 17:35:35
Done.
| |
| 515 } | 530 } |
| 516 } | 531 } |
| 517 | 532 |
| 518 // Process incoming parameters and constants. Do this after all other | 533 // Process incoming parameters and constants. Do this after all other |
| 519 // instructions so that safepoints for all calls have already been found. | 534 // instructions so that safepoints for all calls have already been found. |
| 520 GraphEntryInstr* graph_entry = flow_graph_.graph_entry(); | 535 GraphEntryInstr* graph_entry = flow_graph_.graph_entry(); |
| 521 for (intptr_t i = 0; i < graph_entry->initial_definitions()->length(); i++) { | 536 for (intptr_t i = 0; i < graph_entry->initial_definitions()->length(); i++) { |
| 522 Definition* defn = (*graph_entry->initial_definitions())[i]; | 537 Definition* defn = (*graph_entry->initial_definitions())[i]; |
| 523 LiveRange* range = GetLiveRange(defn->ssa_temp_index()); | 538 LiveRange* range = GetLiveRange(defn->ssa_temp_index()); |
| 524 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); | 539 range->AddUseInterval(graph_entry->start_pos(), graph_entry->end_pos()); |
| (...skipping 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2585 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", | 2600 OS::Print("-- [after ssa allocator] ir [%s] -------------\n", |
| 2586 function.ToFullyQualifiedCString()); | 2601 function.ToFullyQualifiedCString()); |
| 2587 FlowGraphPrinter printer(flow_graph_, true); | 2602 FlowGraphPrinter printer(flow_graph_, true); |
| 2588 printer.PrintBlocks(); | 2603 printer.PrintBlocks(); |
| 2589 OS::Print("----------------------------------------------\n"); | 2604 OS::Print("----------------------------------------------\n"); |
| 2590 } | 2605 } |
| 2591 } | 2606 } |
| 2592 | 2607 |
| 2593 | 2608 |
| 2594 } // namespace dart | 2609 } // namespace dart |
| OLD | NEW |