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 #ifndef V8_COMPILER_INSTRUCTION_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_H_ |
6 #define V8_COMPILER_INSTRUCTION_H_ | 6 #define V8_COMPILER_INSTRUCTION_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 | 695 |
696 private: | 696 private: |
697 Type type_; | 697 Type type_; |
698 int64_t value_; | 698 int64_t value_; |
699 }; | 699 }; |
700 | 700 |
701 | 701 |
702 class FrameStateDescriptor : public ZoneObject { | 702 class FrameStateDescriptor : public ZoneObject { |
703 public: | 703 public: |
704 FrameStateDescriptor(const FrameStateCallInfo& state_info, | 704 FrameStateDescriptor(const FrameStateCallInfo& state_info, |
705 size_t parameters_count, size_t locals_count, | 705 int parameters_count, int locals_count, int stack_count, |
706 size_t stack_count, | |
707 FrameStateDescriptor* outer_state = NULL) | 706 FrameStateDescriptor* outer_state = NULL) |
708 : type_(state_info.type()), | 707 : bailout_id_(state_info.bailout_id()), |
709 bailout_id_(state_info.bailout_id()), | |
710 frame_state_combine_(state_info.state_combine()), | 708 frame_state_combine_(state_info.state_combine()), |
711 parameters_count_(parameters_count), | 709 parameters_count_(parameters_count), |
712 locals_count_(locals_count), | 710 locals_count_(locals_count), |
713 stack_count_(stack_count), | 711 stack_count_(stack_count), |
714 outer_state_(outer_state), | 712 outer_state_(outer_state) {} |
715 jsfunction_(state_info.jsfunction()) {} | |
716 | 713 |
717 FrameStateType type() const { return type_; } | |
718 BailoutId bailout_id() const { return bailout_id_; } | 714 BailoutId bailout_id() const { return bailout_id_; } |
719 OutputFrameStateCombine state_combine() const { return frame_state_combine_; } | 715 OutputFrameStateCombine state_combine() const { return frame_state_combine_; } |
720 size_t parameters_count() const { return parameters_count_; } | 716 int parameters_count() { return parameters_count_; } |
721 size_t locals_count() const { return locals_count_; } | 717 int locals_count() { return locals_count_; } |
722 size_t stack_count() const { return stack_count_; } | 718 int stack_count() { return stack_count_; } |
723 FrameStateDescriptor* outer_state() const { return outer_state_; } | 719 FrameStateDescriptor* outer_state() { return outer_state_; } |
724 MaybeHandle<JSFunction> jsfunction() const { return jsfunction_; } | 720 void set_outer_state(FrameStateDescriptor* outer_state) { |
725 | 721 outer_state_ = outer_state; |
726 size_t size() const { | |
727 return parameters_count_ + locals_count_ + stack_count_ + | |
728 (HasContext() ? 1 : 0); | |
729 } | 722 } |
730 | 723 |
731 size_t GetTotalSize() const { | 724 int size() { |
732 size_t total_size = 0; | 725 return parameters_count_ + locals_count_ + stack_count_ + |
733 for (const FrameStateDescriptor* iter = this; iter != NULL; | 726 1; // Includes context. |
| 727 } |
| 728 |
| 729 int total_size() { |
| 730 int total_size = 0; |
| 731 for (FrameStateDescriptor* iter = this; iter != NULL; |
734 iter = iter->outer_state_) { | 732 iter = iter->outer_state_) { |
735 total_size += iter->size(); | 733 total_size += iter->size(); |
736 } | 734 } |
737 return total_size; | 735 return total_size; |
738 } | 736 } |
739 | 737 |
740 size_t GetHeight(OutputFrameStateCombine override) const { | 738 int GetFrameCount() { |
741 size_t height = size() - parameters_count(); | 739 int count = 0; |
742 switch (override) { | 740 for (FrameStateDescriptor* iter = this; iter != NULL; |
743 case kPushOutput: | |
744 ++height; | |
745 break; | |
746 case kIgnoreOutput: | |
747 break; | |
748 } | |
749 return height; | |
750 } | |
751 | |
752 size_t GetFrameCount() const { | |
753 size_t count = 0; | |
754 for (const FrameStateDescriptor* iter = this; iter != NULL; | |
755 iter = iter->outer_state_) { | 741 iter = iter->outer_state_) { |
756 ++count; | 742 ++count; |
757 } | 743 } |
758 return count; | 744 return count; |
759 } | 745 } |
760 | 746 |
761 size_t GetJSFrameCount() const { | |
762 size_t count = 0; | |
763 for (const FrameStateDescriptor* iter = this; iter != NULL; | |
764 iter = iter->outer_state_) { | |
765 if (iter->type_ == JS_FRAME) { | |
766 ++count; | |
767 } | |
768 } | |
769 return count; | |
770 } | |
771 | |
772 bool HasContext() const { return type_ == JS_FRAME; } | |
773 | |
774 private: | 747 private: |
775 FrameStateType type_; | |
776 BailoutId bailout_id_; | 748 BailoutId bailout_id_; |
777 OutputFrameStateCombine frame_state_combine_; | 749 OutputFrameStateCombine frame_state_combine_; |
778 size_t parameters_count_; | 750 int parameters_count_; |
779 size_t locals_count_; | 751 int locals_count_; |
780 size_t stack_count_; | 752 int stack_count_; |
781 FrameStateDescriptor* outer_state_; | 753 FrameStateDescriptor* outer_state_; |
782 MaybeHandle<JSFunction> jsfunction_; | |
783 }; | 754 }; |
784 | 755 |
785 OStream& operator<<(OStream& os, const Constant& constant); | 756 OStream& operator<<(OStream& os, const Constant& constant); |
786 | 757 |
787 typedef ZoneDeque<Constant> ConstantDeque; | 758 typedef ZoneDeque<Constant> ConstantDeque; |
788 typedef std::map<int, Constant, std::less<int>, | 759 typedef std::map<int, Constant, std::less<int>, |
789 zone_allocator<std::pair<int, Constant> > > ConstantMap; | 760 zone_allocator<std::pair<int, Constant> > > ConstantMap; |
790 | 761 |
791 typedef ZoneDeque<Instruction*> InstructionDeque; | 762 typedef ZoneDeque<Instruction*> InstructionDeque; |
792 typedef ZoneDeque<PointerMap*> PointerMapDeque; | 763 typedef ZoneDeque<PointerMap*> PointerMapDeque; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 DeoptimizationVector deoptimization_entries_; | 902 DeoptimizationVector deoptimization_entries_; |
932 }; | 903 }; |
933 | 904 |
934 OStream& operator<<(OStream& os, const InstructionSequence& code); | 905 OStream& operator<<(OStream& os, const InstructionSequence& code); |
935 | 906 |
936 } // namespace compiler | 907 } // namespace compiler |
937 } // namespace internal | 908 } // namespace internal |
938 } // namespace v8 | 909 } // namespace v8 |
939 | 910 |
940 #endif // V8_COMPILER_INSTRUCTION_H_ | 911 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |