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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 HBasicBlock* entry_block() const { return entry_block_; } | 256 HBasicBlock* entry_block() const { return entry_block_; } |
| 257 HEnvironment* start_environment() const { return start_environment_; } | 257 HEnvironment* start_environment() const { return start_environment_; } |
| 258 | 258 |
| 259 void InitializeInferredTypes(); | 259 void InitializeInferredTypes(); |
| 260 void InsertTypeConversions(); | 260 void InsertTypeConversions(); |
| 261 void MergeRemovableSimulates(); | 261 void MergeRemovableSimulates(); |
| 262 void InsertRepresentationChanges(); | 262 void InsertRepresentationChanges(); |
| 263 void MarkDeoptimizeOnUndefined(); | 263 void MarkDeoptimizeOnUndefined(); |
| 264 void ComputeMinusZeroChecks(); | 264 void ComputeMinusZeroChecks(); |
| 265 void ComputeSafeUint32Operations(); | 265 void ComputeSafeUint32Operations(); |
| 266 void GlobalValueNumbering(); | |
| 266 bool ProcessArgumentsObject(); | 267 bool ProcessArgumentsObject(); |
| 267 void EliminateRedundantPhis(); | 268 void EliminateRedundantPhis(); |
| 268 void EliminateUnreachablePhis(); | 269 void EliminateUnreachablePhis(); |
| 269 void Canonicalize(); | 270 void Canonicalize(); |
| 270 void OrderBlocks(); | 271 void OrderBlocks(); |
| 271 void AssignDominators(); | 272 void AssignDominators(); |
| 272 void ReplaceCheckedValues(); | 273 void ReplaceCheckedValues(); |
| 273 void EliminateRedundantBoundsChecks(); | 274 void EliminateRedundantBoundsChecks(); |
| 274 void DehoistSimpleArrayIndexComputations(); | 275 void DehoistSimpleArrayIndexComputations(); |
| 275 void DeadCodeElimination(); | 276 void DeadCodeElimination(); |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 843 // When inlining HEnterInlined instruction corresponding to the function | 844 // When inlining HEnterInlined instruction corresponding to the function |
| 844 // entry. | 845 // entry. |
| 845 HEnterInlined* entry_; | 846 HEnterInlined* entry_; |
| 846 | 847 |
| 847 HArgumentsElements* arguments_elements_; | 848 HArgumentsElements* arguments_elements_; |
| 848 | 849 |
| 849 FunctionState* outer_; | 850 FunctionState* outer_; |
| 850 }; | 851 }; |
| 851 | 852 |
| 852 | 853 |
| 854 class LoopBodyBuilder { | |
|
Michael Starzinger
2013/01/31 13:15:10
The LoopBodyBuilder seems to be left-over, drop it
danno
2013/01/31 15:53:25
Done.
| |
| 855 public: | |
| 856 virtual ~LoopBodyBuilder() {} | |
| 857 virtual void Build(HValue* current) = 0; | |
| 858 }; | |
| 859 | |
| 860 class CopyElementLoopBodyBuilder; | |
|
Michael Starzinger
2013/01/31 13:15:10
The CopyElementLoopBodyBuilder seems to be a left-
danno
2013/01/31 15:53:25
Done.
danno
2013/01/31 15:53:25
Done.
| |
| 861 | |
| 853 class HGraphBuilder { | 862 class HGraphBuilder { |
| 854 public: | 863 public: |
| 855 explicit HGraphBuilder(CompilationInfo* info) | 864 explicit HGraphBuilder(CompilationInfo* info) |
| 856 : info_(info), graph_(NULL), current_block_(NULL) {} | 865 : info_(info), graph_(NULL), current_block_(NULL) {} |
| 857 virtual ~HGraphBuilder() {} | 866 virtual ~HGraphBuilder() {} |
| 858 | 867 |
| 859 HBasicBlock* current_block() const { return current_block_; } | 868 HBasicBlock* current_block() const { return current_block_; } |
| 860 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 869 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
| 861 HEnvironment* environment() const { | 870 HEnvironment* environment() const { |
| 862 return current_block()->last_environment(); | 871 return current_block()->last_environment(); |
| 863 } | 872 } |
| 864 Zone* zone() const { return info_->zone(); } | 873 Zone* zone() const { return info_->zone(); } |
| 865 HGraph* graph() { return graph_; } | 874 HGraph* graph() { return graph_; } |
| 866 | 875 |
| 867 HGraph* CreateGraph(); | 876 HGraph* CreateGraph(); |
| 868 | 877 |
| 869 // Adding instructions. | 878 // Adding instructions. |
| 870 HInstruction* AddInstruction(HInstruction* instr); | 879 HInstruction* AddInstruction(HInstruction* instr); |
| 871 void AddSimulate(BailoutId id, | 880 void AddSimulate(BailoutId id, |
| 872 RemovableSimulate removable = FIXED_SIMULATE); | 881 RemovableSimulate removable = FIXED_SIMULATE); |
| 873 | 882 |
| 874 protected: | 883 protected: |
| 875 virtual bool BuildGraph() = 0; | 884 virtual bool BuildGraph() = 0; |
| 876 | 885 |
| 886 HBasicBlock* CreateBasicBlock(HEnvironment* env); | |
| 887 HBasicBlock* CreateLoopHeaderBlock(); | |
| 888 | |
| 877 // Building common constructs | 889 // Building common constructs |
| 878 HInstruction* BuildExternalArrayElementAccess( | 890 HInstruction* BuildExternalArrayElementAccess( |
| 879 HValue* external_elements, | 891 HValue* external_elements, |
| 880 HValue* checked_key, | 892 HValue* checked_key, |
| 881 HValue* val, | 893 HValue* val, |
| 882 HValue* dependency, | 894 HValue* dependency, |
| 883 ElementsKind elements_kind, | 895 ElementsKind elements_kind, |
| 884 bool is_store); | 896 bool is_store); |
| 885 | 897 |
| 886 HInstruction* BuildFastElementAccess( | 898 HInstruction* BuildFastElementAccess( |
| 887 HValue* elements, | 899 HValue* elements, |
| 888 HValue* checked_key, | 900 HValue* checked_key, |
| 889 HValue* val, | 901 HValue* val, |
| 890 HValue* dependency, | 902 HValue* dependency, |
| 891 ElementsKind elements_kind, | 903 ElementsKind elements_kind, |
| 892 bool is_store); | 904 bool is_store); |
| 893 | 905 |
| 894 HInstruction* BuildUncheckedMonomorphicElementAccess( | 906 HInstruction* BuildUncheckedMonomorphicElementAccess( |
| 895 HValue* object, | 907 HValue* object, |
| 896 HValue* key, | 908 HValue* key, |
| 897 HValue* val, | 909 HValue* val, |
| 898 HCheckMaps* mapcheck, | 910 HCheckMaps* mapcheck, |
| 899 bool is_js_array, | 911 bool is_js_array, |
| 900 ElementsKind elements_kind, | 912 ElementsKind elements_kind, |
| 901 bool is_store, | 913 bool is_store, |
| 902 Representation checked_index_representation = Representation::None()); | 914 Representation checked_index_representation = Representation::None()); |
| 903 | 915 |
| 916 HValue* IntegerConstant(int value); | |
|
Michael Starzinger
2013/01/31 13:15:10
There already is a HGraph::GetConstantInt32(), we
danno
2013/01/31 15:53:25
Done.
| |
| 917 HValue* Zero() { return IntegerConstant(0); } | |
| 918 HValue* One() { return IntegerConstant(1); } | |
| 919 | |
| 920 class IfBuilder { | |
| 921 public: | |
| 922 IfBuilder(HGraphBuilder* builder, | |
| 923 BailoutId id = BailoutId::StubEntry()); | |
| 924 ~IfBuilder() { | |
| 925 if (!finished_) End(); | |
| 926 } | |
| 927 | |
| 928 void BeginTrue(HValue* left, HValue* right, Token::Value token); | |
| 929 void BeginFalse(); | |
| 930 void End(); | |
| 931 | |
| 932 private: | |
| 933 HGraphBuilder* builder_; | |
| 934 bool finished_; | |
| 935 HEnvironment* true_env_; | |
| 936 HEnvironment* false_env_; | |
| 937 HEnvironment* merge_env_; | |
| 938 HBasicBlock* true_block_; | |
| 939 HBasicBlock* false_block_; | |
| 940 HBasicBlock* merge_block_; | |
| 941 BailoutId id_; | |
| 942 | |
| 943 Zone* zone() { return builder_->zone(); } | |
| 944 }; | |
| 945 | |
| 946 class LoopBuilder { | |
| 947 public: | |
| 948 enum Direction { | |
| 949 kPreIncrement, | |
| 950 kPostIncrement, | |
| 951 kPreDecrement, | |
| 952 kPostDecrement | |
| 953 }; | |
| 954 | |
| 955 LoopBuilder(HGraphBuilder* builder, | |
| 956 HValue* context, | |
| 957 Direction direction, | |
| 958 BailoutId id = BailoutId::StubEntry()); | |
| 959 ~LoopBuilder() { | |
| 960 ASSERT(finished_); | |
| 961 } | |
| 962 | |
| 963 HValue* BeginBody(HValue* initial, HValue* terminating, Token::Value token); | |
| 964 void EndBody(); | |
| 965 | |
| 966 private: | |
| 967 HGraphBuilder* builder_; | |
| 968 HValue* context_; | |
| 969 HInstruction* increment_; | |
| 970 HPhi* phi_; | |
| 971 HEnvironment* body_env_; | |
| 972 HEnvironment* exit_env_; | |
| 973 HBasicBlock* header_block_; | |
| 974 HBasicBlock* body_block_; | |
| 975 HBasicBlock* exit_block_; | |
| 976 Direction direction_; | |
| 977 BailoutId id_; | |
| 978 bool finished_; | |
| 979 | |
| 980 Zone* zone() { return builder_->zone(); } | |
| 981 }; | |
| 982 | |
| 983 HValue* BuildAllocateElements(HContext* context, | |
| 984 ElementsKind kind, | |
| 985 HValue* capacity); | |
| 986 | |
| 987 void BuildCopyElements(HContext* context, | |
| 988 HValue* from_elements, | |
| 989 ElementsKind from_elements_kind, | |
| 990 HValue* to_elements, | |
| 991 ElementsKind to_elements_kind, | |
| 992 HValue* length); | |
| 993 | |
| 904 private: | 994 private: |
| 995 friend class CopyElementLoopBodyBuilder; | |
|
Michael Starzinger
2013/01/31 13:15:10
The CopyElementLoopBodyBuilder seems to be a left-
danno
2013/01/31 15:53:25
Done.
| |
| 905 HGraphBuilder(); | 996 HGraphBuilder(); |
| 906 CompilationInfo* info_; | 997 CompilationInfo* info_; |
| 907 HGraph* graph_; | 998 HGraph* graph_; |
| 908 HBasicBlock* current_block_; | 999 HBasicBlock* current_block_; |
| 909 }; | 1000 }; |
| 910 | 1001 |
| 911 | 1002 |
| 912 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1003 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
| 913 public: | 1004 public: |
| 914 enum BreakType { BREAK, CONTINUE }; | 1005 enum BreakType { BREAK, CONTINUE }; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1126 | 1217 |
| 1127 static Representation ToRepresentation(TypeInfo info); | 1218 static Representation ToRepresentation(TypeInfo info); |
| 1128 | 1219 |
| 1129 void SetUpScope(Scope* scope); | 1220 void SetUpScope(Scope* scope); |
| 1130 virtual void VisitStatements(ZoneList<Statement*>* statements); | 1221 virtual void VisitStatements(ZoneList<Statement*>* statements); |
| 1131 | 1222 |
| 1132 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 1223 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 1133 AST_NODE_LIST(DECLARE_VISIT) | 1224 AST_NODE_LIST(DECLARE_VISIT) |
| 1134 #undef DECLARE_VISIT | 1225 #undef DECLARE_VISIT |
| 1135 | 1226 |
| 1136 HBasicBlock* CreateBasicBlock(HEnvironment* env); | |
| 1137 HBasicBlock* CreateLoopHeaderBlock(); | |
| 1138 | |
| 1139 // Helpers for flow graph construction. | 1227 // Helpers for flow graph construction. |
| 1140 enum GlobalPropertyAccess { | 1228 enum GlobalPropertyAccess { |
| 1141 kUseCell, | 1229 kUseCell, |
| 1142 kUseGeneric | 1230 kUseGeneric |
| 1143 }; | 1231 }; |
| 1144 GlobalPropertyAccess LookupGlobalProperty(Variable* var, | 1232 GlobalPropertyAccess LookupGlobalProperty(Variable* var, |
| 1145 LookupResult* lookup, | 1233 LookupResult* lookup, |
| 1146 bool is_store); | 1234 bool is_store); |
| 1147 | 1235 |
| 1148 void EnsureArgumentsArePushedForAccess(); | 1236 void EnsureArgumentsArePushedForAccess(); |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1577 const char* filename_; | 1665 const char* filename_; |
| 1578 HeapStringAllocator string_allocator_; | 1666 HeapStringAllocator string_allocator_; |
| 1579 StringStream trace_; | 1667 StringStream trace_; |
| 1580 int indent_; | 1668 int indent_; |
| 1581 }; | 1669 }; |
| 1582 | 1670 |
| 1583 | 1671 |
| 1584 } } // namespace v8::internal | 1672 } } // namespace v8::internal |
| 1585 | 1673 |
| 1586 #endif // V8_HYDROGEN_H_ | 1674 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |