| 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(); |
| 276 void RestoreActualValues(); | 277 void RestoreActualValues(); |
| 277 void PropagateDeoptimizingMark(); | 278 void PropagateDeoptimizingMark(); |
| 278 void EliminateUnusedInstructions(); | 279 void EliminateUnusedInstructions(); |
| 279 | 280 |
| 280 // Returns false if there are phi-uses of the arguments-object | 281 // Returns false if there are phi-uses of the arguments-object |
| 281 // which are not supported by the optimizing compiler. | 282 // which are not supported by the optimizing compiler. |
| 282 bool CheckArgumentsPhiUses(); | 283 bool CheckArgumentsPhiUses(); |
| 283 | 284 |
| 284 // Returns false if there are phi-uses of an uninitialized const | 285 // Returns false if there are phi-uses of an uninitialized const |
| 285 // which are not supported by the optimizing compiler. | 286 // which are not supported by the optimizing compiler. |
| 286 bool CheckConstPhiUses(); | 287 bool CheckConstPhiUses(); |
| 287 | 288 |
| 288 void CollectPhis(); | 289 void CollectPhis(); |
| 289 | 290 |
| 290 void set_undefined_constant(HConstant* constant) { | 291 void set_undefined_constant(HConstant* constant) { |
| 291 undefined_constant_.set(constant); | 292 undefined_constant_.set(constant); |
| 292 } | 293 } |
| 293 HConstant* GetConstantUndefined() const { return undefined_constant_.get(); } | 294 HConstant* GetConstantUndefined() const { return undefined_constant_.get(); } |
| 295 HConstant* GetConstant0(); |
| 294 HConstant* GetConstant1(); | 296 HConstant* GetConstant1(); |
| 295 HConstant* GetConstantMinus1(); | 297 HConstant* GetConstantMinus1(); |
| 296 HConstant* GetConstantTrue(); | 298 HConstant* GetConstantTrue(); |
| 297 HConstant* GetConstantFalse(); | 299 HConstant* GetConstantFalse(); |
| 298 HConstant* GetConstantHole(); | 300 HConstant* GetConstantHole(); |
| 299 | 301 |
| 300 HBasicBlock* CreateBasicBlock(); | 302 HBasicBlock* CreateBasicBlock(); |
| 301 HArgumentsObject* GetArgumentsObject() const { | 303 HArgumentsObject* GetArgumentsObject() const { |
| 302 return arguments_object_.get(); | 304 return arguments_object_.get(); |
| 303 } | 305 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 404 |
| 403 Isolate* isolate_; | 405 Isolate* isolate_; |
| 404 int next_block_id_; | 406 int next_block_id_; |
| 405 HBasicBlock* entry_block_; | 407 HBasicBlock* entry_block_; |
| 406 HEnvironment* start_environment_; | 408 HEnvironment* start_environment_; |
| 407 ZoneList<HBasicBlock*> blocks_; | 409 ZoneList<HBasicBlock*> blocks_; |
| 408 ZoneList<HValue*> values_; | 410 ZoneList<HValue*> values_; |
| 409 ZoneList<HPhi*>* phi_list_; | 411 ZoneList<HPhi*>* phi_list_; |
| 410 ZoneList<HInstruction*>* uint32_instructions_; | 412 ZoneList<HInstruction*>* uint32_instructions_; |
| 411 SetOncePointer<HConstant> undefined_constant_; | 413 SetOncePointer<HConstant> undefined_constant_; |
| 414 SetOncePointer<HConstant> constant_0_; |
| 412 SetOncePointer<HConstant> constant_1_; | 415 SetOncePointer<HConstant> constant_1_; |
| 413 SetOncePointer<HConstant> constant_minus1_; | 416 SetOncePointer<HConstant> constant_minus1_; |
| 414 SetOncePointer<HConstant> constant_true_; | 417 SetOncePointer<HConstant> constant_true_; |
| 415 SetOncePointer<HConstant> constant_false_; | 418 SetOncePointer<HConstant> constant_false_; |
| 416 SetOncePointer<HConstant> constant_hole_; | 419 SetOncePointer<HConstant> constant_hole_; |
| 417 SetOncePointer<HArgumentsObject> arguments_object_; | 420 SetOncePointer<HArgumentsObject> arguments_object_; |
| 418 | 421 |
| 419 SetOncePointer<HBasicBlock> osr_loop_entry_; | 422 SetOncePointer<HBasicBlock> osr_loop_entry_; |
| 420 SetOncePointer<ZoneList<HUnknownOSRValue*> > osr_values_; | 423 SetOncePointer<ZoneList<HUnknownOSRValue*> > osr_values_; |
| 421 | 424 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 HGraph* CreateGraph(); | 870 HGraph* CreateGraph(); |
| 868 | 871 |
| 869 // Adding instructions. | 872 // Adding instructions. |
| 870 HInstruction* AddInstruction(HInstruction* instr); | 873 HInstruction* AddInstruction(HInstruction* instr); |
| 871 void AddSimulate(BailoutId id, | 874 void AddSimulate(BailoutId id, |
| 872 RemovableSimulate removable = FIXED_SIMULATE); | 875 RemovableSimulate removable = FIXED_SIMULATE); |
| 873 | 876 |
| 874 protected: | 877 protected: |
| 875 virtual bool BuildGraph() = 0; | 878 virtual bool BuildGraph() = 0; |
| 876 | 879 |
| 880 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
| 881 HBasicBlock* CreateLoopHeaderBlock(); |
| 882 |
| 877 // Building common constructs | 883 // Building common constructs |
| 878 HInstruction* BuildExternalArrayElementAccess( | 884 HInstruction* BuildExternalArrayElementAccess( |
| 879 HValue* external_elements, | 885 HValue* external_elements, |
| 880 HValue* checked_key, | 886 HValue* checked_key, |
| 881 HValue* val, | 887 HValue* val, |
| 882 HValue* dependency, | 888 HValue* dependency, |
| 883 ElementsKind elements_kind, | 889 ElementsKind elements_kind, |
| 884 bool is_store); | 890 bool is_store); |
| 885 | 891 |
| 886 HInstruction* BuildFastElementAccess( | 892 HInstruction* BuildFastElementAccess( |
| 887 HValue* elements, | 893 HValue* elements, |
| 888 HValue* checked_key, | 894 HValue* checked_key, |
| 889 HValue* val, | 895 HValue* val, |
| 890 HValue* dependency, | 896 HValue* dependency, |
| 891 ElementsKind elements_kind, | 897 ElementsKind elements_kind, |
| 892 bool is_store); | 898 bool is_store); |
| 893 | 899 |
| 894 HInstruction* BuildUncheckedMonomorphicElementAccess( | 900 HInstruction* BuildUncheckedMonomorphicElementAccess( |
| 895 HValue* object, | 901 HValue* object, |
| 896 HValue* key, | 902 HValue* key, |
| 897 HValue* val, | 903 HValue* val, |
| 898 HCheckMaps* mapcheck, | 904 HCheckMaps* mapcheck, |
| 899 bool is_js_array, | 905 bool is_js_array, |
| 900 ElementsKind elements_kind, | 906 ElementsKind elements_kind, |
| 901 bool is_store, | 907 bool is_store, |
| 902 Representation checked_index_representation = Representation::None()); | 908 Representation checked_index_representation = Representation::None()); |
| 903 | 909 |
| 910 |
| 911 class IfBuilder { |
| 912 public: |
| 913 IfBuilder(HGraphBuilder* builder, |
| 914 BailoutId id = BailoutId::StubEntry()); |
| 915 ~IfBuilder() { |
| 916 if (!finished_) End(); |
| 917 } |
| 918 |
| 919 void BeginTrue(HValue* left, HValue* right, Token::Value token); |
| 920 void BeginFalse(); |
| 921 void End(); |
| 922 |
| 923 private: |
| 924 HGraphBuilder* builder_; |
| 925 bool finished_; |
| 926 HEnvironment* true_env_; |
| 927 HEnvironment* false_env_; |
| 928 HEnvironment* merge_env_; |
| 929 HBasicBlock* true_block_; |
| 930 HBasicBlock* false_block_; |
| 931 HBasicBlock* merge_block_; |
| 932 BailoutId id_; |
| 933 |
| 934 Zone* zone() { return builder_->zone(); } |
| 935 }; |
| 936 |
| 937 class LoopBuilder { |
| 938 public: |
| 939 enum Direction { |
| 940 kPreIncrement, |
| 941 kPostIncrement, |
| 942 kPreDecrement, |
| 943 kPostDecrement |
| 944 }; |
| 945 |
| 946 LoopBuilder(HGraphBuilder* builder, |
| 947 HValue* context, |
| 948 Direction direction, |
| 949 BailoutId id = BailoutId::StubEntry()); |
| 950 ~LoopBuilder() { |
| 951 ASSERT(finished_); |
| 952 } |
| 953 |
| 954 HValue* BeginBody(HValue* initial, HValue* terminating, Token::Value token); |
| 955 void EndBody(); |
| 956 |
| 957 private: |
| 958 HGraphBuilder* builder_; |
| 959 HValue* context_; |
| 960 HInstruction* increment_; |
| 961 HPhi* phi_; |
| 962 HEnvironment* body_env_; |
| 963 HEnvironment* exit_env_; |
| 964 HBasicBlock* header_block_; |
| 965 HBasicBlock* body_block_; |
| 966 HBasicBlock* exit_block_; |
| 967 Direction direction_; |
| 968 BailoutId id_; |
| 969 bool finished_; |
| 970 |
| 971 Zone* zone() { return builder_->zone(); } |
| 972 }; |
| 973 |
| 974 HValue* BuildAllocateElements(HContext* context, |
| 975 ElementsKind kind, |
| 976 HValue* capacity); |
| 977 |
| 978 void BuildCopyElements(HContext* context, |
| 979 HValue* from_elements, |
| 980 ElementsKind from_elements_kind, |
| 981 HValue* to_elements, |
| 982 ElementsKind to_elements_kind, |
| 983 HValue* length); |
| 984 |
| 904 private: | 985 private: |
| 905 HGraphBuilder(); | 986 HGraphBuilder(); |
| 906 CompilationInfo* info_; | 987 CompilationInfo* info_; |
| 907 HGraph* graph_; | 988 HGraph* graph_; |
| 908 HBasicBlock* current_block_; | 989 HBasicBlock* current_block_; |
| 909 }; | 990 }; |
| 910 | 991 |
| 911 | 992 |
| 912 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 993 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
| 913 public: | 994 public: |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 | 1207 |
| 1127 static Representation ToRepresentation(TypeInfo info); | 1208 static Representation ToRepresentation(TypeInfo info); |
| 1128 | 1209 |
| 1129 void SetUpScope(Scope* scope); | 1210 void SetUpScope(Scope* scope); |
| 1130 virtual void VisitStatements(ZoneList<Statement*>* statements); | 1211 virtual void VisitStatements(ZoneList<Statement*>* statements); |
| 1131 | 1212 |
| 1132 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 1213 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 1133 AST_NODE_LIST(DECLARE_VISIT) | 1214 AST_NODE_LIST(DECLARE_VISIT) |
| 1134 #undef DECLARE_VISIT | 1215 #undef DECLARE_VISIT |
| 1135 | 1216 |
| 1136 HBasicBlock* CreateBasicBlock(HEnvironment* env); | |
| 1137 HBasicBlock* CreateLoopHeaderBlock(); | |
| 1138 | |
| 1139 // Helpers for flow graph construction. | 1217 // Helpers for flow graph construction. |
| 1140 enum GlobalPropertyAccess { | 1218 enum GlobalPropertyAccess { |
| 1141 kUseCell, | 1219 kUseCell, |
| 1142 kUseGeneric | 1220 kUseGeneric |
| 1143 }; | 1221 }; |
| 1144 GlobalPropertyAccess LookupGlobalProperty(Variable* var, | 1222 GlobalPropertyAccess LookupGlobalProperty(Variable* var, |
| 1145 LookupResult* lookup, | 1223 LookupResult* lookup, |
| 1146 bool is_store); | 1224 bool is_store); |
| 1147 | 1225 |
| 1148 void EnsureArgumentsArePushedForAccess(); | 1226 void EnsureArgumentsArePushedForAccess(); |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 const char* filename_; | 1655 const char* filename_; |
| 1578 HeapStringAllocator string_allocator_; | 1656 HeapStringAllocator string_allocator_; |
| 1579 StringStream trace_; | 1657 StringStream trace_; |
| 1580 int indent_; | 1658 int indent_; |
| 1581 }; | 1659 }; |
| 1582 | 1660 |
| 1583 | 1661 |
| 1584 } } // namespace v8::internal | 1662 } } // namespace v8::internal |
| 1585 | 1663 |
| 1586 #endif // V8_HYDROGEN_H_ | 1664 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |