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 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 return true; | 737 return true; |
738 } | 738 } |
739 | 739 |
740 | 740 |
741 void InstructionSequence::SetSourcePosition(const Instruction* instr, | 741 void InstructionSequence::SetSourcePosition(const Instruction* instr, |
742 SourcePosition value) { | 742 SourcePosition value) { |
743 source_positions_.insert(std::make_pair(instr, value)); | 743 source_positions_.insert(std::make_pair(instr, value)); |
744 } | 744 } |
745 | 745 |
746 | 746 |
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) { | 747 std::ostream& operator<<(std::ostream& os, const RpoNumber& rpo) { |
824 return os << rpo.ToSize(); | 748 return os << rpo.ToSize(); |
825 } | 749 } |
826 | 750 |
827 | 751 |
828 std::ostream& operator<<(std::ostream& os, | 752 std::ostream& operator<<(std::ostream& os, |
829 const PrintableInstructionSequence& printable) { | 753 const PrintableInstructionSequence& printable) { |
830 const InstructionSequence& code = *printable.sequence_; | 754 const InstructionSequence& code = *printable.sequence_; |
831 for (size_t i = 0; i < code.immediates_.size(); ++i) { | 755 for (size_t i = 0; i < code.immediates_.size(); ++i) { |
832 Constant constant = code.immediates_[i]; | 756 Constant constant = code.immediates_[i]; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 os << " B" << succ.ToInt(); | 809 os << " B" << succ.ToInt(); |
886 } | 810 } |
887 os << "\n"; | 811 os << "\n"; |
888 } | 812 } |
889 return os; | 813 return os; |
890 } | 814 } |
891 | 815 |
892 } // namespace compiler | 816 } // namespace compiler |
893 } // namespace internal | 817 } // namespace internal |
894 } // namespace v8 | 818 } // namespace v8 |
OLD | NEW |