Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/instruction-selector.h" | 5 #include "src/compiler/instruction-selector.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/base/adapters.h" | 9 #include "src/base/adapters.h" |
| 10 #include "src/compiler/instruction-selector-impl.h" | 10 #include "src/compiler/instruction-selector-impl.h" |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 780 BasicBlock* tbranch = block->SuccessorAt(0); | 780 BasicBlock* tbranch = block->SuccessorAt(0); |
| 781 BasicBlock* fbranch = block->SuccessorAt(1); | 781 BasicBlock* fbranch = block->SuccessorAt(1); |
| 782 if (tbranch == fbranch) return VisitGoto(tbranch); | 782 if (tbranch == fbranch) return VisitGoto(tbranch); |
| 783 return VisitBranch(input, tbranch, fbranch); | 783 return VisitBranch(input, tbranch, fbranch); |
| 784 } | 784 } |
| 785 case BasicBlock::kSwitch: { | 785 case BasicBlock::kSwitch: { |
| 786 DCHECK_EQ(IrOpcode::kSwitch, input->opcode()); | 786 DCHECK_EQ(IrOpcode::kSwitch, input->opcode()); |
| 787 SwitchInfo sw; | 787 SwitchInfo sw; |
| 788 // Last successor must be Default. | 788 // Last successor must be Default. |
| 789 sw.default_branch = block->successors().back(); | 789 sw.default_branch = block->successors().back(); |
| 790 DCHECK_EQ(IrOpcode::kIfDefault, sw.default_branch->front()->opcode()); | 790 BasicBlock* branch = sw.default_branch; |
| 791 // The scheduler may have inserted a split-edge block between the switch | |
| 792 // and the default label, skip it if necessary. | |
| 793 if (branch->size() == 0) { | |
| 794 DCHECK_EQ(BasicBlock::kGoto, branch->control()); | |
| 795 DCHECK_EQ(1, branch->SuccessorCount()); | |
| 796 DCHECK_EQ(1, branch->PredecessorCount()); | |
| 797 branch = branch->SuccessorAt(0); | |
| 798 } | |
| 799 USE(branch); | |
| 800 DCHECK_EQ(IrOpcode::kIfDefault, branch->front()->opcode()); | |
| 791 // All other successors must be cases. | 801 // All other successors must be cases. |
| 792 sw.case_count = block->SuccessorCount() - 1; | 802 sw.case_count = block->SuccessorCount() - 1; |
| 793 sw.case_branches = &block->successors().front(); | 803 sw.case_branches = &block->successors().front(); |
| 794 // Determine case values and their min/max. | 804 // Determine case values and their min/max. |
| 795 sw.case_values = zone()->NewArray<int32_t>(sw.case_count); | 805 sw.case_values = zone()->NewArray<int32_t>(sw.case_count); |
| 796 sw.min_value = std::numeric_limits<int32_t>::max(); | 806 sw.min_value = std::numeric_limits<int32_t>::max(); |
| 797 sw.max_value = std::numeric_limits<int32_t>::min(); | 807 sw.max_value = std::numeric_limits<int32_t>::min(); |
| 798 for (size_t index = 0; index < sw.case_count; ++index) { | 808 for (size_t index = 0; index < sw.case_count; ++index) { |
| 799 BasicBlock* branch = sw.case_branches[index]; | 809 branch = sw.case_branches[index]; |
| 810 // The scheduler may have inserted a split-edge block between the switch | |
|
titzer
2016/03/21 08:06:03
Not sure this is sound. The split-edge blocks are
danno
2016/03/22 07:53:44
As discussed, moved the logic to ensure the extra
| |
| 811 // and the label, skip it if necessary. | |
| 812 if (branch->size() == 0) { | |
| 813 DCHECK_EQ(BasicBlock::kGoto, branch->control()); | |
| 814 DCHECK_EQ(1, branch->SuccessorCount()); | |
| 815 DCHECK_EQ(1, branch->PredecessorCount()); | |
| 816 branch = branch->SuccessorAt(0); | |
| 817 } | |
| 800 int32_t value = OpParameter<int32_t>(branch->front()->op()); | 818 int32_t value = OpParameter<int32_t>(branch->front()->op()); |
| 801 sw.case_values[index] = value; | 819 sw.case_values[index] = value; |
| 802 if (sw.min_value > value) sw.min_value = value; | 820 if (sw.min_value > value) sw.min_value = value; |
| 803 if (sw.max_value < value) sw.max_value = value; | 821 if (sw.max_value < value) sw.max_value = value; |
| 804 } | 822 } |
| 805 DCHECK_LE(sw.min_value, sw.max_value); | 823 DCHECK_LE(sw.min_value, sw.max_value); |
| 806 // Note that {value_range} can be 0 if {min_value} is -2^31 and | 824 // Note that {value_range} can be 0 if {min_value} is -2^31 and |
| 807 // {max_value} | 825 // {max_value} |
| 808 // is 2^31-1, so don't assume that it's non-zero below. | 826 // is 2^31-1, so don't assume that it's non-zero below. |
| 809 sw.value_range = 1u + bit_cast<uint32_t>(sw.max_value) - | 827 sw.value_range = 1u + bit_cast<uint32_t>(sw.max_value) - |
| (...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1785 return new (instruction_zone()) FrameStateDescriptor( | 1803 return new (instruction_zone()) FrameStateDescriptor( |
| 1786 instruction_zone(), state_info.type(), state_info.bailout_id(), | 1804 instruction_zone(), state_info.type(), state_info.bailout_id(), |
| 1787 state_info.state_combine(), parameters, locals, stack, | 1805 state_info.state_combine(), parameters, locals, stack, |
| 1788 state_info.shared_info(), outer_state); | 1806 state_info.shared_info(), outer_state); |
| 1789 } | 1807 } |
| 1790 | 1808 |
| 1791 | 1809 |
| 1792 } // namespace compiler | 1810 } // namespace compiler |
| 1793 } // namespace internal | 1811 } // namespace internal |
| 1794 } // namespace v8 | 1812 } // namespace v8 |
| OLD | NEW |