OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 ASSERT(parent_loop_header_ == NULL); | 118 ASSERT(parent_loop_header_ == NULL); |
119 parent_loop_header_ = block; | 119 parent_loop_header_ = block; |
120 } | 120 } |
121 | 121 |
122 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } | 122 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } |
123 | 123 |
124 void SetJoinId(BailoutId ast_id); | 124 void SetJoinId(BailoutId ast_id); |
125 | 125 |
126 void Finish(HControlInstruction* last); | 126 void Finish(HControlInstruction* last); |
127 void FinishExit(HControlInstruction* instruction); | 127 void FinishExit(HControlInstruction* instruction); |
128 void Goto(HBasicBlock* block, FunctionState* state = NULL); | 128 void Goto(HBasicBlock* block, |
| 129 FunctionState* state = NULL, |
| 130 bool add_simulate = true); |
| 131 void GotoNoSimulate(HBasicBlock* block) { |
| 132 Goto(block, NULL, false); |
| 133 } |
129 | 134 |
130 int PredecessorIndexOf(HBasicBlock* predecessor) const; | 135 int PredecessorIndexOf(HBasicBlock* predecessor) const; |
131 void AddSimulate(BailoutId ast_id, | 136 void AddSimulate(BailoutId ast_id, |
132 RemovableSimulate removable = FIXED_SIMULATE) { | 137 RemovableSimulate removable = FIXED_SIMULATE) { |
133 AddInstruction(CreateSimulate(ast_id, removable)); | 138 AddInstruction(CreateSimulate(ast_id, removable)); |
134 } | 139 } |
135 void AssignCommonDominator(HBasicBlock* other); | 140 void AssignCommonDominator(HBasicBlock* other); |
136 void AssignLoopSuccessorDominators(); | 141 void AssignLoopSuccessorDominators(); |
137 | 142 |
138 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) { | 143 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) { |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 }; | 673 }; |
669 | 674 |
670 | 675 |
671 class HOptimizedGraphBuilder; | 676 class HOptimizedGraphBuilder; |
672 | 677 |
673 enum ArgumentsAllowedFlag { | 678 enum ArgumentsAllowedFlag { |
674 ARGUMENTS_NOT_ALLOWED, | 679 ARGUMENTS_NOT_ALLOWED, |
675 ARGUMENTS_ALLOWED | 680 ARGUMENTS_ALLOWED |
676 }; | 681 }; |
677 | 682 |
| 683 |
| 684 class HIfContinuation; |
| 685 |
678 // This class is not BASE_EMBEDDED because our inlining implementation uses | 686 // This class is not BASE_EMBEDDED because our inlining implementation uses |
679 // new and delete. | 687 // new and delete. |
680 class AstContext { | 688 class AstContext { |
681 public: | 689 public: |
682 bool IsEffect() const { return kind_ == Expression::kEffect; } | 690 bool IsEffect() const { return kind_ == Expression::kEffect; } |
683 bool IsValue() const { return kind_ == Expression::kValue; } | 691 bool IsValue() const { return kind_ == Expression::kValue; } |
684 bool IsTest() const { return kind_ == Expression::kTest; } | 692 bool IsTest() const { return kind_ == Expression::kTest; } |
685 | 693 |
686 // 'Fill' this context with a hydrogen value. The value is assumed to | 694 // 'Fill' this context with a hydrogen value. The value is assumed to |
687 // have already been inserted in the instruction stream (or not need to | 695 // have already been inserted in the instruction stream (or not need to |
688 // be, e.g., HPhi). Call this function in tail position in the Visit | 696 // be, e.g., HPhi). Call this function in tail position in the Visit |
689 // functions for expressions. | 697 // functions for expressions. |
690 virtual void ReturnValue(HValue* value) = 0; | 698 virtual void ReturnValue(HValue* value) = 0; |
691 | 699 |
692 // Add a hydrogen instruction to the instruction stream (recording an | 700 // Add a hydrogen instruction to the instruction stream (recording an |
693 // environment simulation if necessary) and then fill this context with | 701 // environment simulation if necessary) and then fill this context with |
694 // the instruction as value. | 702 // the instruction as value. |
695 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id) = 0; | 703 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id) = 0; |
696 | 704 |
697 // Finishes the current basic block and materialize a boolean for | 705 // Finishes the current basic block and materialize a boolean for |
698 // value context, nothing for effect, generate a branch for test context. | 706 // value context, nothing for effect, generate a branch for test context. |
699 // Call this function in tail position in the Visit functions for | 707 // Call this function in tail position in the Visit functions for |
700 // expressions. | 708 // expressions. |
701 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id) = 0; | 709 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id) = 0; |
702 | 710 |
| 711 // Finishes the current basic block and materialize a boolean for |
| 712 // value context, nothing for effect, generate a branch for test context. |
| 713 // Call this function in tail position in the Visit functions for |
| 714 // expressions that use an IfBuilder. |
| 715 virtual void ReturnContinuation(HIfContinuation* continuation, |
| 716 BailoutId ast_id) = 0; |
| 717 |
703 void set_for_typeof(bool for_typeof) { for_typeof_ = for_typeof; } | 718 void set_for_typeof(bool for_typeof) { for_typeof_ = for_typeof; } |
704 bool is_for_typeof() { return for_typeof_; } | 719 bool is_for_typeof() { return for_typeof_; } |
705 | 720 |
706 protected: | 721 protected: |
707 AstContext(HOptimizedGraphBuilder* owner, Expression::Context kind); | 722 AstContext(HOptimizedGraphBuilder* owner, Expression::Context kind); |
708 virtual ~AstContext(); | 723 virtual ~AstContext(); |
709 | 724 |
710 HOptimizedGraphBuilder* owner() const { return owner_; } | 725 HOptimizedGraphBuilder* owner() const { return owner_; } |
711 | 726 |
712 inline Zone* zone() const; | 727 inline Zone* zone() const; |
(...skipping 15 matching lines...) Expand all Loading... |
728 class EffectContext: public AstContext { | 743 class EffectContext: public AstContext { |
729 public: | 744 public: |
730 explicit EffectContext(HOptimizedGraphBuilder* owner) | 745 explicit EffectContext(HOptimizedGraphBuilder* owner) |
731 : AstContext(owner, Expression::kEffect) { | 746 : AstContext(owner, Expression::kEffect) { |
732 } | 747 } |
733 virtual ~EffectContext(); | 748 virtual ~EffectContext(); |
734 | 749 |
735 virtual void ReturnValue(HValue* value); | 750 virtual void ReturnValue(HValue* value); |
736 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); | 751 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); |
737 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); | 752 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); |
| 753 virtual void ReturnContinuation(HIfContinuation* continuation, |
| 754 BailoutId ast_id); |
738 }; | 755 }; |
739 | 756 |
740 | 757 |
741 class ValueContext: public AstContext { | 758 class ValueContext: public AstContext { |
742 public: | 759 public: |
743 ValueContext(HOptimizedGraphBuilder* owner, ArgumentsAllowedFlag flag) | 760 ValueContext(HOptimizedGraphBuilder* owner, ArgumentsAllowedFlag flag) |
744 : AstContext(owner, Expression::kValue), flag_(flag) { | 761 : AstContext(owner, Expression::kValue), flag_(flag) { |
745 } | 762 } |
746 virtual ~ValueContext(); | 763 virtual ~ValueContext(); |
747 | 764 |
748 virtual void ReturnValue(HValue* value); | 765 virtual void ReturnValue(HValue* value); |
749 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); | 766 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); |
750 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); | 767 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); |
| 768 virtual void ReturnContinuation(HIfContinuation* continuation, |
| 769 BailoutId ast_id); |
751 | 770 |
752 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } | 771 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } |
753 | 772 |
754 private: | 773 private: |
755 ArgumentsAllowedFlag flag_; | 774 ArgumentsAllowedFlag flag_; |
756 }; | 775 }; |
757 | 776 |
758 | 777 |
759 class TestContext: public AstContext { | 778 class TestContext: public AstContext { |
760 public: | 779 public: |
761 TestContext(HOptimizedGraphBuilder* owner, | 780 TestContext(HOptimizedGraphBuilder* owner, |
762 Expression* condition, | 781 Expression* condition, |
763 TypeFeedbackOracle* oracle, | 782 TypeFeedbackOracle* oracle, |
764 HBasicBlock* if_true, | 783 HBasicBlock* if_true, |
765 HBasicBlock* if_false) | 784 HBasicBlock* if_false) |
766 : AstContext(owner, Expression::kTest), | 785 : AstContext(owner, Expression::kTest), |
767 condition_(condition), | 786 condition_(condition), |
768 oracle_(oracle), | 787 oracle_(oracle), |
769 if_true_(if_true), | 788 if_true_(if_true), |
770 if_false_(if_false) { | 789 if_false_(if_false) { |
771 } | 790 } |
772 | 791 |
773 virtual void ReturnValue(HValue* value); | 792 virtual void ReturnValue(HValue* value); |
774 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); | 793 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); |
775 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); | 794 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); |
| 795 virtual void ReturnContinuation(HIfContinuation* continuation, |
| 796 BailoutId ast_id); |
776 | 797 |
777 static TestContext* cast(AstContext* context) { | 798 static TestContext* cast(AstContext* context) { |
778 ASSERT(context->IsTest()); | 799 ASSERT(context->IsTest()); |
779 return reinterpret_cast<TestContext*>(context); | 800 return reinterpret_cast<TestContext*>(context); |
780 } | 801 } |
781 | 802 |
782 Expression* condition() const { return condition_; } | 803 Expression* condition() const { return condition_; } |
783 TypeFeedbackOracle* oracle() const { return oracle_; } | 804 TypeFeedbackOracle* oracle() const { return oracle_; } |
784 HBasicBlock* if_true() const { return if_true_; } | 805 HBasicBlock* if_true() const { return if_true_; } |
785 HBasicBlock* if_false() const { return if_false_; } | 806 HBasicBlock* if_false() const { return if_false_; } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 // When inlining HEnterInlined instruction corresponding to the function | 874 // When inlining HEnterInlined instruction corresponding to the function |
854 // entry. | 875 // entry. |
855 HEnterInlined* entry_; | 876 HEnterInlined* entry_; |
856 | 877 |
857 HArgumentsElements* arguments_elements_; | 878 HArgumentsElements* arguments_elements_; |
858 | 879 |
859 FunctionState* outer_; | 880 FunctionState* outer_; |
860 }; | 881 }; |
861 | 882 |
862 | 883 |
| 884 class HIfContinuation { |
| 885 public: |
| 886 HIfContinuation() { continuation_captured_ = false; } |
| 887 ~HIfContinuation() { ASSERT(!continuation_captured_); } |
| 888 |
| 889 void Capture(HBasicBlock* true_branch, |
| 890 HBasicBlock* false_branch, |
| 891 int position) { |
| 892 ASSERT(!continuation_captured_); |
| 893 ASSERT(true_branch != NULL || false_branch != NULL); |
| 894 true_branch_ = true_branch; |
| 895 false_branch_ = false_branch; |
| 896 position_ = position; |
| 897 continuation_captured_ = true; |
| 898 } |
| 899 |
| 900 void Continue(HBasicBlock** true_branch, |
| 901 HBasicBlock** false_branch, |
| 902 int* position) { |
| 903 ASSERT(continuation_captured_); |
| 904 *true_branch = true_branch_; |
| 905 *false_branch = false_branch_; |
| 906 if (position != NULL) *position = position_; |
| 907 continuation_captured_ = false; |
| 908 } |
| 909 |
| 910 bool IsTrueReachable() { return true_branch_ != NULL; } |
| 911 bool IsFalseReachable() { return false_branch_ != NULL; } |
| 912 bool TrueAndFalseReachable() { |
| 913 return IsTrueReachable() || IsFalseReachable(); |
| 914 } |
| 915 |
| 916 bool continuation_captured_; |
| 917 HBasicBlock* true_branch_; |
| 918 HBasicBlock* false_branch_; |
| 919 int position_; |
| 920 }; |
| 921 |
| 922 |
863 class HGraphBuilder { | 923 class HGraphBuilder { |
864 public: | 924 public: |
865 explicit HGraphBuilder(CompilationInfo* info) | 925 explicit HGraphBuilder(CompilationInfo* info) |
866 : info_(info), | 926 : info_(info), |
867 graph_(NULL), | 927 graph_(NULL), |
868 current_block_(NULL), | 928 current_block_(NULL), |
869 no_side_effects_scope_count_(0) {} | 929 no_side_effects_scope_count_(0) {} |
870 virtual ~HGraphBuilder() {} | 930 virtual ~HGraphBuilder() {} |
871 | 931 |
872 HBasicBlock* current_block() const { return current_block_; } | 932 HBasicBlock* current_block() const { return current_block_; } |
(...skipping 23 matching lines...) Expand all Loading... |
896 no_side_effects_scope_count_++; | 956 no_side_effects_scope_count_++; |
897 } | 957 } |
898 | 958 |
899 void DecrementInNoSideEffectsScope() { | 959 void DecrementInNoSideEffectsScope() { |
900 no_side_effects_scope_count_--; | 960 no_side_effects_scope_count_--; |
901 } | 961 } |
902 | 962 |
903 protected: | 963 protected: |
904 virtual bool BuildGraph() = 0; | 964 virtual bool BuildGraph() = 0; |
905 | 965 |
906 HBasicBlock* CreateBasicBlock(HEnvironment* envy); | 966 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
907 HBasicBlock* CreateLoopHeaderBlock(); | 967 HBasicBlock* CreateLoopHeaderBlock(); |
908 | 968 |
| 969 HValue* BuildCheckNonSmi(HValue* object); |
| 970 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); |
| 971 |
909 // Building common constructs | 972 // Building common constructs |
910 HInstruction* BuildExternalArrayElementAccess( | 973 HInstruction* BuildExternalArrayElementAccess( |
911 HValue* external_elements, | 974 HValue* external_elements, |
912 HValue* checked_key, | 975 HValue* checked_key, |
913 HValue* val, | 976 HValue* val, |
914 HValue* dependency, | 977 HValue* dependency, |
915 ElementsKind elements_kind, | 978 ElementsKind elements_kind, |
916 bool is_store); | 979 bool is_store); |
917 | 980 |
918 HInstruction* BuildFastElementAccess( | 981 HInstruction* BuildFastElementAccess( |
(...skipping 26 matching lines...) Expand all Loading... |
945 ElementsKind elements_kind, | 1008 ElementsKind elements_kind, |
946 bool is_store, | 1009 bool is_store, |
947 KeyedAccessStoreMode store_mode, | 1010 KeyedAccessStoreMode store_mode, |
948 Representation checked_index_representation = Representation::None()); | 1011 Representation checked_index_representation = Representation::None()); |
949 | 1012 |
950 HInstruction* BuildStoreMap(HValue* object, HValue* map); | 1013 HInstruction* BuildStoreMap(HValue* object, HValue* map); |
951 HInstruction* BuildStoreMap(HValue* object, Handle<Map> map); | 1014 HInstruction* BuildStoreMap(HValue* object, Handle<Map> map); |
952 | 1015 |
953 class CheckBuilder { | 1016 class CheckBuilder { |
954 public: | 1017 public: |
955 explicit CheckBuilder(HGraphBuilder* builder, BailoutId id); | 1018 explicit CheckBuilder(HGraphBuilder* builder); |
956 ~CheckBuilder() { | 1019 ~CheckBuilder() { |
957 if (!finished_) End(); | 1020 if (!finished_) End(); |
958 } | 1021 } |
959 | 1022 |
960 HValue* CheckNotUndefined(HValue* value); | 1023 HValue* CheckNotUndefined(HValue* value); |
961 HValue* CheckIntegerCompare(HValue* left, HValue* right, Token::Value op); | 1024 HValue* CheckIntegerCompare(HValue* left, HValue* right, Token::Value op); |
962 HValue* CheckIntegerEq(HValue* left, HValue* right); | 1025 HValue* CheckIntegerEq(HValue* left, HValue* right); |
963 void End(); | 1026 void End(); |
964 | 1027 |
965 private: | 1028 private: |
966 Zone* zone() { return builder_->zone(); } | 1029 Zone* zone() { return builder_->zone(); } |
967 | 1030 |
968 HGraphBuilder* builder_; | 1031 HGraphBuilder* builder_; |
969 bool finished_; | 1032 bool finished_; |
970 HBasicBlock* failure_block_; | 1033 HBasicBlock* failure_block_; |
971 HBasicBlock* merge_block_; | 1034 HBasicBlock* merge_block_; |
972 BailoutId id_; | |
973 }; | 1035 }; |
974 | 1036 |
975 class IfBuilder { | 1037 class IfBuilder { |
976 public: | 1038 public: |
977 explicit IfBuilder(HGraphBuilder* builder, BailoutId id); | 1039 explicit IfBuilder(HGraphBuilder* builder, |
| 1040 int position = RelocInfo::kNoPosition); |
| 1041 IfBuilder(HGraphBuilder* builder, |
| 1042 HIfContinuation* continuation); |
| 1043 |
978 ~IfBuilder() { | 1044 ~IfBuilder() { |
979 if (!finished_) End(); | 1045 if (!finished_) End(); |
980 } | 1046 } |
981 | 1047 |
982 HInstruction* BeginIf( | 1048 HInstruction* IfCompare( |
983 HValue* left, | 1049 HValue* left, |
984 HValue* right, | 1050 HValue* right, |
985 Token::Value token, | 1051 Token::Value token, |
986 Representation input_representation = Representation::Integer32()); | 1052 Representation input_representation = Representation::Integer32()); |
987 HInstruction* BeginIfObjectsEqual(HValue* left, HValue* right); | 1053 |
988 HInstruction* BeginIfMapEquals(HValue* value, Handle<Map> map); | 1054 HInstruction* IfCompareMap(HValue* left, Handle<Map> map); |
989 void BeginElse(); | 1055 |
| 1056 template<class Condition> |
| 1057 HInstruction* If(HValue *p) { |
| 1058 HControlInstruction* compare = new(zone()) Condition(p); |
| 1059 AddCompare(compare); |
| 1060 return compare; |
| 1061 } |
| 1062 |
| 1063 template<class Condition, class P2> |
| 1064 HInstruction* If(HValue* p1, P2 p2) { |
| 1065 HControlInstruction* compare = new(zone()) Condition(p1, p2); |
| 1066 AddCompare(compare); |
| 1067 return compare; |
| 1068 } |
| 1069 |
| 1070 template<class Condition> |
| 1071 HInstruction* OrIfCompare( |
| 1072 HValue* p1, |
| 1073 HValue* p2, |
| 1074 Token::Value token, |
| 1075 Representation input_representation = Representation::Integer32()) { |
| 1076 Or(); |
| 1077 return IfCompare(p1, p2, token, input_representation); |
| 1078 } |
| 1079 |
| 1080 HInstruction* OrIfCompareMap(HValue* left, Handle<Map> map) { |
| 1081 Or(); |
| 1082 return IfCompareMap(left, map); |
| 1083 } |
| 1084 |
| 1085 template<class Condition> |
| 1086 HInstruction* OrIf(HValue *p) { |
| 1087 Or(); |
| 1088 return If<Condition>(p); |
| 1089 } |
| 1090 |
| 1091 template<class Condition, class P2> |
| 1092 HInstruction* OrIf(HValue* p1, P2 p2) { |
| 1093 Or(); |
| 1094 return If<Condition>(p1, p2); |
| 1095 } |
| 1096 |
| 1097 template<class Condition> |
| 1098 HInstruction* AndIfCompare( |
| 1099 HValue* p1, |
| 1100 HValue* p2, |
| 1101 Token::Value token, |
| 1102 Representation input_representation = Representation::Integer32()) { |
| 1103 And(); |
| 1104 return IfCompare(p1, p2, token, input_representation); |
| 1105 } |
| 1106 |
| 1107 HInstruction* AndIfCompareMap(HValue* left, Handle<Map> map) { |
| 1108 And(); |
| 1109 return IfCompareMap(left, map); |
| 1110 } |
| 1111 |
| 1112 template<class Condition> |
| 1113 HInstruction* AndIf(HValue *p) { |
| 1114 And(); |
| 1115 return If<Condition>(p); |
| 1116 } |
| 1117 |
| 1118 template<class Condition, class P2> |
| 1119 HInstruction* AndIf(HValue* p1, P2 p2) { |
| 1120 And(); |
| 1121 return If<Condition>(p1, p2); |
| 1122 } |
| 1123 |
| 1124 void Or(); |
| 1125 void And(); |
| 1126 |
| 1127 void CaptureContinuation(HIfContinuation* continuation); |
| 1128 |
| 1129 void Then(); |
| 1130 void Else(); |
990 void End(); | 1131 void End(); |
991 | 1132 |
| 1133 void Deopt(); |
| 1134 |
992 private: | 1135 private: |
| 1136 void AddCompare(HControlInstruction* compare); |
| 1137 |
993 Zone* zone() { return builder_->zone(); } | 1138 Zone* zone() { return builder_->zone(); } |
994 | 1139 |
995 HGraphBuilder* builder_; | 1140 HGraphBuilder* builder_; |
996 bool finished_; | 1141 int position_; |
997 bool did_else_; | 1142 bool finished_ : 1; |
| 1143 bool did_then_ : 1; |
| 1144 bool did_else_ : 1; |
| 1145 bool deopt_then_ : 1; |
| 1146 bool deopt_else_ : 1; |
| 1147 bool did_and_ : 1; |
| 1148 bool did_or_ : 1; |
| 1149 bool captured_ : 1; |
| 1150 bool needs_compare_ : 1; |
998 HBasicBlock* first_true_block_; | 1151 HBasicBlock* first_true_block_; |
999 HBasicBlock* last_true_block_; | 1152 HBasicBlock* last_true_block_; |
1000 HBasicBlock* first_false_block_; | 1153 HBasicBlock* first_false_block_; |
| 1154 HBasicBlock* split_edge_merge_block_; |
1001 HBasicBlock* merge_block_; | 1155 HBasicBlock* merge_block_; |
1002 BailoutId id_; | |
1003 }; | 1156 }; |
1004 | 1157 |
1005 class LoopBuilder { | 1158 class LoopBuilder { |
1006 public: | 1159 public: |
1007 enum Direction { | 1160 enum Direction { |
1008 kPreIncrement, | 1161 kPreIncrement, |
1009 kPostIncrement, | 1162 kPostIncrement, |
1010 kPreDecrement, | 1163 kPreDecrement, |
1011 kPostDecrement | 1164 kPostDecrement |
1012 }; | 1165 }; |
1013 | 1166 |
1014 LoopBuilder(HGraphBuilder* builder, | 1167 LoopBuilder(HGraphBuilder* builder, |
1015 HValue* context, | 1168 HValue* context, |
1016 Direction direction, | 1169 Direction direction); |
1017 BailoutId id); | |
1018 ~LoopBuilder() { | 1170 ~LoopBuilder() { |
1019 ASSERT(finished_); | 1171 ASSERT(finished_); |
1020 } | 1172 } |
1021 | 1173 |
1022 HValue* BeginBody( | 1174 HValue* BeginBody( |
1023 HValue* initial, | 1175 HValue* initial, |
1024 HValue* terminating, | 1176 HValue* terminating, |
1025 Token::Value token, | 1177 Token::Value token, |
1026 Representation input_representation = Representation::Integer32()); | 1178 Representation input_representation = Representation::Integer32()); |
1027 void EndBody(); | 1179 void EndBody(); |
1028 | 1180 |
1029 private: | 1181 private: |
1030 Zone* zone() { return builder_->zone(); } | 1182 Zone* zone() { return builder_->zone(); } |
1031 | 1183 |
1032 HGraphBuilder* builder_; | 1184 HGraphBuilder* builder_; |
1033 HValue* context_; | 1185 HValue* context_; |
1034 HInstruction* increment_; | 1186 HInstruction* increment_; |
1035 HPhi* phi_; | 1187 HPhi* phi_; |
1036 HBasicBlock* header_block_; | 1188 HBasicBlock* header_block_; |
1037 HBasicBlock* body_block_; | 1189 HBasicBlock* body_block_; |
1038 HBasicBlock* exit_block_; | 1190 HBasicBlock* exit_block_; |
1039 Direction direction_; | 1191 Direction direction_; |
1040 BailoutId id_; | |
1041 bool finished_; | 1192 bool finished_; |
1042 }; | 1193 }; |
1043 | 1194 |
1044 class NoObservableSideEffectsScope { | 1195 class NoObservableSideEffectsScope { |
1045 public: | 1196 public: |
1046 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : | 1197 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : |
1047 builder_(builder) { | 1198 builder_(builder) { |
1048 builder_->IncrementInNoSideEffectsScope(); | 1199 builder_->IncrementInNoSideEffectsScope(); |
1049 } | 1200 } |
1050 ~NoObservableSideEffectsScope() { | 1201 ~NoObservableSideEffectsScope() { |
1051 builder_->DecrementInNoSideEffectsScope(); | 1202 builder_->DecrementInNoSideEffectsScope(); |
1052 } | 1203 } |
1053 | 1204 |
1054 private: | 1205 private: |
1055 HGraphBuilder* builder_; | 1206 HGraphBuilder* builder_; |
1056 }; | 1207 }; |
1057 | 1208 |
1058 HValue* BuildNewElementsCapacity(HValue* context, | 1209 HValue* BuildNewElementsCapacity(HValue* context, |
1059 HValue* old_capacity); | 1210 HValue* old_capacity); |
1060 | 1211 |
1061 void BuildNewSpaceArrayCheck(HValue* length, | 1212 void BuildNewSpaceArrayCheck(HValue* length, |
1062 ElementsKind kind); | 1213 ElementsKind kind); |
1063 | 1214 |
1064 HValue* BuildAllocateElements(HValue* context, | 1215 HValue* BuildAllocateElements(HValue* context, |
1065 ElementsKind kind, | 1216 ElementsKind kind, |
1066 HValue* capacity, | 1217 HValue* capacity); |
1067 BailoutId ast_id); | |
1068 | 1218 |
1069 void BuildInitializeElements(HValue* elements, | 1219 void BuildInitializeElements(HValue* elements, |
1070 ElementsKind kind, | 1220 ElementsKind kind, |
1071 HValue* capacity); | 1221 HValue* capacity); |
1072 | 1222 |
1073 HValue* BuildAllocateAndInitializeElements(HValue* context, | 1223 HValue* BuildAllocateAndInitializeElements(HValue* context, |
1074 ElementsKind kind, | 1224 ElementsKind kind, |
1075 HValue* capacity); | 1225 HValue* capacity); |
1076 | 1226 |
1077 HValue* BuildGrowElementsCapacity(HValue* object, | 1227 HValue* BuildGrowElementsCapacity(HValue* object, |
1078 HValue* elements, | 1228 HValue* elements, |
1079 ElementsKind kind, | 1229 ElementsKind kind, |
1080 HValue* length, | 1230 HValue* length, |
1081 HValue* new_capacity, | 1231 HValue* new_capacity); |
1082 BailoutId ast_id); | |
1083 | 1232 |
1084 void BuildFillElementsWithHole(HValue* context, | 1233 void BuildFillElementsWithHole(HValue* context, |
1085 HValue* elements, | 1234 HValue* elements, |
1086 ElementsKind elements_kind, | 1235 ElementsKind elements_kind, |
1087 HValue* from, | 1236 HValue* from, |
1088 HValue* to, | 1237 HValue* to); |
1089 BailoutId ast_id); | |
1090 | 1238 |
1091 void BuildCopyElements(HValue* context, | 1239 void BuildCopyElements(HValue* context, |
1092 HValue* from_elements, | 1240 HValue* from_elements, |
1093 ElementsKind from_elements_kind, | 1241 ElementsKind from_elements_kind, |
1094 HValue* to_elements, | 1242 HValue* to_elements, |
1095 ElementsKind to_elements_kind, | 1243 ElementsKind to_elements_kind, |
1096 HValue* length, | 1244 HValue* length, |
1097 HValue* capacity, | 1245 HValue* capacity); |
1098 BailoutId ast_id); | |
1099 | 1246 |
1100 HValue* BuildCloneShallowArray(HContext* context, | 1247 HValue* BuildCloneShallowArray(HContext* context, |
1101 HValue* boilerplate, | 1248 HValue* boilerplate, |
1102 AllocationSiteMode mode, | 1249 AllocationSiteMode mode, |
1103 ElementsKind kind, | 1250 ElementsKind kind, |
1104 int length); | 1251 int length); |
1105 | 1252 |
1106 private: | 1253 private: |
1107 HGraphBuilder(); | 1254 HGraphBuilder(); |
1108 CompilationInfo* info_; | 1255 CompilationInfo* info_; |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1793 EmbeddedVector<char, 64> filename_; | 1940 EmbeddedVector<char, 64> filename_; |
1794 HeapStringAllocator string_allocator_; | 1941 HeapStringAllocator string_allocator_; |
1795 StringStream trace_; | 1942 StringStream trace_; |
1796 int indent_; | 1943 int indent_; |
1797 }; | 1944 }; |
1798 | 1945 |
1799 | 1946 |
1800 } } // namespace v8::internal | 1947 } } // namespace v8::internal |
1801 | 1948 |
1802 #endif // V8_HYDROGEN_H_ | 1949 #endif // V8_HYDROGEN_H_ |
OLD | NEW |