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/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
7 #include "src/compiler/instruction.h" | 7 #include "src/compiler/instruction.h" |
8 #include "src/compiler/schedule.h" | 8 #include "src/compiler/schedule.h" |
| 9 #include "src/compiler/state-values-utils.h" |
9 | 10 |
10 namespace v8 { | 11 namespace v8 { |
11 namespace internal { | 12 namespace internal { |
12 namespace compiler { | 13 namespace compiler { |
13 | 14 |
14 | 15 |
15 FlagsCondition CommuteFlagsCondition(FlagsCondition condition) { | 16 FlagsCondition CommuteFlagsCondition(FlagsCondition condition) { |
16 switch (condition) { | 17 switch (condition) { |
17 case kSignedLessThan: | 18 case kSignedLessThan: |
18 return kSignedGreaterThan; | 19 return kSignedGreaterThan; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 case kNotOverflow: | 53 case kNotOverflow: |
53 case kUnorderedEqual: | 54 case kUnorderedEqual: |
54 case kUnorderedNotEqual: | 55 case kUnorderedNotEqual: |
55 return condition; | 56 return condition; |
56 } | 57 } |
57 UNREACHABLE(); | 58 UNREACHABLE(); |
58 return condition; | 59 return condition; |
59 } | 60 } |
60 | 61 |
61 | 62 |
| 63 FrameStateDescriptor::FrameStateDescriptor( |
| 64 Zone* zone, FrameStateType type, BailoutId bailout_id, |
| 65 OutputFrameStateCombine state_combine, size_t parameters_count, |
| 66 size_t locals_count, size_t stack_count, |
| 67 MaybeHandle<SharedFunctionInfo> shared_info, |
| 68 FrameStateDescriptor* outer_state) |
| 69 : type_(type), |
| 70 bailout_id_(bailout_id), |
| 71 frame_state_combine_(state_combine), |
| 72 parameters_count_(parameters_count), |
| 73 locals_count_(locals_count), |
| 74 stack_count_(stack_count), |
| 75 values_(zone), |
| 76 shared_info_(shared_info), |
| 77 outer_state_(outer_state) {} |
| 78 |
| 79 |
| 80 size_t FrameStateDescriptor::GetSize(OutputFrameStateCombine combine) const { |
| 81 size_t size = 1 + parameters_count() + locals_count() + stack_count() + |
| 82 (HasContext() ? 1 : 0); |
| 83 switch (combine.kind()) { |
| 84 case OutputFrameStateCombine::kPushOutput: |
| 85 size += combine.GetPushCount(); |
| 86 break; |
| 87 case OutputFrameStateCombine::kPokeAt: |
| 88 break; |
| 89 } |
| 90 return size; |
| 91 } |
| 92 |
| 93 |
| 94 size_t FrameStateDescriptor::GetTotalSize() const { |
| 95 size_t total_size = 0; |
| 96 for (const FrameStateDescriptor* iter = this; iter != NULL; |
| 97 iter = iter->outer_state_) { |
| 98 total_size += iter->GetSize(); |
| 99 } |
| 100 return total_size; |
| 101 } |
| 102 |
| 103 |
| 104 size_t FrameStateDescriptor::GetFrameCount() const { |
| 105 size_t count = 0; |
| 106 for (const FrameStateDescriptor* iter = this; iter != NULL; |
| 107 iter = iter->outer_state_) { |
| 108 ++count; |
| 109 } |
| 110 return count; |
| 111 } |
| 112 |
| 113 |
| 114 size_t FrameStateDescriptor::GetJSFrameCount() const { |
| 115 size_t count = 0; |
| 116 for (const FrameStateDescriptor* iter = this; iter != NULL; |
| 117 iter = iter->outer_state_) { |
| 118 if (iter->type_ == FrameStateType::kJavaScriptFunction) { |
| 119 ++count; |
| 120 } |
| 121 } |
| 122 return count; |
| 123 } |
| 124 |
| 125 |
62 std::ostream& operator<<(std::ostream& os, | 126 std::ostream& operator<<(std::ostream& os, |
63 const PrintableInstructionOperand& printable) { | 127 const PrintableInstructionOperand& printable) { |
64 const InstructionOperand& op = printable.op_; | 128 const InstructionOperand& op = printable.op_; |
65 const RegisterConfiguration* conf = printable.register_configuration_; | 129 const RegisterConfiguration* conf = printable.register_configuration_; |
66 switch (op.kind()) { | 130 switch (op.kind()) { |
67 case InstructionOperand::UNALLOCATED: { | 131 case InstructionOperand::UNALLOCATED: { |
68 const UnallocatedOperand* unalloc = UnallocatedOperand::cast(&op); | 132 const UnallocatedOperand* unalloc = UnallocatedOperand::cast(&op); |
69 os << "v" << unalloc->virtual_register(); | 133 os << "v" << unalloc->virtual_register(); |
70 if (unalloc->basic_policy() == UnallocatedOperand::FIXED_SLOT) { | 134 if (unalloc->basic_policy() == UnallocatedOperand::FIXED_SLOT) { |
71 return os << "(=" << unalloc->fixed_slot_index() << "S)"; | 135 return os << "(=" << unalloc->fixed_slot_index() << "S)"; |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 return true; | 801 return true; |
738 } | 802 } |
739 | 803 |
740 | 804 |
741 void InstructionSequence::SetSourcePosition(const Instruction* instr, | 805 void InstructionSequence::SetSourcePosition(const Instruction* instr, |
742 SourcePosition value) { | 806 SourcePosition value) { |
743 source_positions_.insert(std::make_pair(instr, value)); | 807 source_positions_.insert(std::make_pair(instr, value)); |
744 } | 808 } |
745 | 809 |
746 | 810 |
747 FrameStateDescriptor::FrameStateDescriptor( | |
748 Zone* zone, FrameStateType type, BailoutId bailout_id, | |
749 OutputFrameStateCombine state_combine, size_t parameters_count, | |
750 size_t locals_count, size_t stack_count, | |
751 MaybeHandle<SharedFunctionInfo> shared_info, | |
752 FrameStateDescriptor* outer_state) | |
753 : type_(type), | |
754 bailout_id_(bailout_id), | |
755 frame_state_combine_(state_combine), | |
756 parameters_count_(parameters_count), | |
757 locals_count_(locals_count), | |
758 stack_count_(stack_count), | |
759 types_(zone), | |
760 shared_info_(shared_info), | |
761 outer_state_(outer_state) { | |
762 types_.resize(GetSize(), kMachNone); | |
763 } | |
764 | |
765 | |
766 size_t FrameStateDescriptor::GetSize(OutputFrameStateCombine combine) const { | |
767 size_t size = 1 + parameters_count() + locals_count() + stack_count() + | |
768 (HasContext() ? 1 : 0); | |
769 switch (combine.kind()) { | |
770 case OutputFrameStateCombine::kPushOutput: | |
771 size += combine.GetPushCount(); | |
772 break; | |
773 case OutputFrameStateCombine::kPokeAt: | |
774 break; | |
775 } | |
776 return size; | |
777 } | |
778 | |
779 | |
780 size_t FrameStateDescriptor::GetTotalSize() const { | |
781 size_t total_size = 0; | |
782 for (const FrameStateDescriptor* iter = this; iter != NULL; | |
783 iter = iter->outer_state_) { | |
784 total_size += iter->GetSize(); | |
785 } | |
786 return total_size; | |
787 } | |
788 | |
789 | |
790 size_t FrameStateDescriptor::GetFrameCount() const { | |
791 size_t count = 0; | |
792 for (const FrameStateDescriptor* iter = this; iter != NULL; | |
793 iter = iter->outer_state_) { | |
794 ++count; | |
795 } | |
796 return count; | |
797 } | |
798 | |
799 | |
800 size_t FrameStateDescriptor::GetJSFrameCount() const { | |
801 size_t count = 0; | |
802 for (const FrameStateDescriptor* iter = this; iter != NULL; | |
803 iter = iter->outer_state_) { | |
804 if (iter->type_ == FrameStateType::kJavaScriptFunction) { | |
805 ++count; | |
806 } | |
807 } | |
808 return count; | |
809 } | |
810 | |
811 | |
812 MachineType FrameStateDescriptor::GetType(size_t index) const { | |
813 return types_[index]; | |
814 } | |
815 | |
816 | |
817 void FrameStateDescriptor::SetType(size_t index, MachineType type) { | |
818 DCHECK(index < GetSize()); | |
819 types_[index] = type; | |
820 } | |
821 | |
822 | |
823 std::ostream& operator<<(std::ostream& os, const RpoNumber& rpo) { | 811 std::ostream& operator<<(std::ostream& os, const RpoNumber& rpo) { |
824 return os << rpo.ToSize(); | 812 return os << rpo.ToSize(); |
825 } | 813 } |
826 | 814 |
827 | 815 |
828 std::ostream& operator<<(std::ostream& os, | 816 std::ostream& operator<<(std::ostream& os, |
829 const PrintableInstructionSequence& printable) { | 817 const PrintableInstructionSequence& printable) { |
830 const InstructionSequence& code = *printable.sequence_; | 818 const InstructionSequence& code = *printable.sequence_; |
831 for (size_t i = 0; i < code.immediates_.size(); ++i) { | 819 for (size_t i = 0; i < code.immediates_.size(); ++i) { |
832 Constant constant = code.immediates_[i]; | 820 Constant constant = code.immediates_[i]; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 os << " B" << succ.ToInt(); | 873 os << " B" << succ.ToInt(); |
886 } | 874 } |
887 os << "\n"; | 875 os << "\n"; |
888 } | 876 } |
889 return os; | 877 return os; |
890 } | 878 } |
891 | 879 |
892 } // namespace compiler | 880 } // namespace compiler |
893 } // namespace internal | 881 } // namespace internal |
894 } // namespace v8 | 882 } // namespace v8 |
OLD | NEW |