| 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 #define DEFINE_ACCEPT(ShortName) \ | 66 #define DEFINE_ACCEPT(ShortName) \ |
| 67 void ShortName##Instr::Accept(FlowGraphVisitor* visitor) { \ | 67 void ShortName##Instr::Accept(FlowGraphVisitor* visitor) { \ |
| 68 visitor->Visit##ShortName(this); \ | 68 visitor->Visit##ShortName(this); \ |
| 69 } | 69 } |
| 70 | 70 |
| 71 FOR_EACH_INSTRUCTION(DEFINE_ACCEPT) | 71 FOR_EACH_INSTRUCTION(DEFINE_ACCEPT) |
| 72 | 72 |
| 73 #undef DEFINE_ACCEPT | 73 #undef DEFINE_ACCEPT |
| 74 | 74 |
| 75 | 75 |
| 76 void ForwardInstructionIterator::RemoveCurrentFromGraph() { |
| 77 ASSERT(!current_->IsBlockEntry()); |
| 78 ASSERT(!current_->IsBranch()); |
| 79 ASSERT(!current_->IsThrow()); |
| 80 ASSERT(!current_->IsReturn()); |
| 81 ASSERT(!current_->IsReThrow()); |
| 82 ASSERT(current_->previous() != NULL); |
| 83 Instruction* prev = current_->previous(); |
| 84 Instruction* next = current_->next(); |
| 85 prev->set_next(next); |
| 86 ASSERT(next != NULL); |
| 87 if (current_ != block_entry_->last_instruction()) { |
| 88 ASSERT(!next->IsBlockEntry()); |
| 89 next->set_previous(prev); |
| 90 } else { |
| 91 ASSERT(current_->IsBind()); |
| 92 // Removing the last instruction of a block. |
| 93 // Update last_instruction of the current basic block. |
| 94 block_entry_->set_last_instruction(prev); |
| 95 } |
| 96 // Reset successor and previous instruction to indicate |
| 97 // that the instruction is removed from the graph. |
| 98 current_->set_previous(NULL); |
| 99 current_->set_next(NULL); |
| 100 current_ = prev; |
| 101 } |
| 102 |
| 103 |
| 76 // True iff. the v2 is above v1 on stack, or one of them is constant. | 104 // True iff. the v2 is above v1 on stack, or one of them is constant. |
| 77 static bool VerifyValues(Value* v1, Value* v2) { | 105 static bool VerifyValues(Value* v1, Value* v2) { |
| 78 ASSERT(v1->IsUse() && v2->IsUse()); | 106 ASSERT(v1->IsUse() && v2->IsUse()); |
| 79 return (v1->AsUse()->definition()->temp_index() + 1) == | 107 return (v1->AsUse()->definition()->temp_index() + 1) == |
| 80 v2->AsUse()->definition()->temp_index(); | 108 v2->AsUse()->definition()->temp_index(); |
| 81 } | 109 } |
| 82 | 110 |
| 83 | 111 |
| 84 // Default implementation of visiting basic blocks. Can be overridden. | 112 // Default implementation of visiting basic blocks. Can be overridden. |
| 85 void FlowGraphVisitor::VisitBlocks() { | 113 void FlowGraphVisitor::VisitBlocks() { |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 phis_->Add(NULL); | 528 phis_->Add(NULL); |
| 501 } | 529 } |
| 502 } | 530 } |
| 503 ASSERT((*phis_)[var_index] == NULL); | 531 ASSERT((*phis_)[var_index] == NULL); |
| 504 (*phis_)[var_index] = new PhiInstr(PredecessorCount()); | 532 (*phis_)[var_index] = new PhiInstr(PredecessorCount()); |
| 505 phi_count_++; | 533 phi_count_++; |
| 506 } | 534 } |
| 507 | 535 |
| 508 | 536 |
| 509 intptr_t Instruction::SuccessorCount() const { | 537 intptr_t Instruction::SuccessorCount() const { |
| 510 ASSERT(!IsBranch()); | |
| 511 ASSERT(!IsGraphEntry()); | |
| 512 ASSERT(next() == NULL || next()->IsBlockEntry()); | 538 ASSERT(next() == NULL || next()->IsBlockEntry()); |
| 513 return (next() != NULL) ? 1 : 0; | 539 return (next() != NULL) ? 1 : 0; |
| 514 } | 540 } |
| 515 | 541 |
| 516 | 542 |
| 517 BlockEntryInstr* Instruction::SuccessorAt(intptr_t index) const { | 543 BlockEntryInstr* Instruction::SuccessorAt(intptr_t index) const { |
| 518 return next()->AsBlockEntry(); | 544 return next()->AsBlockEntry(); |
| 519 } | 545 } |
| 520 | 546 |
| 521 | 547 |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); | 1319 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); |
| 1294 compiler->GenerateCall(token_pos(), try_index(), &label, | 1320 compiler->GenerateCall(token_pos(), try_index(), &label, |
| 1295 PcDescriptors::kOther); | 1321 PcDescriptors::kOther); |
| 1296 __ Drop(2); // Discard type arguments and receiver. | 1322 __ Drop(2); // Discard type arguments and receiver. |
| 1297 } | 1323 } |
| 1298 | 1324 |
| 1299 | 1325 |
| 1300 #undef __ | 1326 #undef __ |
| 1301 | 1327 |
| 1302 } // namespace dart | 1328 } // namespace dart |
| OLD | NEW |