| 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_allocator.h" | 10 #include "vm/flow_graph_allocator.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 const Object& Value::BoundConstant() const { | 232 const Object& Value::BoundConstant() const { |
| 233 ASSERT(BindsToConstant()); | 233 ASSERT(BindsToConstant()); |
| 234 ConstantInstr* constant = definition()->AsConstant(); | 234 ConstantInstr* constant = definition()->AsConstant(); |
| 235 ASSERT(constant != NULL); | 235 ASSERT(constant != NULL); |
| 236 return constant->value(); | 236 return constant->value(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 | 239 |
| 240 GraphEntryInstr::GraphEntryInstr(const ParsedFunction& parsed_function, | 240 GraphEntryInstr::GraphEntryInstr(const ParsedFunction& parsed_function, |
| 241 TargetEntryInstr* normal_entry, | 241 TargetEntryInstr* normal_entry) |
| 242 intptr_t osr_id) | |
| 243 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex), | 242 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex), |
| 244 parsed_function_(parsed_function), | 243 parsed_function_(parsed_function), |
| 245 normal_entry_(normal_entry), | 244 normal_entry_(normal_entry), |
| 246 catch_entries_(), | 245 catch_entries_(), |
| 247 initial_definitions_(), | 246 initial_definitions_(), |
| 248 osr_id_(osr_id), | |
| 249 spill_slot_count_(0), | 247 spill_slot_count_(0), |
| 250 fixed_slot_count_(0) { | 248 fixed_slot_count_(0) { |
| 251 } | 249 } |
| 252 | 250 |
| 253 | 251 |
| 254 ConstantInstr* GraphEntryInstr::constant_null() { | 252 ConstantInstr* GraphEntryInstr::constant_null() { |
| 255 ASSERT(initial_definitions_.length() > 0); | 253 ASSERT(initial_definitions_.length() > 0); |
| 256 for (intptr_t i = 0; i < initial_definitions_.length(); ++i) { | 254 for (intptr_t i = 0; i < initial_definitions_.length(); ++i) { |
| 257 ConstantInstr* defn = initial_definitions_[i]->AsConstant(); | 255 ConstantInstr* defn = initial_definitions_[i]->AsConstant(); |
| 258 if (defn != NULL && defn->value().IsNull()) return defn; | 256 if (defn != NULL && defn->value().IsNull()) return defn; |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 variable_count, | 773 variable_count, |
| 776 fixed_parameter_count); | 774 fixed_parameter_count); |
| 777 } | 775 } |
| 778 | 776 |
| 779 // 6. Assign postorder number and add the block entry to the list. | 777 // 6. Assign postorder number and add the block entry to the list. |
| 780 set_postorder_number(postorder->length()); | 778 set_postorder_number(postorder->length()); |
| 781 postorder->Add(this); | 779 postorder->Add(this); |
| 782 } | 780 } |
| 783 | 781 |
| 784 | 782 |
| 785 bool BlockEntryInstr::PruneUnreachable(FlowGraphBuilder* builder, | |
| 786 GraphEntryInstr* graph_entry, | |
| 787 intptr_t osr_id, | |
| 788 BitVector* block_marks) { | |
| 789 // Search for the instruction with the OSR id. Use a depth first search | |
| 790 // because basic blocks have not been discovered yet. Prune unreachable | |
| 791 // blocks by replacing the normal entry with a jump to the block | |
| 792 // containing the OSR entry point. | |
| 793 | |
| 794 // Do not visit blocks more than once. | |
| 795 if (block_marks->Contains(block_id())) return false; | |
| 796 block_marks->Add(block_id()); | |
| 797 | |
| 798 // Search this block for the OSR id. | |
| 799 Instruction* instr = this; | |
| 800 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) { | |
| 801 instr = it.Current(); | |
| 802 if (instr->GetDeoptId() == osr_id) { | |
| 803 // Sanity check that we found a stack check instruction. | |
| 804 ASSERT(instr->IsCheckStackOverflow()); | |
| 805 // Loop stack check checks are always in join blocks so that they can | |
| 806 // be the target of a goto. | |
| 807 ASSERT(IsJoinEntry()); | |
| 808 // The instruction should be the first instruction in the block so | |
| 809 // we can simply jump to the beginning of the block. | |
| 810 ASSERT(instr->previous() == this); | |
| 811 | |
| 812 GotoInstr* goto_join = new GotoInstr(AsJoinEntry()); | |
| 813 goto_join->deopt_id_ = deopt_id_; | |
| 814 graph_entry->normal_entry()->LinkTo(goto_join); | |
| 815 return true; | |
| 816 } | |
| 817 } | |
| 818 | |
| 819 // Recursively search the successors. | |
| 820 for (intptr_t i = instr->SuccessorCount() - 1; i >= 0; --i) { | |
| 821 if (instr->SuccessorAt(i)->PruneUnreachable(builder, | |
| 822 graph_entry, | |
| 823 osr_id, | |
| 824 block_marks)) { | |
| 825 return true; | |
| 826 } | |
| 827 } | |
| 828 return false; | |
| 829 } | |
| 830 | |
| 831 | |
| 832 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const { | 783 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const { |
| 833 // TODO(fschneider): Make this faster by e.g. storing dominators for each | 784 // TODO(fschneider): Make this faster by e.g. storing dominators for each |
| 834 // block while computing the dominator tree. | 785 // block while computing the dominator tree. |
| 835 ASSERT(other != NULL); | 786 ASSERT(other != NULL); |
| 836 BlockEntryInstr* current = other; | 787 BlockEntryInstr* current = other; |
| 837 while (current != NULL && current != this) { | 788 while (current != NULL && current != this) { |
| 838 current = current->dominator(); | 789 current = current->dominator(); |
| 839 } | 790 } |
| 840 return current == this; | 791 return current == this; |
| 841 } | 792 } |
| (...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2542 default: | 2493 default: |
| 2543 UNREACHABLE(); | 2494 UNREACHABLE(); |
| 2544 } | 2495 } |
| 2545 return kPowRuntimeEntry; | 2496 return kPowRuntimeEntry; |
| 2546 } | 2497 } |
| 2547 | 2498 |
| 2548 | 2499 |
| 2549 #undef __ | 2500 #undef __ |
| 2550 | 2501 |
| 2551 } // namespace dart | 2502 } // namespace dart |
| OLD | NEW |