| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 267 |
| 268 GraphEntryInstr::GraphEntryInstr(const ParsedFunction& parsed_function, | 268 GraphEntryInstr::GraphEntryInstr(const ParsedFunction& parsed_function, |
| 269 TargetEntryInstr* normal_entry, | 269 TargetEntryInstr* normal_entry, |
| 270 intptr_t osr_id) | 270 intptr_t osr_id) |
| 271 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex), | 271 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex), |
| 272 parsed_function_(parsed_function), | 272 parsed_function_(parsed_function), |
| 273 normal_entry_(normal_entry), | 273 normal_entry_(normal_entry), |
| 274 catch_entries_(), | 274 catch_entries_(), |
| 275 initial_definitions_(), | 275 initial_definitions_(), |
| 276 osr_id_(osr_id), | 276 osr_id_(osr_id), |
| 277 entry_count_(0), |
| 277 spill_slot_count_(0), | 278 spill_slot_count_(0), |
| 278 fixed_slot_count_(0) { | 279 fixed_slot_count_(0) { |
| 279 } | 280 } |
| 280 | 281 |
| 281 | 282 |
| 282 ConstantInstr* GraphEntryInstr::constant_null() { | 283 ConstantInstr* GraphEntryInstr::constant_null() { |
| 283 ASSERT(initial_definitions_.length() > 0); | 284 ASSERT(initial_definitions_.length() > 0); |
| 284 for (intptr_t i = 0; i < initial_definitions_.length(); ++i) { | 285 for (intptr_t i = 0; i < initial_definitions_.length(); ++i) { |
| 285 ConstantInstr* defn = initial_definitions_[i]->AsConstant(); | 286 ConstantInstr* defn = initial_definitions_[i]->AsConstant(); |
| 286 if (defn != NULL && defn->value().IsNull()) return defn; | 287 if (defn != NULL && defn->value().IsNull()) return defn; |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 } | 830 } |
| 830 | 831 |
| 831 // 6. Assign postorder number and add the block entry to the list. | 832 // 6. Assign postorder number and add the block entry to the list. |
| 832 set_postorder_number(postorder->length()); | 833 set_postorder_number(postorder->length()); |
| 833 postorder->Add(this); | 834 postorder->Add(this); |
| 834 } | 835 } |
| 835 | 836 |
| 836 | 837 |
| 837 bool BlockEntryInstr::PruneUnreachable(FlowGraphBuilder* builder, | 838 bool BlockEntryInstr::PruneUnreachable(FlowGraphBuilder* builder, |
| 838 GraphEntryInstr* graph_entry, | 839 GraphEntryInstr* graph_entry, |
| 840 Instruction* parent, |
| 839 intptr_t osr_id, | 841 intptr_t osr_id, |
| 840 BitVector* block_marks) { | 842 BitVector* block_marks) { |
| 841 // Search for the instruction with the OSR id. Use a depth first search | 843 // Search for the instruction with the OSR id. Use a depth first search |
| 842 // because basic blocks have not been discovered yet. Prune unreachable | 844 // because basic blocks have not been discovered yet. Prune unreachable |
| 843 // blocks by replacing the normal entry with a jump to the block | 845 // blocks by replacing the normal entry with a jump to the block |
| 844 // containing the OSR entry point. | 846 // containing the OSR entry point. |
| 845 | 847 |
| 846 // Do not visit blocks more than once. | 848 // Do not visit blocks more than once. |
| 847 if (block_marks->Contains(block_id())) return false; | 849 if (block_marks->Contains(block_id())) return false; |
| 848 block_marks->Add(block_id()); | 850 block_marks->Add(block_id()); |
| 849 | 851 |
| 850 // Search this block for the OSR id. | 852 // Search this block for the OSR id. |
| 851 Instruction* instr = this; | 853 Instruction* instr = this; |
| 852 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) { | 854 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) { |
| 853 instr = it.Current(); | 855 instr = it.Current(); |
| 854 if (instr->GetDeoptId() == osr_id) { | 856 if (instr->GetDeoptId() == osr_id) { |
| 855 // Sanity check that we found a stack check instruction. | 857 // Sanity check that we found a stack check instruction. |
| 856 ASSERT(instr->IsCheckStackOverflow()); | 858 ASSERT(instr->IsCheckStackOverflow()); |
| 857 // Loop stack check checks are always in join blocks so that they can | 859 // Loop stack check checks are always in join blocks so that they can |
| 858 // be the target of a goto. | 860 // be the target of a goto. |
| 859 ASSERT(IsJoinEntry()); | 861 ASSERT(IsJoinEntry()); |
| 860 // The instruction should be the first instruction in the block so | 862 // The instruction should be the first instruction in the block so |
| 861 // we can simply jump to the beginning of the block. | 863 // we can simply jump to the beginning of the block. |
| 862 ASSERT(instr->previous() == this); | 864 ASSERT(instr->previous() == this); |
| 863 | 865 |
| 864 GotoInstr* goto_join = new GotoInstr(AsJoinEntry()); | 866 GotoInstr* goto_join = new GotoInstr(AsJoinEntry()); |
| 865 goto_join->deopt_id_ = deopt_id_; | 867 goto_join->deopt_id_ = parent->deopt_id_; |
| 866 graph_entry->normal_entry()->LinkTo(goto_join); | 868 graph_entry->normal_entry()->LinkTo(goto_join); |
| 867 return true; | 869 return true; |
| 868 } | 870 } |
| 869 } | 871 } |
| 870 | 872 |
| 871 // Recursively search the successors. | 873 // Recursively search the successors. |
| 872 for (intptr_t i = instr->SuccessorCount() - 1; i >= 0; --i) { | 874 for (intptr_t i = instr->SuccessorCount() - 1; i >= 0; --i) { |
| 873 if (instr->SuccessorAt(i)->PruneUnreachable(builder, | 875 if (instr->SuccessorAt(i)->PruneUnreachable(builder, |
| 874 graph_entry, | 876 graph_entry, |
| 877 instr, |
| 875 osr_id, | 878 osr_id, |
| 876 block_marks)) { | 879 block_marks)) { |
| 877 return true; | 880 return true; |
| 878 } | 881 } |
| 879 } | 882 } |
| 880 return false; | 883 return false; |
| 881 } | 884 } |
| 882 | 885 |
| 883 | 886 |
| 884 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const { | 887 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const { |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 } | 1634 } |
| 1632 } | 1635 } |
| 1633 | 1636 |
| 1634 | 1637 |
| 1635 LocationSummary* TargetEntryInstr::MakeLocationSummary() const { | 1638 LocationSummary* TargetEntryInstr::MakeLocationSummary() const { |
| 1636 UNREACHABLE(); | 1639 UNREACHABLE(); |
| 1637 return NULL; | 1640 return NULL; |
| 1638 } | 1641 } |
| 1639 | 1642 |
| 1640 | 1643 |
| 1641 void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | |
| 1642 __ Bind(compiler->GetJumpLabel(this)); | |
| 1643 if (!compiler->is_optimizing()) { | |
| 1644 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, | |
| 1645 deopt_id_, | |
| 1646 Scanner::kDummyTokenIndex); | |
| 1647 } | |
| 1648 if (HasParallelMove()) { | |
| 1649 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); | |
| 1650 } | |
| 1651 } | |
| 1652 | |
| 1653 | |
| 1654 LocationSummary* PhiInstr::MakeLocationSummary() const { | 1644 LocationSummary* PhiInstr::MakeLocationSummary() const { |
| 1655 UNREACHABLE(); | 1645 UNREACHABLE(); |
| 1656 return NULL; | 1646 return NULL; |
| 1657 } | 1647 } |
| 1658 | 1648 |
| 1659 | 1649 |
| 1660 void PhiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1650 void PhiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1661 UNREACHABLE(); | 1651 UNREACHABLE(); |
| 1662 } | 1652 } |
| 1663 | 1653 |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2651 default: | 2641 default: |
| 2652 UNREACHABLE(); | 2642 UNREACHABLE(); |
| 2653 } | 2643 } |
| 2654 return kPowRuntimeEntry; | 2644 return kPowRuntimeEntry; |
| 2655 } | 2645 } |
| 2656 | 2646 |
| 2657 | 2647 |
| 2658 #undef __ | 2648 #undef __ |
| 2659 | 2649 |
| 2660 } // namespace dart | 2650 } // namespace dart |
| OLD | NEW |