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