Chromium Code Reviews| 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 IfContinuation; | |
| 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 // Finished the current basic block and boolean for | |
|
Michael Starzinger
2013/04/18 10:30:21
nit: s/Finished/Finishes/ and missing "materialize
danno
2013/04/18 10:44:04
Done.
| |
| 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(IfContinuation* 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(IfContinuation* 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(IfContinuation* 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(IfContinuation* 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 IfContinuation { | |
|
Michael Starzinger
2013/04/18 10:30:21
Could I convince you to rename this class to "HCon
danno
2013/04/18 10:44:04
Done.
| |
| 885 public: | |
| 886 IfContinuation() { continuation_captured_ = false; } | |
| 887 ~IfContinuation() { ASSERT(!continuation_captured_); } | |
| 888 | |
| 889 void Capture(HBasicBlock* true_branch, | |
| 890 HBasicBlock* false_branch, | |
| 891 int position) { | |
| 892 ASSERT(!continuation_captured_); | |
|
Michael Starzinger
2013/04/18 10:30:21
Can we also add an assert here that at least one o
danno
2013/04/18 10:44:04
Done.
| |
| 893 true_branch_ = true_branch; | |
| 894 false_branch_ = false_branch; | |
| 895 position_ = position; | |
| 896 continuation_captured_ = true; | |
| 897 } | |
| 898 | |
| 899 void Continue(HBasicBlock** true_branch, | |
| 900 HBasicBlock** false_branch, | |
| 901 int* position) { | |
| 902 ASSERT(continuation_captured_); | |
| 903 *true_branch = true_branch_; | |
| 904 *false_branch = false_branch_; | |
| 905 if (position != NULL) *position = position_; | |
| 906 continuation_captured_ = false; | |
| 907 } | |
| 908 | |
| 909 bool IsTrueReachable() { return true_branch_ != NULL; } | |
| 910 bool IsFalseReachable() { return false_branch_ != NULL; } | |
| 911 bool TrueAndFalseReachable() { | |
| 912 return IsTrueReachable() || IsFalseReachable(); | |
| 913 } | |
| 914 | |
| 915 bool continuation_captured_; | |
| 916 HBasicBlock* true_branch_; | |
| 917 HBasicBlock* false_branch_; | |
| 918 int position_; | |
| 919 }; | |
| 920 | |
| 921 | |
| 863 class HGraphBuilder { | 922 class HGraphBuilder { |
| 864 public: | 923 public: |
| 865 explicit HGraphBuilder(CompilationInfo* info) | 924 explicit HGraphBuilder(CompilationInfo* info) |
| 866 : info_(info), | 925 : info_(info), |
| 867 graph_(NULL), | 926 graph_(NULL), |
| 868 current_block_(NULL), | 927 current_block_(NULL), |
| 869 no_side_effects_scope_count_(0) {} | 928 no_side_effects_scope_count_(0) {} |
| 870 virtual ~HGraphBuilder() {} | 929 virtual ~HGraphBuilder() {} |
| 871 | 930 |
| 872 HBasicBlock* current_block() const { return current_block_; } | 931 HBasicBlock* current_block() const { return current_block_; } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 896 no_side_effects_scope_count_++; | 955 no_side_effects_scope_count_++; |
| 897 } | 956 } |
| 898 | 957 |
| 899 void DecrementInNoSideEffectsScope() { | 958 void DecrementInNoSideEffectsScope() { |
| 900 no_side_effects_scope_count_--; | 959 no_side_effects_scope_count_--; |
| 901 } | 960 } |
| 902 | 961 |
| 903 protected: | 962 protected: |
| 904 virtual bool BuildGraph() = 0; | 963 virtual bool BuildGraph() = 0; |
| 905 | 964 |
| 906 HBasicBlock* CreateBasicBlock(HEnvironment* envy); | 965 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
| 907 HBasicBlock* CreateLoopHeaderBlock(); | 966 HBasicBlock* CreateLoopHeaderBlock(); |
| 908 | 967 |
| 968 HValue* BuildCheckNonSmi(HValue* object); | |
| 969 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); | |
| 970 | |
| 909 // Building common constructs | 971 // Building common constructs |
| 910 HInstruction* BuildExternalArrayElementAccess( | 972 HInstruction* BuildExternalArrayElementAccess( |
| 911 HValue* external_elements, | 973 HValue* external_elements, |
| 912 HValue* checked_key, | 974 HValue* checked_key, |
| 913 HValue* val, | 975 HValue* val, |
| 914 HValue* dependency, | 976 HValue* dependency, |
| 915 ElementsKind elements_kind, | 977 ElementsKind elements_kind, |
| 916 bool is_store); | 978 bool is_store); |
| 917 | 979 |
| 918 HInstruction* BuildFastElementAccess( | 980 HInstruction* BuildFastElementAccess( |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 945 ElementsKind elements_kind, | 1007 ElementsKind elements_kind, |
| 946 bool is_store, | 1008 bool is_store, |
| 947 KeyedAccessStoreMode store_mode, | 1009 KeyedAccessStoreMode store_mode, |
| 948 Representation checked_index_representation = Representation::None()); | 1010 Representation checked_index_representation = Representation::None()); |
| 949 | 1011 |
| 950 HInstruction* BuildStoreMap(HValue* object, HValue* map); | 1012 HInstruction* BuildStoreMap(HValue* object, HValue* map); |
| 951 HInstruction* BuildStoreMap(HValue* object, Handle<Map> map); | 1013 HInstruction* BuildStoreMap(HValue* object, Handle<Map> map); |
| 952 | 1014 |
| 953 class CheckBuilder { | 1015 class CheckBuilder { |
| 954 public: | 1016 public: |
| 955 explicit CheckBuilder(HGraphBuilder* builder, BailoutId id); | 1017 explicit CheckBuilder(HGraphBuilder* builder); |
| 956 ~CheckBuilder() { | 1018 ~CheckBuilder() { |
| 957 if (!finished_) End(); | 1019 if (!finished_) End(); |
| 958 } | 1020 } |
| 959 | 1021 |
| 960 HValue* CheckNotUndefined(HValue* value); | 1022 HValue* CheckNotUndefined(HValue* value); |
| 961 HValue* CheckIntegerCompare(HValue* left, HValue* right, Token::Value op); | 1023 HValue* CheckIntegerCompare(HValue* left, HValue* right, Token::Value op); |
| 962 HValue* CheckIntegerEq(HValue* left, HValue* right); | 1024 HValue* CheckIntegerEq(HValue* left, HValue* right); |
| 963 void End(); | 1025 void End(); |
| 964 | 1026 |
| 965 private: | 1027 private: |
| 966 Zone* zone() { return builder_->zone(); } | 1028 Zone* zone() { return builder_->zone(); } |
| 967 | 1029 |
| 968 HGraphBuilder* builder_; | 1030 HGraphBuilder* builder_; |
| 969 bool finished_; | 1031 bool finished_; |
| 970 HBasicBlock* failure_block_; | 1032 HBasicBlock* failure_block_; |
| 971 HBasicBlock* merge_block_; | 1033 HBasicBlock* merge_block_; |
| 972 BailoutId id_; | |
| 973 }; | 1034 }; |
| 974 | 1035 |
| 975 class IfBuilder { | 1036 class IfBuilder { |
| 976 public: | 1037 public: |
| 977 explicit IfBuilder(HGraphBuilder* builder, BailoutId id); | 1038 explicit IfBuilder(HGraphBuilder* builder, |
| 1039 int position = RelocInfo::kNoPosition); | |
| 978 ~IfBuilder() { | 1040 ~IfBuilder() { |
| 979 if (!finished_) End(); | 1041 if (!finished_) End(); |
| 980 } | 1042 } |
| 981 | 1043 |
| 982 HInstruction* BeginIf( | 1044 IfBuilder(HGraphBuilder* builder, |
|
Michael Starzinger
2013/04/18 10:30:21
nit: Move this in front of the destructor.
danno
2013/04/18 10:44:04
Done.
| |
| 1045 IfContinuation* continuation); | |
| 1046 | |
| 1047 HInstruction* IfCompare( | |
| 983 HValue* left, | 1048 HValue* left, |
| 984 HValue* right, | 1049 HValue* right, |
| 985 Token::Value token, | 1050 Token::Value token, |
| 986 Representation input_representation = Representation::Integer32()); | 1051 Representation input_representation = Representation::Integer32()); |
| 987 HInstruction* BeginIfObjectsEqual(HValue* left, HValue* right); | 1052 |
| 988 HInstruction* BeginIfMapEquals(HValue* value, Handle<Map> map); | 1053 HInstruction* IfCompareMap(HValue* left, Handle<Map> map); |
| 989 void BeginElse(); | 1054 |
| 1055 template<class Condition> | |
| 1056 HInstruction* If(HValue *p) { | |
| 1057 HControlInstruction* compare = new(zone()) Condition(p); | |
| 1058 AddCompare(compare); | |
| 1059 return compare; | |
| 1060 } | |
| 1061 | |
| 1062 template<class Condition, class P2> | |
| 1063 HInstruction* If(HValue* p1, P2 p2) { | |
| 1064 HControlInstruction* compare = new(zone()) Condition(p1, p2); | |
| 1065 AddCompare(compare); | |
| 1066 return compare; | |
| 1067 } | |
| 1068 | |
| 1069 template<class Condition> | |
| 1070 HInstruction* OrIfCompare( | |
| 1071 HValue* p1, | |
| 1072 HValue* p2, | |
| 1073 Token::Value token, | |
| 1074 Representation input_representation = Representation::Integer32()) { | |
| 1075 Or(); | |
| 1076 return IfCompare(p1, p2, token, input_representation); | |
| 1077 } | |
| 1078 | |
| 1079 HInstruction* OrIfCompareMap(HValue* left, Handle<Map> map) { | |
| 1080 Or(); | |
| 1081 return IfCompareMap(left, map); | |
| 1082 } | |
| 1083 | |
| 1084 template<class Condition> | |
| 1085 HInstruction* OrIf(HValue *p) { | |
| 1086 Or(); | |
| 1087 return If<Condition>(p); | |
| 1088 } | |
| 1089 | |
| 1090 template<class Condition, class P2> | |
| 1091 HInstruction* OrIf(HValue* p1, P2 p2) { | |
| 1092 Or(); | |
| 1093 return If<Condition>(p1, p2); | |
| 1094 } | |
| 1095 | |
| 1096 template<class Condition> | |
| 1097 HInstruction* AndIfCompare( | |
| 1098 HValue* p1, | |
| 1099 HValue* p2, | |
| 1100 Token::Value token, | |
| 1101 Representation input_representation = Representation::Integer32()) { | |
| 1102 And(); | |
| 1103 return IfCompare(p1, p2, token, input_representation); | |
| 1104 } | |
| 1105 | |
| 1106 HInstruction* AndIfCompareMap(HValue* left, Handle<Map> map) { | |
| 1107 And(); | |
| 1108 return IfCompareMap(left, map); | |
| 1109 } | |
| 1110 | |
| 1111 template<class Condition> | |
| 1112 HInstruction* AndIf(HValue *p) { | |
| 1113 And(); | |
| 1114 return If<Condition>(p); | |
| 1115 } | |
| 1116 | |
| 1117 template<class Condition, class P2> | |
| 1118 HInstruction* AndIf(HValue* p1, P2 p2) { | |
| 1119 And(); | |
| 1120 return If<Condition>(p1, p2); | |
| 1121 } | |
| 1122 | |
| 1123 void Or(); | |
| 1124 void And(); | |
| 1125 | |
| 1126 void CaptureContinuation(IfContinuation* continuation); | |
| 1127 | |
| 1128 void Then(); | |
| 1129 void Else(); | |
| 990 void End(); | 1130 void End(); |
| 991 | 1131 |
| 1132 void Deopt(); | |
| 1133 | |
| 992 private: | 1134 private: |
| 1135 void AddCompare(HControlInstruction* compare); | |
| 1136 | |
| 993 Zone* zone() { return builder_->zone(); } | 1137 Zone* zone() { return builder_->zone(); } |
| 994 | 1138 |
| 995 HGraphBuilder* builder_; | 1139 HGraphBuilder* builder_; |
| 996 bool finished_; | 1140 int position_; |
| 997 bool did_else_; | 1141 bool finished_ : 1; |
| 1142 bool did_then_ : 1; | |
| 1143 bool did_else_ : 1; | |
| 1144 bool deopt_then_ : 1; | |
| 1145 bool deopt_else_ : 1; | |
| 1146 bool did_and_ : 1; | |
| 1147 bool did_or_ : 1; | |
| 1148 bool captured_ : 1; | |
| 1149 bool needs_compare_ : 1; | |
| 998 HBasicBlock* first_true_block_; | 1150 HBasicBlock* first_true_block_; |
| 999 HBasicBlock* last_true_block_; | 1151 HBasicBlock* last_true_block_; |
| 1000 HBasicBlock* first_false_block_; | 1152 HBasicBlock* first_false_block_; |
| 1153 HBasicBlock* split_edge_merge_block_; | |
| 1001 HBasicBlock* merge_block_; | 1154 HBasicBlock* merge_block_; |
| 1002 BailoutId id_; | |
| 1003 }; | 1155 }; |
| 1004 | 1156 |
| 1005 class LoopBuilder { | 1157 class LoopBuilder { |
| 1006 public: | 1158 public: |
| 1007 enum Direction { | 1159 enum Direction { |
| 1008 kPreIncrement, | 1160 kPreIncrement, |
| 1009 kPostIncrement, | 1161 kPostIncrement, |
| 1010 kPreDecrement, | 1162 kPreDecrement, |
| 1011 kPostDecrement | 1163 kPostDecrement |
| 1012 }; | 1164 }; |
| 1013 | 1165 |
| 1014 LoopBuilder(HGraphBuilder* builder, | 1166 LoopBuilder(HGraphBuilder* builder, |
| 1015 HValue* context, | 1167 HValue* context, |
| 1016 Direction direction, | 1168 Direction direction); |
| 1017 BailoutId id); | |
| 1018 ~LoopBuilder() { | 1169 ~LoopBuilder() { |
| 1019 ASSERT(finished_); | 1170 ASSERT(finished_); |
| 1020 } | 1171 } |
| 1021 | 1172 |
| 1022 HValue* BeginBody( | 1173 HValue* BeginBody( |
| 1023 HValue* initial, | 1174 HValue* initial, |
| 1024 HValue* terminating, | 1175 HValue* terminating, |
| 1025 Token::Value token, | 1176 Token::Value token, |
| 1026 Representation input_representation = Representation::Integer32()); | 1177 Representation input_representation = Representation::Integer32()); |
| 1027 void EndBody(); | 1178 void EndBody(); |
| 1028 | 1179 |
| 1029 private: | 1180 private: |
| 1030 Zone* zone() { return builder_->zone(); } | 1181 Zone* zone() { return builder_->zone(); } |
| 1031 | 1182 |
| 1032 HGraphBuilder* builder_; | 1183 HGraphBuilder* builder_; |
| 1033 HValue* context_; | 1184 HValue* context_; |
| 1034 HInstruction* increment_; | 1185 HInstruction* increment_; |
| 1035 HPhi* phi_; | 1186 HPhi* phi_; |
| 1036 HBasicBlock* header_block_; | 1187 HBasicBlock* header_block_; |
| 1037 HBasicBlock* body_block_; | 1188 HBasicBlock* body_block_; |
| 1038 HBasicBlock* exit_block_; | 1189 HBasicBlock* exit_block_; |
| 1039 Direction direction_; | 1190 Direction direction_; |
| 1040 BailoutId id_; | |
| 1041 bool finished_; | 1191 bool finished_; |
| 1042 }; | 1192 }; |
| 1043 | 1193 |
| 1044 class NoObservableSideEffectsScope { | 1194 class NoObservableSideEffectsScope { |
| 1045 public: | 1195 public: |
| 1046 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : | 1196 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : |
| 1047 builder_(builder) { | 1197 builder_(builder) { |
| 1048 builder_->IncrementInNoSideEffectsScope(); | 1198 builder_->IncrementInNoSideEffectsScope(); |
| 1049 } | 1199 } |
| 1050 ~NoObservableSideEffectsScope() { | 1200 ~NoObservableSideEffectsScope() { |
| 1051 builder_->DecrementInNoSideEffectsScope(); | 1201 builder_->DecrementInNoSideEffectsScope(); |
| 1052 } | 1202 } |
| 1053 | 1203 |
| 1054 private: | 1204 private: |
| 1055 HGraphBuilder* builder_; | 1205 HGraphBuilder* builder_; |
| 1056 }; | 1206 }; |
| 1057 | 1207 |
| 1058 HValue* BuildNewElementsCapacity(HValue* context, | 1208 HValue* BuildNewElementsCapacity(HValue* context, |
| 1059 HValue* old_capacity); | 1209 HValue* old_capacity); |
| 1060 | 1210 |
| 1061 void BuildNewSpaceArrayCheck(HValue* length, | 1211 void BuildNewSpaceArrayCheck(HValue* length, |
| 1062 ElementsKind kind); | 1212 ElementsKind kind); |
| 1063 | 1213 |
| 1064 HValue* BuildAllocateElements(HValue* context, | 1214 HValue* BuildAllocateElements(HValue* context, |
| 1065 ElementsKind kind, | 1215 ElementsKind kind, |
| 1066 HValue* capacity, | 1216 HValue* capacity); |
| 1067 BailoutId ast_id); | |
| 1068 | 1217 |
| 1069 void BuildInitializeElements(HValue* elements, | 1218 void BuildInitializeElements(HValue* elements, |
| 1070 ElementsKind kind, | 1219 ElementsKind kind, |
| 1071 HValue* capacity); | 1220 HValue* capacity); |
| 1072 | 1221 |
| 1073 HValue* BuildAllocateAndInitializeElements(HValue* context, | 1222 HValue* BuildAllocateAndInitializeElements(HValue* context, |
| 1074 ElementsKind kind, | 1223 ElementsKind kind, |
| 1075 HValue* capacity); | 1224 HValue* capacity); |
| 1076 | 1225 |
| 1077 HValue* BuildGrowElementsCapacity(HValue* object, | 1226 HValue* BuildGrowElementsCapacity(HValue* object, |
| 1078 HValue* elements, | 1227 HValue* elements, |
| 1079 ElementsKind kind, | 1228 ElementsKind kind, |
| 1080 HValue* length, | 1229 HValue* length, |
| 1081 HValue* new_capacity, | 1230 HValue* new_capacity); |
| 1082 BailoutId ast_id); | |
| 1083 | 1231 |
| 1084 void BuildFillElementsWithHole(HValue* context, | 1232 void BuildFillElementsWithHole(HValue* context, |
| 1085 HValue* elements, | 1233 HValue* elements, |
| 1086 ElementsKind elements_kind, | 1234 ElementsKind elements_kind, |
| 1087 HValue* from, | 1235 HValue* from, |
| 1088 HValue* to, | 1236 HValue* to); |
| 1089 BailoutId ast_id); | |
| 1090 | 1237 |
| 1091 void BuildCopyElements(HValue* context, | 1238 void BuildCopyElements(HValue* context, |
| 1092 HValue* from_elements, | 1239 HValue* from_elements, |
| 1093 ElementsKind from_elements_kind, | 1240 ElementsKind from_elements_kind, |
| 1094 HValue* to_elements, | 1241 HValue* to_elements, |
| 1095 ElementsKind to_elements_kind, | 1242 ElementsKind to_elements_kind, |
| 1096 HValue* length, | 1243 HValue* length, |
| 1097 HValue* capacity, | 1244 HValue* capacity); |
| 1098 BailoutId ast_id); | |
| 1099 | 1245 |
| 1100 HValue* BuildCloneShallowArray(HContext* context, | 1246 HValue* BuildCloneShallowArray(HContext* context, |
| 1101 HValue* boilerplate, | 1247 HValue* boilerplate, |
| 1102 AllocationSiteMode mode, | 1248 AllocationSiteMode mode, |
| 1103 ElementsKind kind, | 1249 ElementsKind kind, |
| 1104 int length); | 1250 int length); |
| 1105 | 1251 |
| 1106 private: | 1252 private: |
| 1107 HGraphBuilder(); | 1253 HGraphBuilder(); |
| 1108 CompilationInfo* info_; | 1254 CompilationInfo* info_; |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1793 EmbeddedVector<char, 64> filename_; | 1939 EmbeddedVector<char, 64> filename_; |
| 1794 HeapStringAllocator string_allocator_; | 1940 HeapStringAllocator string_allocator_; |
| 1795 StringStream trace_; | 1941 StringStream trace_; |
| 1796 int indent_; | 1942 int indent_; |
| 1797 }; | 1943 }; |
| 1798 | 1944 |
| 1799 | 1945 |
| 1800 } } // namespace v8::internal | 1946 } } // namespace v8::internal |
| 1801 | 1947 |
| 1802 #endif // V8_HYDROGEN_H_ | 1948 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |