| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 void AttachLoopInformation(); | 104 void AttachLoopInformation(); |
| 105 void DetachLoopInformation(); | 105 void DetachLoopInformation(); |
| 106 bool IsLoopHeader() const { return loop_information() != NULL; } | 106 bool IsLoopHeader() const { return loop_information() != NULL; } |
| 107 bool IsStartBlock() const { return block_id() == 0; } | 107 bool IsStartBlock() const { return block_id() == 0; } |
| 108 void PostProcessLoopHeader(IterationStatement* stmt); | 108 void PostProcessLoopHeader(IterationStatement* stmt); |
| 109 | 109 |
| 110 bool IsFinished() const { return end_ != NULL; } | 110 bool IsFinished() const { return end_ != NULL; } |
| 111 void AddPhi(HPhi* phi); | 111 void AddPhi(HPhi* phi); |
| 112 void RemovePhi(HPhi* phi); | 112 void RemovePhi(HPhi* phi); |
| 113 void AddInstruction(HInstruction* instr); | 113 void AddInstruction(HInstruction* instr, int position); |
| 114 bool Dominates(HBasicBlock* other) const; | 114 bool Dominates(HBasicBlock* other) const; |
| 115 int LoopNestingDepth() const; | 115 int LoopNestingDepth() const; |
| 116 | 116 |
| 117 void SetInitialEnvironment(HEnvironment* env); | 117 void SetInitialEnvironment(HEnvironment* env); |
| 118 void ClearEnvironment() { | 118 void ClearEnvironment() { |
| 119 ASSERT(IsFinished()); | 119 ASSERT(IsFinished()); |
| 120 ASSERT(end()->SuccessorCount() == 0); | 120 ASSERT(end()->SuccessorCount() == 0); |
| 121 last_environment_ = NULL; | 121 last_environment_ = NULL; |
| 122 } | 122 } |
| 123 bool HasEnvironment() const { return last_environment_ != NULL; } | 123 bool HasEnvironment() const { return last_environment_ != NULL; } |
| 124 void UpdateEnvironment(HEnvironment* env); | 124 void UpdateEnvironment(HEnvironment* env); |
| 125 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } | 125 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } |
| 126 | 126 |
| 127 void set_parent_loop_header(HBasicBlock* block) { | 127 void set_parent_loop_header(HBasicBlock* block) { |
| 128 ASSERT(parent_loop_header_ == NULL); | 128 ASSERT(parent_loop_header_ == NULL); |
| 129 parent_loop_header_ = block; | 129 parent_loop_header_ = block; |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } | 132 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } |
| 133 | 133 |
| 134 void SetJoinId(BailoutId ast_id); | 134 void SetJoinId(BailoutId ast_id); |
| 135 | 135 |
| 136 void Finish(HControlInstruction* last); | |
| 137 void FinishExit(HControlInstruction* instruction); | |
| 138 void Goto(HBasicBlock* block, | |
| 139 FunctionState* state = NULL, | |
| 140 bool add_simulate = true); | |
| 141 void GotoNoSimulate(HBasicBlock* block) { | |
| 142 Goto(block, NULL, false); | |
| 143 } | |
| 144 | |
| 145 int PredecessorIndexOf(HBasicBlock* predecessor) const; | 136 int PredecessorIndexOf(HBasicBlock* predecessor) const; |
| 146 HPhi* AddNewPhi(int merged_index); | 137 HPhi* AddNewPhi(int merged_index); |
| 147 HSimulate* AddNewSimulate(BailoutId ast_id, | 138 HSimulate* AddNewSimulate(BailoutId ast_id, |
| 139 int position, |
| 148 RemovableSimulate removable = FIXED_SIMULATE) { | 140 RemovableSimulate removable = FIXED_SIMULATE) { |
| 149 HSimulate* instr = CreateSimulate(ast_id, removable); | 141 HSimulate* instr = CreateSimulate(ast_id, removable); |
| 150 AddInstruction(instr); | 142 AddInstruction(instr, position); |
| 151 return instr; | 143 return instr; |
| 152 } | 144 } |
| 153 void AssignCommonDominator(HBasicBlock* other); | 145 void AssignCommonDominator(HBasicBlock* other); |
| 154 void AssignLoopSuccessorDominators(); | 146 void AssignLoopSuccessorDominators(); |
| 155 | 147 |
| 156 // Add the inlined function exit sequence, adding an HLeaveInlined | |
| 157 // instruction and updating the bailout environment. | |
| 158 void AddLeaveInlined(HValue* return_value, FunctionState* state); | |
| 159 | |
| 160 // If a target block is tagged as an inline function return, all | 148 // If a target block is tagged as an inline function return, all |
| 161 // predecessors should contain the inlined exit sequence: | 149 // predecessors should contain the inlined exit sequence: |
| 162 // | 150 // |
| 163 // LeaveInlined | 151 // LeaveInlined |
| 164 // Simulate (caller's environment) | 152 // Simulate (caller's environment) |
| 165 // Goto (target block) | 153 // Goto (target block) |
| 166 bool IsInlineReturnTarget() const { return is_inline_return_target_; } | 154 bool IsInlineReturnTarget() const { return is_inline_return_target_; } |
| 167 void MarkAsInlineReturnTarget(HBasicBlock* inlined_entry_block) { | 155 void MarkAsInlineReturnTarget(HBasicBlock* inlined_entry_block) { |
| 168 is_inline_return_target_ = true; | 156 is_inline_return_target_ = true; |
| 169 inlined_entry_block_ = inlined_entry_block; | 157 inlined_entry_block_ = inlined_entry_block; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 184 void MarkAsLoopSuccessorDominator() { | 172 void MarkAsLoopSuccessorDominator() { |
| 185 dominates_loop_successors_ = true; | 173 dominates_loop_successors_ = true; |
| 186 } | 174 } |
| 187 | 175 |
| 188 inline Zone* zone() const; | 176 inline Zone* zone() const; |
| 189 | 177 |
| 190 #ifdef DEBUG | 178 #ifdef DEBUG |
| 191 void Verify(); | 179 void Verify(); |
| 192 #endif | 180 #endif |
| 193 | 181 |
| 194 private: | 182 protected: |
| 195 friend class HGraphBuilder; | 183 friend class HGraphBuilder; |
| 196 | 184 |
| 185 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); |
| 186 void Finish(HControlInstruction* last, int position); |
| 187 void FinishExit(HControlInstruction* instruction, int position); |
| 188 void Goto(HBasicBlock* block, |
| 189 int position, |
| 190 FunctionState* state = NULL, |
| 191 bool add_simulate = true); |
| 192 void GotoNoSimulate(HBasicBlock* block, int position) { |
| 193 Goto(block, position, NULL, false); |
| 194 } |
| 195 |
| 196 // Add the inlined function exit sequence, adding an HLeaveInlined |
| 197 // instruction and updating the bailout environment. |
| 198 void AddLeaveInlined(HValue* return_value, |
| 199 FunctionState* state, |
| 200 int position); |
| 201 |
| 202 private: |
| 197 void RegisterPredecessor(HBasicBlock* pred); | 203 void RegisterPredecessor(HBasicBlock* pred); |
| 198 void AddDominatedBlock(HBasicBlock* block); | 204 void AddDominatedBlock(HBasicBlock* block); |
| 199 | 205 |
| 200 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); | |
| 201 | |
| 202 int block_id_; | 206 int block_id_; |
| 203 HGraph* graph_; | 207 HGraph* graph_; |
| 204 ZoneList<HPhi*> phis_; | 208 ZoneList<HPhi*> phis_; |
| 205 HInstruction* first_; | 209 HInstruction* first_; |
| 206 HInstruction* last_; | 210 HInstruction* last_; |
| 207 HControlInstruction* end_; | 211 HControlInstruction* end_; |
| 208 HLoopInformation* loop_information_; | 212 HLoopInformation* loop_information_; |
| 209 ZoneList<HBasicBlock*> predecessors_; | 213 ZoneList<HBasicBlock*> predecessors_; |
| 210 HBasicBlock* dominator_; | 214 HBasicBlock* dominator_; |
| 211 ZoneList<HBasicBlock*> dominated_blocks_; | 215 ZoneList<HBasicBlock*> dominated_blocks_; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // Returns false if there are phi-uses of the arguments-object | 335 // Returns false if there are phi-uses of the arguments-object |
| 332 // which are not supported by the optimizing compiler. | 336 // which are not supported by the optimizing compiler. |
| 333 bool CheckArgumentsPhiUses(); | 337 bool CheckArgumentsPhiUses(); |
| 334 | 338 |
| 335 // Returns false if there are phi-uses of an uninitialized const | 339 // Returns false if there are phi-uses of an uninitialized const |
| 336 // which are not supported by the optimizing compiler. | 340 // which are not supported by the optimizing compiler. |
| 337 bool CheckConstPhiUses(); | 341 bool CheckConstPhiUses(); |
| 338 | 342 |
| 339 void CollectPhis(); | 343 void CollectPhis(); |
| 340 | 344 |
| 341 void set_undefined_constant(HConstant* constant) { | 345 HConstant* GetConstantUndefined(); |
| 342 undefined_constant_.set(constant); | |
| 343 } | |
| 344 HConstant* GetConstantUndefined() const { return undefined_constant_.get(); } | |
| 345 HConstant* GetConstant0(); | 346 HConstant* GetConstant0(); |
| 346 HConstant* GetConstant1(); | 347 HConstant* GetConstant1(); |
| 347 HConstant* GetConstantMinus1(); | 348 HConstant* GetConstantMinus1(); |
| 348 HConstant* GetConstantTrue(); | 349 HConstant* GetConstantTrue(); |
| 349 HConstant* GetConstantFalse(); | 350 HConstant* GetConstantFalse(); |
| 350 HConstant* GetConstantHole(); | 351 HConstant* GetConstantHole(); |
| 351 HConstant* GetConstantNull(); | 352 HConstant* GetConstantNull(); |
| 352 HConstant* GetInvalidContext(); | 353 HConstant* GetInvalidContext(); |
| 353 | 354 |
| 354 bool IsStandardConstant(HConstant* constant); | 355 bool IsStandardConstant(HConstant* constant); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); | 450 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); |
| 450 } | 451 } |
| 451 uint32_instructions_->Add(instr, zone()); | 452 uint32_instructions_->Add(instr, zone()); |
| 452 } | 453 } |
| 453 | 454 |
| 454 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } | 455 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } |
| 455 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } | 456 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } |
| 456 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } | 457 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } |
| 457 | 458 |
| 458 private: | 459 private: |
| 460 HConstant* ReinsertConstantIfNecessary(HConstant* constant); |
| 459 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, | 461 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, |
| 460 int32_t integer_value); | 462 int32_t integer_value); |
| 461 | 463 |
| 462 template<class Phase> | 464 template<class Phase> |
| 463 void Run() { | 465 void Run() { |
| 464 Phase phase(this); | 466 Phase phase(this); |
| 465 phase.Run(); | 467 phase.Run(); |
| 466 } | 468 } |
| 467 | 469 |
| 468 void EliminateRedundantBoundsChecksUsingInductionVariables(); | 470 void EliminateRedundantBoundsChecksUsingInductionVariables(); |
| 469 | 471 |
| 470 Isolate* isolate_; | 472 Isolate* isolate_; |
| 471 int next_block_id_; | 473 int next_block_id_; |
| 472 HBasicBlock* entry_block_; | 474 HBasicBlock* entry_block_; |
| 473 HEnvironment* start_environment_; | 475 HEnvironment* start_environment_; |
| 474 ZoneList<HBasicBlock*> blocks_; | 476 ZoneList<HBasicBlock*> blocks_; |
| 475 ZoneList<HValue*> values_; | 477 ZoneList<HValue*> values_; |
| 476 ZoneList<HPhi*>* phi_list_; | 478 ZoneList<HPhi*>* phi_list_; |
| 477 ZoneList<HInstruction*>* uint32_instructions_; | 479 ZoneList<HInstruction*>* uint32_instructions_; |
| 478 SetOncePointer<HConstant> undefined_constant_; | 480 SetOncePointer<HConstant> constant_undefined_; |
| 479 SetOncePointer<HConstant> constant_0_; | 481 SetOncePointer<HConstant> constant_0_; |
| 480 SetOncePointer<HConstant> constant_1_; | 482 SetOncePointer<HConstant> constant_1_; |
| 481 SetOncePointer<HConstant> constant_minus1_; | 483 SetOncePointer<HConstant> constant_minus1_; |
| 482 SetOncePointer<HConstant> constant_true_; | 484 SetOncePointer<HConstant> constant_true_; |
| 483 SetOncePointer<HConstant> constant_false_; | 485 SetOncePointer<HConstant> constant_false_; |
| 484 SetOncePointer<HConstant> constant_the_hole_; | 486 SetOncePointer<HConstant> constant_the_hole_; |
| 485 SetOncePointer<HConstant> constant_null_; | 487 SetOncePointer<HConstant> constant_null_; |
| 486 SetOncePointer<HConstant> constant_invalid_context_; | 488 SetOncePointer<HConstant> constant_invalid_context_; |
| 487 SetOncePointer<HArgumentsObject> arguments_object_; | 489 SetOncePointer<HArgumentsObject> arguments_object_; |
| 488 | 490 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 HArgumentsElements* arguments_elements_; | 935 HArgumentsElements* arguments_elements_; |
| 934 | 936 |
| 935 FunctionState* outer_; | 937 FunctionState* outer_; |
| 936 }; | 938 }; |
| 937 | 939 |
| 938 | 940 |
| 939 class HIfContinuation V8_FINAL { | 941 class HIfContinuation V8_FINAL { |
| 940 public: | 942 public: |
| 941 HIfContinuation() : continuation_captured_(false) {} | 943 HIfContinuation() : continuation_captured_(false) {} |
| 942 HIfContinuation(HBasicBlock* true_branch, | 944 HIfContinuation(HBasicBlock* true_branch, |
| 943 HBasicBlock* false_branch, | 945 HBasicBlock* false_branch) |
| 944 int position = RelocInfo::kNoPosition) | |
| 945 : continuation_captured_(true), true_branch_(true_branch), | 946 : continuation_captured_(true), true_branch_(true_branch), |
| 946 false_branch_(false_branch), position_(position) {} | 947 false_branch_(false_branch) {} |
| 947 ~HIfContinuation() { ASSERT(!continuation_captured_); } | 948 ~HIfContinuation() { ASSERT(!continuation_captured_); } |
| 948 | 949 |
| 949 void Capture(HBasicBlock* true_branch, | 950 void Capture(HBasicBlock* true_branch, |
| 950 HBasicBlock* false_branch, | 951 HBasicBlock* false_branch) { |
| 951 int position) { | |
| 952 ASSERT(!continuation_captured_); | 952 ASSERT(!continuation_captured_); |
| 953 true_branch_ = true_branch; | 953 true_branch_ = true_branch; |
| 954 false_branch_ = false_branch; | 954 false_branch_ = false_branch; |
| 955 position_ = position; | |
| 956 continuation_captured_ = true; | 955 continuation_captured_ = true; |
| 957 } | 956 } |
| 958 | 957 |
| 959 void Continue(HBasicBlock** true_branch, | 958 void Continue(HBasicBlock** true_branch, |
| 960 HBasicBlock** false_branch, | 959 HBasicBlock** false_branch) { |
| 961 int* position) { | |
| 962 ASSERT(continuation_captured_); | 960 ASSERT(continuation_captured_); |
| 963 *true_branch = true_branch_; | 961 *true_branch = true_branch_; |
| 964 *false_branch = false_branch_; | 962 *false_branch = false_branch_; |
| 965 if (position != NULL) *position = position_; | |
| 966 continuation_captured_ = false; | 963 continuation_captured_ = false; |
| 967 } | 964 } |
| 968 | 965 |
| 969 bool IsTrueReachable() { return true_branch_ != NULL; } | 966 bool IsTrueReachable() { return true_branch_ != NULL; } |
| 970 bool IsFalseReachable() { return false_branch_ != NULL; } | 967 bool IsFalseReachable() { return false_branch_ != NULL; } |
| 971 bool TrueAndFalseReachable() { | 968 bool TrueAndFalseReachable() { |
| 972 return IsTrueReachable() || IsFalseReachable(); | 969 return IsTrueReachable() || IsFalseReachable(); |
| 973 } | 970 } |
| 974 | 971 |
| 975 HBasicBlock* true_branch() const { return true_branch_; } | 972 HBasicBlock* true_branch() const { return true_branch_; } |
| 976 HBasicBlock* false_branch() const { return false_branch_; } | 973 HBasicBlock* false_branch() const { return false_branch_; } |
| 977 | 974 |
| 978 private: | 975 private: |
| 979 bool continuation_captured_; | 976 bool continuation_captured_; |
| 980 HBasicBlock* true_branch_; | 977 HBasicBlock* true_branch_; |
| 981 HBasicBlock* false_branch_; | 978 HBasicBlock* false_branch_; |
| 982 int position_; | |
| 983 }; | 979 }; |
| 984 | 980 |
| 985 | 981 |
| 986 class HGraphBuilder { | 982 class HGraphBuilder { |
| 987 public: | 983 public: |
| 988 explicit HGraphBuilder(CompilationInfo* info) | 984 explicit HGraphBuilder(CompilationInfo* info) |
| 989 : info_(info), | 985 : info_(info), |
| 990 graph_(NULL), | 986 graph_(NULL), |
| 991 current_block_(NULL) {} | 987 current_block_(NULL), |
| 988 position_(RelocInfo::kNoPosition) {} |
| 992 virtual ~HGraphBuilder() {} | 989 virtual ~HGraphBuilder() {} |
| 993 | 990 |
| 994 HBasicBlock* current_block() const { return current_block_; } | 991 HBasicBlock* current_block() const { return current_block_; } |
| 995 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 992 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
| 996 HEnvironment* environment() const { | 993 HEnvironment* environment() const { |
| 997 return current_block()->last_environment(); | 994 return current_block()->last_environment(); |
| 998 } | 995 } |
| 999 Zone* zone() const { return info_->zone(); } | 996 Zone* zone() const { return info_->zone(); } |
| 1000 HGraph* graph() const { return graph_; } | 997 HGraph* graph() const { return graph_; } |
| 1001 Isolate* isolate() const { return graph_->isolate(); } | 998 Isolate* isolate() const { return graph_->isolate(); } |
| 1002 CompilationInfo* top_info() { return info_; } | 999 CompilationInfo* top_info() { return info_; } |
| 1003 | 1000 |
| 1004 HGraph* CreateGraph(); | 1001 HGraph* CreateGraph(); |
| 1005 | 1002 |
| 1006 // Bailout environment manipulation. | 1003 // Bailout environment manipulation. |
| 1007 void Push(HValue* value) { environment()->Push(value); } | 1004 void Push(HValue* value) { environment()->Push(value); } |
| 1008 HValue* Pop() { return environment()->Pop(); } | 1005 HValue* Pop() { return environment()->Pop(); } |
| 1009 | 1006 |
| 1010 virtual HValue* context() = 0; | 1007 virtual HValue* context() = 0; |
| 1011 | 1008 |
| 1012 // Adding instructions. | 1009 // Adding instructions. |
| 1013 HInstruction* AddInstruction(HInstruction* instr); | 1010 HInstruction* AddInstruction(HInstruction* instr); |
| 1011 void FinishCurrentBlock(HControlInstruction* last); |
| 1012 void FinishExitCurrentBlock(HControlInstruction* instruction); |
| 1013 |
| 1014 void Goto(HBasicBlock* from, |
| 1015 HBasicBlock* target, |
| 1016 FunctionState* state = NULL, |
| 1017 bool add_simulate = true) { |
| 1018 from->Goto(target, position_, state, add_simulate); |
| 1019 } |
| 1020 void Goto(HBasicBlock* target, |
| 1021 FunctionState* state = NULL, |
| 1022 bool add_simulate = true) { |
| 1023 Goto(current_block(), target, state, add_simulate); |
| 1024 } |
| 1025 void GotoNoSimulate(HBasicBlock* from, HBasicBlock* target) { |
| 1026 Goto(from, target, NULL, false); |
| 1027 } |
| 1028 void GotoNoSimulate(HBasicBlock* target) { |
| 1029 Goto(target, NULL, false); |
| 1030 } |
| 1031 void AddLeaveInlined(HBasicBlock* block, |
| 1032 HValue* return_value, |
| 1033 FunctionState* state) { |
| 1034 block->AddLeaveInlined(return_value, state, position_); |
| 1035 } |
| 1036 void AddLeaveInlined(HValue* return_value, FunctionState* state) { |
| 1037 return AddLeaveInlined(current_block(), return_value, state); |
| 1038 } |
| 1014 | 1039 |
| 1015 template<class I> | 1040 template<class I> |
| 1016 HInstruction* NewUncasted() { return I::New(zone(), context()); } | 1041 HInstruction* NewUncasted() { return I::New(zone(), context()); } |
| 1017 | 1042 |
| 1018 template<class I> | 1043 template<class I> |
| 1019 I* New() { return I::cast(NewUncasted<I>()); } | 1044 I* New() { return I::cast(NewUncasted<I>()); } |
| 1020 | 1045 |
| 1021 template<class I> | 1046 template<class I> |
| 1022 HInstruction* AddUncasted() { return AddInstruction(NewUncasted<I>());} | 1047 HInstruction* AddUncasted() { return AddInstruction(NewUncasted<I>());} |
| 1023 | 1048 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 | 1223 |
| 1199 template<class I, class P1, class P2, class P3, class P4, | 1224 template<class I, class P1, class P2, class P3, class P4, |
| 1200 class P5, class P6, class P7, class P8> | 1225 class P5, class P6, class P7, class P8> |
| 1201 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { | 1226 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { |
| 1202 return I::cast( | 1227 return I::cast( |
| 1203 AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8))); | 1228 AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8))); |
| 1204 } | 1229 } |
| 1205 | 1230 |
| 1206 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); | 1231 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); |
| 1207 | 1232 |
| 1233 int position() const { return position_; } |
| 1234 |
| 1208 protected: | 1235 protected: |
| 1209 virtual bool BuildGraph() = 0; | 1236 virtual bool BuildGraph() = 0; |
| 1210 | 1237 |
| 1211 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 1238 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
| 1212 HBasicBlock* CreateLoopHeaderBlock(); | 1239 HBasicBlock* CreateLoopHeaderBlock(); |
| 1213 | 1240 |
| 1214 HValue* BuildCheckHeapObject(HValue* object); | 1241 HValue* BuildCheckHeapObject(HValue* object); |
| 1215 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); | 1242 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); |
| 1216 HValue* BuildWrapReceiver(HValue* object, HValue* function); | 1243 HValue* BuildWrapReceiver(HValue* object, HValue* function); |
| 1217 | 1244 |
| 1218 // Building common constructs | 1245 // Building common constructs |
| 1219 HValue* BuildCheckForCapacityGrow(HValue* object, | 1246 HValue* BuildCheckForCapacityGrow(HValue* object, |
| 1220 HValue* elements, | 1247 HValue* elements, |
| 1221 ElementsKind kind, | 1248 ElementsKind kind, |
| 1222 HValue* length, | 1249 HValue* length, |
| 1223 HValue* key, | 1250 HValue* key, |
| 1224 bool is_js_array); | 1251 bool is_js_array); |
| 1225 | 1252 |
| 1226 HValue* BuildCopyElementsOnWrite(HValue* object, | 1253 HValue* BuildCopyElementsOnWrite(HValue* object, |
| 1227 HValue* elements, | 1254 HValue* elements, |
| 1228 ElementsKind kind, | 1255 ElementsKind kind, |
| 1229 HValue* length); | 1256 HValue* length); |
| 1230 | 1257 |
| 1231 void BuildTransitionElementsKind(HValue* object, | 1258 void BuildTransitionElementsKind(HValue* object, |
| 1232 HValue* map, | 1259 HValue* map, |
| 1233 ElementsKind from_kind, | 1260 ElementsKind from_kind, |
| 1234 ElementsKind to_kind, | 1261 ElementsKind to_kind, |
| 1235 bool is_jsarray); | 1262 bool is_jsarray); |
| 1236 | 1263 |
| 1237 // Do lookup in the number string cache. If the object is not found | 1264 HValue* BuildNumberToString(HValue* object, Handle<Type> type); |
| 1238 // in the cache, the false branch of the continuation is taken; | |
| 1239 // otherwise the true branch is taken and the returned value contains | |
| 1240 // the cache value for the object. The returned value must NOT be used | |
| 1241 // on the false branch. | |
| 1242 HValue* BuildLookupNumberStringCache(HValue* object, | |
| 1243 HIfContinuation* continuation); | |
| 1244 HValue* BuildNumberToString(HValue* number); | |
| 1245 | 1265 |
| 1246 HInstruction* BuildUncheckedMonomorphicElementAccess( | 1266 HInstruction* BuildUncheckedMonomorphicElementAccess( |
| 1247 HValue* checked_object, | 1267 HValue* checked_object, |
| 1248 HValue* key, | 1268 HValue* key, |
| 1249 HValue* val, | 1269 HValue* val, |
| 1250 bool is_js_array, | 1270 bool is_js_array, |
| 1251 ElementsKind elements_kind, | 1271 ElementsKind elements_kind, |
| 1252 bool is_store, | 1272 bool is_store, |
| 1253 LoadKeyedHoleMode load_mode, | 1273 LoadKeyedHoleMode load_mode, |
| 1254 KeyedAccessStoreMode store_mode); | 1274 KeyedAccessStoreMode store_mode); |
| 1255 | 1275 |
| 1256 HInstruction* AddExternalArrayElementAccess( | 1276 HInstruction* AddElementAccess( |
| 1257 HValue* external_elements, | |
| 1258 HValue* checked_key, | |
| 1259 HValue* val, | |
| 1260 HValue* dependency, | |
| 1261 ElementsKind elements_kind, | |
| 1262 bool is_store); | |
| 1263 | |
| 1264 HInstruction* AddFastElementAccess( | |
| 1265 HValue* elements, | 1277 HValue* elements, |
| 1266 HValue* checked_key, | 1278 HValue* checked_key, |
| 1267 HValue* val, | 1279 HValue* val, |
| 1268 HValue* dependency, | 1280 HValue* dependency, |
| 1269 ElementsKind elements_kind, | 1281 ElementsKind elements_kind, |
| 1270 bool is_store, | 1282 bool is_store, |
| 1271 LoadKeyedHoleMode load_mode, | 1283 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE); |
| 1272 KeyedAccessStoreMode store_mode); | |
| 1273 | 1284 |
| 1274 HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access); | 1285 HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access); |
| 1286 HInstruction* AddLoadNamedField(HValue* object, HObjectAccess access); |
| 1275 HInstruction* BuildLoadStringLength(HValue* object, HValue* checked_value); | 1287 HInstruction* BuildLoadStringLength(HValue* object, HValue* checked_value); |
| 1276 HStoreNamedField* AddStoreMapConstant(HValue* object, Handle<Map>); | 1288 HStoreNamedField* AddStoreMapConstant(HValue* object, Handle<Map>); |
| 1277 HLoadNamedField* AddLoadElements(HValue* object); | 1289 HLoadNamedField* AddLoadElements(HValue* object); |
| 1278 | 1290 |
| 1279 bool MatchRotateRight(HValue* left, | 1291 bool MatchRotateRight(HValue* left, |
| 1280 HValue* right, | 1292 HValue* right, |
| 1281 HValue** operand, | 1293 HValue** operand, |
| 1282 HValue** shift_amount); | 1294 HValue** shift_amount); |
| 1283 | 1295 |
| 1284 HInstruction* BuildBinaryOperation(Token::Value op, | 1296 HInstruction* BuildBinaryOperation(Token::Value op, |
| 1285 HValue* left, | 1297 HValue* left, |
| 1286 HValue* right, | 1298 HValue* right, |
| 1287 Handle<Type> left_type, | 1299 Handle<Type> left_type, |
| 1288 Handle<Type> right_type, | 1300 Handle<Type> right_type, |
| 1289 Handle<Type> result_type, | 1301 Handle<Type> result_type, |
| 1290 Maybe<int> fixed_right_arg, | 1302 Maybe<int> fixed_right_arg, |
| 1291 bool binop_stub = false); | 1303 bool binop_stub = false); |
| 1292 | 1304 |
| 1293 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); | 1305 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); |
| 1294 | 1306 |
| 1295 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin); | 1307 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin); |
| 1296 | 1308 |
| 1297 HValue* EnforceNumberType(HValue* number, Handle<Type> expected); | 1309 HValue* EnforceNumberType(HValue* number, Handle<Type> expected); |
| 1298 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); | 1310 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); |
| 1299 | 1311 |
| 1300 void PushAndAdd(HInstruction* instr); | |
| 1301 | |
| 1302 void FinishExitWithHardDeoptimization(const char* reason, | 1312 void FinishExitWithHardDeoptimization(const char* reason, |
| 1303 HBasicBlock* continuation); | 1313 HBasicBlock* continuation); |
| 1304 | 1314 |
| 1305 void AddIncrementCounter(StatsCounter* counter); | 1315 void AddIncrementCounter(StatsCounter* counter); |
| 1306 | 1316 |
| 1307 class IfBuilder V8_FINAL { | 1317 class IfBuilder V8_FINAL { |
| 1308 public: | 1318 public: |
| 1309 explicit IfBuilder(HGraphBuilder* builder, | 1319 explicit IfBuilder(HGraphBuilder* builder); |
| 1310 int position = RelocInfo::kNoPosition); | |
| 1311 IfBuilder(HGraphBuilder* builder, | 1320 IfBuilder(HGraphBuilder* builder, |
| 1312 HIfContinuation* continuation); | 1321 HIfContinuation* continuation); |
| 1313 | 1322 |
| 1314 ~IfBuilder() { | 1323 ~IfBuilder() { |
| 1315 if (!finished_) End(); | 1324 if (!finished_) End(); |
| 1316 } | 1325 } |
| 1317 | 1326 |
| 1318 template<class Condition> | 1327 template<class Condition> |
| 1319 Condition* If(HValue *p) { | 1328 Condition* If(HValue *p) { |
| 1320 Condition* compare = builder()->New<Condition>(p); | 1329 Condition* compare = builder()->New<Condition>(p); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 } | 1460 } |
| 1452 | 1461 |
| 1453 void Return(HValue* value); | 1462 void Return(HValue* value); |
| 1454 | 1463 |
| 1455 private: | 1464 private: |
| 1456 HControlInstruction* AddCompare(HControlInstruction* compare); | 1465 HControlInstruction* AddCompare(HControlInstruction* compare); |
| 1457 | 1466 |
| 1458 HGraphBuilder* builder() const { return builder_; } | 1467 HGraphBuilder* builder() const { return builder_; } |
| 1459 | 1468 |
| 1460 HGraphBuilder* builder_; | 1469 HGraphBuilder* builder_; |
| 1461 int position_; | |
| 1462 bool finished_ : 1; | 1470 bool finished_ : 1; |
| 1463 bool deopt_then_ : 1; | 1471 bool deopt_then_ : 1; |
| 1464 bool deopt_else_ : 1; | 1472 bool deopt_else_ : 1; |
| 1465 bool did_then_ : 1; | 1473 bool did_then_ : 1; |
| 1466 bool did_else_ : 1; | 1474 bool did_else_ : 1; |
| 1467 bool did_and_ : 1; | 1475 bool did_and_ : 1; |
| 1468 bool did_or_ : 1; | 1476 bool did_or_ : 1; |
| 1469 bool captured_ : 1; | 1477 bool captured_ : 1; |
| 1470 bool needs_compare_ : 1; | 1478 bool needs_compare_ : 1; |
| 1471 HBasicBlock* first_true_block_; | 1479 HBasicBlock* first_true_block_; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 | 1620 |
| 1613 HValue* BuildCloneShallowArray(HValue* boilerplate, | 1621 HValue* BuildCloneShallowArray(HValue* boilerplate, |
| 1614 HValue* allocation_site, | 1622 HValue* allocation_site, |
| 1615 AllocationSiteMode mode, | 1623 AllocationSiteMode mode, |
| 1616 ElementsKind kind, | 1624 ElementsKind kind, |
| 1617 int length); | 1625 int length); |
| 1618 | 1626 |
| 1619 void BuildCompareNil( | 1627 void BuildCompareNil( |
| 1620 HValue* value, | 1628 HValue* value, |
| 1621 Handle<Type> type, | 1629 Handle<Type> type, |
| 1622 int position, | |
| 1623 HIfContinuation* continuation); | 1630 HIfContinuation* continuation); |
| 1624 | 1631 |
| 1625 HValue* BuildCreateAllocationMemento(HValue* previous_object, | 1632 HValue* BuildCreateAllocationMemento(HValue* previous_object, |
| 1626 int previous_object_size, | 1633 int previous_object_size, |
| 1627 HValue* payload); | 1634 HValue* payload); |
| 1628 | 1635 |
| 1629 HInstruction* BuildConstantMapCheck(Handle<JSObject> constant, | 1636 HInstruction* BuildConstantMapCheck(Handle<JSObject> constant, |
| 1630 CompilationInfo* info); | 1637 CompilationInfo* info); |
| 1631 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype, | 1638 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype, |
| 1632 Handle<JSObject> holder); | 1639 Handle<JSObject> holder); |
| 1633 | 1640 |
| 1634 HInstruction* BuildGetNativeContext(); | 1641 HInstruction* BuildGetNativeContext(); |
| 1635 HInstruction* BuildGetArrayFunction(); | 1642 HInstruction* BuildGetArrayFunction(); |
| 1636 | 1643 |
| 1644 protected: |
| 1645 void SetSourcePosition(int position) { |
| 1646 ASSERT(position != RelocInfo::kNoPosition); |
| 1647 position_ = position; |
| 1648 } |
| 1649 |
| 1637 private: | 1650 private: |
| 1638 HGraphBuilder(); | 1651 HGraphBuilder(); |
| 1639 | 1652 |
| 1640 void PadEnvironmentForContinuation(HBasicBlock* from, | 1653 void PadEnvironmentForContinuation(HBasicBlock* from, |
| 1641 HBasicBlock* continuation); | 1654 HBasicBlock* continuation); |
| 1642 | 1655 |
| 1643 CompilationInfo* info_; | 1656 CompilationInfo* info_; |
| 1644 HGraph* graph_; | 1657 HGraph* graph_; |
| 1645 HBasicBlock* current_block_; | 1658 HBasicBlock* current_block_; |
| 1659 int position_; |
| 1646 }; | 1660 }; |
| 1647 | 1661 |
| 1648 | 1662 |
| 1649 template<> | 1663 template<> |
| 1650 inline HInstruction* HGraphBuilder::AddUncasted<HDeoptimize>( | 1664 inline HInstruction* HGraphBuilder::AddUncasted<HDeoptimize>( |
| 1651 const char* reason, Deoptimizer::BailoutType type) { | 1665 const char* reason, Deoptimizer::BailoutType type) { |
| 1652 if (type == Deoptimizer::SOFT) { | 1666 if (type == Deoptimizer::SOFT) { |
| 1653 isolate()->counters()->soft_deopts_requested()->Increment(); | 1667 isolate()->counters()->soft_deopts_requested()->Increment(); |
| 1654 if (FLAG_always_opt) return NULL; | 1668 if (FLAG_always_opt) return NULL; |
| 1655 } | 1669 } |
| 1656 if (current_block()->IsDeoptimizing()) return NULL; | 1670 if (current_block()->IsDeoptimizing()) return NULL; |
| 1657 HBasicBlock* after_deopt_block = CreateBasicBlock( | 1671 HBasicBlock* after_deopt_block = CreateBasicBlock( |
| 1658 current_block()->last_environment()); | 1672 current_block()->last_environment()); |
| 1659 HDeoptimize* instr = New<HDeoptimize>(reason, type, after_deopt_block); | 1673 HDeoptimize* instr = New<HDeoptimize>(reason, type, after_deopt_block); |
| 1660 if (type == Deoptimizer::SOFT) { | 1674 if (type == Deoptimizer::SOFT) { |
| 1661 isolate()->counters()->soft_deopts_inserted()->Increment(); | 1675 isolate()->counters()->soft_deopts_inserted()->Increment(); |
| 1662 } | 1676 } |
| 1663 current_block()->Finish(instr); | 1677 FinishCurrentBlock(instr); |
| 1664 set_current_block(after_deopt_block); | 1678 set_current_block(after_deopt_block); |
| 1665 return instr; | 1679 return instr; |
| 1666 } | 1680 } |
| 1667 | 1681 |
| 1668 | 1682 |
| 1669 template<> | 1683 template<> |
| 1670 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( | 1684 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( |
| 1671 const char* reason, Deoptimizer::BailoutType type) { | 1685 const char* reason, Deoptimizer::BailoutType type) { |
| 1672 return static_cast<HDeoptimize*>(AddUncasted<HDeoptimize>(reason, type)); | 1686 return static_cast<HDeoptimize*>(AddUncasted<HDeoptimize>(reason, type)); |
| 1673 } | 1687 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1687 inline HInstruction* HGraphBuilder::AddUncasted<HSimulate>(BailoutId id) { | 1701 inline HInstruction* HGraphBuilder::AddUncasted<HSimulate>(BailoutId id) { |
| 1688 return AddUncasted<HSimulate>(id, FIXED_SIMULATE); | 1702 return AddUncasted<HSimulate>(id, FIXED_SIMULATE); |
| 1689 } | 1703 } |
| 1690 | 1704 |
| 1691 | 1705 |
| 1692 template<> | 1706 template<> |
| 1693 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HValue* value) { | 1707 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HValue* value) { |
| 1694 int num_parameters = graph()->info()->num_parameters(); | 1708 int num_parameters = graph()->info()->num_parameters(); |
| 1695 HValue* params = AddUncasted<HConstant>(num_parameters); | 1709 HValue* params = AddUncasted<HConstant>(num_parameters); |
| 1696 HReturn* return_instruction = New<HReturn>(value, params); | 1710 HReturn* return_instruction = New<HReturn>(value, params); |
| 1697 current_block()->FinishExit(return_instruction); | 1711 FinishExitCurrentBlock(return_instruction); |
| 1698 return return_instruction; | 1712 return return_instruction; |
| 1699 } | 1713 } |
| 1700 | 1714 |
| 1701 | 1715 |
| 1702 template<> | 1716 template<> |
| 1703 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HConstant* value) { | 1717 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HConstant* value) { |
| 1704 return AddUncasted<HReturn>(static_cast<HValue*>(value)); | 1718 return AddUncasted<HReturn>(static_cast<HValue*>(value)); |
| 1705 } | 1719 } |
| 1706 | 1720 |
| 1707 | 1721 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1721 return instr; | 1735 return instr; |
| 1722 } | 1736 } |
| 1723 | 1737 |
| 1724 | 1738 |
| 1725 template<> | 1739 template<> |
| 1726 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() { | 1740 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() { |
| 1727 return HContext::New(zone()); | 1741 return HContext::New(zone()); |
| 1728 } | 1742 } |
| 1729 | 1743 |
| 1730 | 1744 |
| 1731 class HOptimizedGraphBuilder V8_FINAL | 1745 class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { |
| 1732 : public HGraphBuilder, public AstVisitor { | |
| 1733 public: | 1746 public: |
| 1734 // A class encapsulating (lazily-allocated) break and continue blocks for | 1747 // A class encapsulating (lazily-allocated) break and continue blocks for |
| 1735 // a breakable statement. Separated from BreakAndContinueScope so that it | 1748 // a breakable statement. Separated from BreakAndContinueScope so that it |
| 1736 // can have a separate lifetime. | 1749 // can have a separate lifetime. |
| 1737 class BreakAndContinueInfo V8_FINAL BASE_EMBEDDED { | 1750 class BreakAndContinueInfo V8_FINAL BASE_EMBEDDED { |
| 1738 public: | 1751 public: |
| 1739 explicit BreakAndContinueInfo(BreakableStatement* target, | 1752 explicit BreakAndContinueInfo(BreakableStatement* target, |
| 1740 int drop_extra = 0) | 1753 int drop_extra = 0) |
| 1741 : target_(target), | 1754 : target_(target), |
| 1742 break_block_(NULL), | 1755 break_block_(NULL), |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1809 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 1822 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 1810 | 1823 |
| 1811 void* operator new(size_t size, Zone* zone) { | 1824 void* operator new(size_t size, Zone* zone) { |
| 1812 return zone->New(static_cast<int>(size)); | 1825 return zone->New(static_cast<int>(size)); |
| 1813 } | 1826 } |
| 1814 void operator delete(void* pointer, Zone* zone) { } | 1827 void operator delete(void* pointer, Zone* zone) { } |
| 1815 void operator delete(void* pointer) { } | 1828 void operator delete(void* pointer) { } |
| 1816 | 1829 |
| 1817 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 1830 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 1818 | 1831 |
| 1819 private: | 1832 protected: |
| 1820 // Type of a member function that generates inline code for a native function. | 1833 // Type of a member function that generates inline code for a native function. |
| 1821 typedef void (HOptimizedGraphBuilder::*InlineFunctionGenerator) | 1834 typedef void (HOptimizedGraphBuilder::*InlineFunctionGenerator) |
| 1822 (CallRuntime* call); | 1835 (CallRuntime* call); |
| 1823 | 1836 |
| 1824 // Forward declarations for inner scope classes. | 1837 // Forward declarations for inner scope classes. |
| 1825 class SubgraphScope; | 1838 class SubgraphScope; |
| 1826 | 1839 |
| 1827 static const InlineFunctionGenerator kInlineFunctionGenerators[]; | 1840 static const InlineFunctionGenerator kInlineFunctionGenerators[]; |
| 1828 | 1841 |
| 1829 static const int kMaxCallPolymorphism = 4; | 1842 static const int kMaxCallPolymorphism = 4; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 !var->is_arguments() && | 1940 !var->is_arguments() && |
| 1928 !value->IsArgumentsObject() && | 1941 !value->IsArgumentsObject() && |
| 1929 env->is_local_index(index); | 1942 env->is_local_index(index); |
| 1930 } | 1943 } |
| 1931 void BindIfLive(Variable* var, HValue* value) { | 1944 void BindIfLive(Variable* var, HValue* value) { |
| 1932 HEnvironment* env = environment(); | 1945 HEnvironment* env = environment(); |
| 1933 int index = env->IndexFor(var); | 1946 int index = env->IndexFor(var); |
| 1934 env->Bind(index, value); | 1947 env->Bind(index, value); |
| 1935 if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) { | 1948 if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) { |
| 1936 HEnvironmentMarker* bind = | 1949 HEnvironmentMarker* bind = |
| 1937 new(zone()) HEnvironmentMarker(HEnvironmentMarker::BIND, index); | 1950 Add<HEnvironmentMarker>(HEnvironmentMarker::BIND, index); |
| 1938 AddInstruction(bind); | 1951 USE(bind); |
| 1939 #ifdef DEBUG | 1952 #ifdef DEBUG |
| 1940 bind->set_closure(env->closure()); | 1953 bind->set_closure(env->closure()); |
| 1941 #endif | 1954 #endif |
| 1942 } | 1955 } |
| 1943 } | 1956 } |
| 1957 |
| 1944 HValue* LookupAndMakeLive(Variable* var) { | 1958 HValue* LookupAndMakeLive(Variable* var) { |
| 1945 HEnvironment* env = environment(); | 1959 HEnvironment* env = environment(); |
| 1946 int index = env->IndexFor(var); | 1960 int index = env->IndexFor(var); |
| 1947 HValue* value = env->Lookup(index); | 1961 HValue* value = env->Lookup(index); |
| 1948 if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) { | 1962 if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) { |
| 1949 HEnvironmentMarker* lookup = | 1963 HEnvironmentMarker* lookup = |
| 1950 new(zone()) HEnvironmentMarker(HEnvironmentMarker::LOOKUP, index); | 1964 Add<HEnvironmentMarker>(HEnvironmentMarker::LOOKUP, index); |
| 1951 AddInstruction(lookup); | 1965 USE(lookup); |
| 1952 #ifdef DEBUG | 1966 #ifdef DEBUG |
| 1953 lookup->set_closure(env->closure()); | 1967 lookup->set_closure(env->closure()); |
| 1954 #endif | 1968 #endif |
| 1955 } | 1969 } |
| 1956 return value; | 1970 return value; |
| 1957 } | 1971 } |
| 1958 | 1972 |
| 1959 // The value of the arguments object is allowed in some but not most value | 1973 // The value of the arguments object is allowed in some but not most value |
| 1960 // contexts. (It's allowed in all effect contexts and disallowed in all | 1974 // contexts. (It's allowed in all effect contexts and disallowed in all |
| 1961 // test contexts.) | 1975 // test contexts.) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1979 // to push them as outgoing parameters. | 1993 // to push them as outgoing parameters. |
| 1980 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); | 1994 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); |
| 1981 | 1995 |
| 1982 void SetUpScope(Scope* scope); | 1996 void SetUpScope(Scope* scope); |
| 1983 virtual void VisitStatements(ZoneList<Statement*>* statements) V8_OVERRIDE; | 1997 virtual void VisitStatements(ZoneList<Statement*>* statements) V8_OVERRIDE; |
| 1984 | 1998 |
| 1985 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) V8_OVERRIDE; | 1999 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) V8_OVERRIDE; |
| 1986 AST_NODE_LIST(DECLARE_VISIT) | 2000 AST_NODE_LIST(DECLARE_VISIT) |
| 1987 #undef DECLARE_VISIT | 2001 #undef DECLARE_VISIT |
| 1988 | 2002 |
| 2003 private: |
| 1989 // Helpers for flow graph construction. | 2004 // Helpers for flow graph construction. |
| 1990 enum GlobalPropertyAccess { | 2005 enum GlobalPropertyAccess { |
| 1991 kUseCell, | 2006 kUseCell, |
| 1992 kUseGeneric | 2007 kUseGeneric |
| 1993 }; | 2008 }; |
| 1994 GlobalPropertyAccess LookupGlobalProperty(Variable* var, | 2009 GlobalPropertyAccess LookupGlobalProperty(Variable* var, |
| 1995 LookupResult* lookup, | 2010 LookupResult* lookup, |
| 1996 bool is_store); | 2011 bool is_store); |
| 1997 | 2012 |
| 1998 void EnsureArgumentsArePushedForAccess(); | 2013 void EnsureArgumentsArePushedForAccess(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2030 | 2045 |
| 2031 // If --trace-inlining, print a line of the inlining trace. Inlining | 2046 // If --trace-inlining, print a line of the inlining trace. Inlining |
| 2032 // succeeded if the reason string is NULL and failed if there is a | 2047 // succeeded if the reason string is NULL and failed if there is a |
| 2033 // non-NULL reason string. | 2048 // non-NULL reason string. |
| 2034 void TraceInline(Handle<JSFunction> target, | 2049 void TraceInline(Handle<JSFunction> target, |
| 2035 Handle<JSFunction> caller, | 2050 Handle<JSFunction> caller, |
| 2036 const char* failure_reason); | 2051 const char* failure_reason); |
| 2037 | 2052 |
| 2038 void HandleGlobalVariableAssignment(Variable* var, | 2053 void HandleGlobalVariableAssignment(Variable* var, |
| 2039 HValue* value, | 2054 HValue* value, |
| 2040 int position, | |
| 2041 BailoutId ast_id); | 2055 BailoutId ast_id); |
| 2042 | 2056 |
| 2043 void HandlePropertyAssignment(Assignment* expr); | 2057 void HandlePropertyAssignment(Assignment* expr); |
| 2044 void HandleCompoundAssignment(Assignment* expr); | 2058 void HandleCompoundAssignment(Assignment* expr); |
| 2045 void HandlePolymorphicLoadNamedField(int position, | 2059 void HandlePolymorphicLoadNamedField(BailoutId ast_id, |
| 2046 BailoutId ast_id, | |
| 2047 BailoutId return_id, | 2060 BailoutId return_id, |
| 2048 HValue* object, | 2061 HValue* object, |
| 2049 SmallMapList* types, | 2062 SmallMapList* types, |
| 2050 Handle<String> name); | 2063 Handle<String> name); |
| 2051 | 2064 |
| 2052 class PropertyAccessInfo { | 2065 class PropertyAccessInfo { |
| 2053 public: | 2066 public: |
| 2054 PropertyAccessInfo(Isolate* isolate, Handle<Map> map, Handle<String> name) | 2067 PropertyAccessInfo(Isolate* isolate, Handle<Map> map, Handle<String> name) |
| 2055 : lookup_(isolate), | 2068 : lookup_(isolate), |
| 2056 map_(map), | 2069 map_(map), |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2133 HObjectAccess access_; | 2146 HObjectAccess access_; |
| 2134 }; | 2147 }; |
| 2135 | 2148 |
| 2136 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info, | 2149 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info, |
| 2137 HValue* object, | 2150 HValue* object, |
| 2138 HInstruction* checked_object, | 2151 HInstruction* checked_object, |
| 2139 BailoutId ast_id, | 2152 BailoutId ast_id, |
| 2140 BailoutId return_id, | 2153 BailoutId return_id, |
| 2141 bool can_inline_accessor = true); | 2154 bool can_inline_accessor = true); |
| 2142 | 2155 |
| 2143 void HandlePolymorphicStoreNamedField(int position, | 2156 void HandlePolymorphicStoreNamedField(BailoutId assignment_id, |
| 2144 BailoutId assignment_id, | |
| 2145 HValue* object, | 2157 HValue* object, |
| 2146 HValue* value, | 2158 HValue* value, |
| 2147 SmallMapList* types, | 2159 SmallMapList* types, |
| 2148 Handle<String> name); | 2160 Handle<String> name); |
| 2149 bool TryStorePolymorphicAsMonomorphic(int position, | 2161 bool TryStorePolymorphicAsMonomorphic(BailoutId assignment_id, |
| 2150 BailoutId assignment_id, | |
| 2151 HValue* object, | 2162 HValue* object, |
| 2152 HValue* value, | 2163 HValue* value, |
| 2153 SmallMapList* types, | 2164 SmallMapList* types, |
| 2154 Handle<String> name); | 2165 Handle<String> name); |
| 2155 void HandlePolymorphicCallNamed(Call* expr, | 2166 void HandlePolymorphicCallNamed(Call* expr, |
| 2156 HValue* receiver, | 2167 HValue* receiver, |
| 2157 SmallMapList* types, | 2168 SmallMapList* types, |
| 2158 Handle<String> name); | 2169 Handle<String> name); |
| 2159 bool TryCallPolymorphicAsMonomorphic(Call* expr, | 2170 bool TryCallPolymorphicAsMonomorphic(Call* expr, |
| 2160 HValue* receiver, | 2171 HValue* receiver, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2189 HValue* val, | 2200 HValue* val, |
| 2190 HValue* dependency, | 2201 HValue* dependency, |
| 2191 Handle<Map> map, | 2202 Handle<Map> map, |
| 2192 bool is_store, | 2203 bool is_store, |
| 2193 KeyedAccessStoreMode store_mode); | 2204 KeyedAccessStoreMode store_mode); |
| 2194 | 2205 |
| 2195 HValue* HandlePolymorphicElementAccess(HValue* object, | 2206 HValue* HandlePolymorphicElementAccess(HValue* object, |
| 2196 HValue* key, | 2207 HValue* key, |
| 2197 HValue* val, | 2208 HValue* val, |
| 2198 SmallMapList* maps, | 2209 SmallMapList* maps, |
| 2199 BailoutId ast_id, | |
| 2200 int position, | |
| 2201 bool is_store, | 2210 bool is_store, |
| 2202 KeyedAccessStoreMode store_mode, | 2211 KeyedAccessStoreMode store_mode, |
| 2203 bool* has_side_effects); | 2212 bool* has_side_effects); |
| 2204 | 2213 |
| 2205 HValue* HandleKeyedElementAccess(HValue* obj, | 2214 HValue* HandleKeyedElementAccess(HValue* obj, |
| 2206 HValue* key, | 2215 HValue* key, |
| 2207 HValue* val, | 2216 HValue* val, |
| 2208 Expression* expr, | 2217 Expression* expr, |
| 2209 BailoutId ast_id, | |
| 2210 int position, | |
| 2211 bool is_store, | 2218 bool is_store, |
| 2212 bool* has_side_effects); | 2219 bool* has_side_effects); |
| 2213 | 2220 |
| 2214 HInstruction* BuildLoadNamedGeneric(HValue* object, | 2221 HInstruction* BuildLoadNamedGeneric(HValue* object, |
| 2215 Handle<String> name, | 2222 Handle<String> name, |
| 2216 Property* expr); | 2223 Property* expr); |
| 2217 | 2224 |
| 2218 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); | 2225 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); |
| 2219 | 2226 |
| 2220 void BuildLoad(Property* property, | 2227 void BuildLoad(Property* property, |
| 2221 int position, | |
| 2222 BailoutId ast_id); | 2228 BailoutId ast_id); |
| 2223 void PushLoad(Property* property, | 2229 void PushLoad(Property* property, |
| 2224 HValue* object, | 2230 HValue* object, |
| 2225 HValue* key, | 2231 HValue* key); |
| 2226 int position); | |
| 2227 | 2232 |
| 2228 void BuildStoreForEffect(Expression* expression, | 2233 void BuildStoreForEffect(Expression* expression, |
| 2229 Property* prop, | 2234 Property* prop, |
| 2230 BailoutId ast_id, | 2235 BailoutId ast_id, |
| 2231 BailoutId return_id, | 2236 BailoutId return_id, |
| 2232 HValue* object, | 2237 HValue* object, |
| 2233 HValue* key, | 2238 HValue* key, |
| 2234 HValue* value); | 2239 HValue* value); |
| 2235 | 2240 |
| 2236 void BuildStore(Expression* expression, | 2241 void BuildStore(Expression* expression, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2252 HValue* value, | 2257 HValue* value, |
| 2253 Handle<Map> map); | 2258 Handle<Map> map); |
| 2254 HInstruction* BuildStoreKeyedGeneric(HValue* object, | 2259 HInstruction* BuildStoreKeyedGeneric(HValue* object, |
| 2255 HValue* key, | 2260 HValue* key, |
| 2256 HValue* value); | 2261 HValue* value); |
| 2257 | 2262 |
| 2258 HValue* BuildContextChainWalk(Variable* var); | 2263 HValue* BuildContextChainWalk(Variable* var); |
| 2259 | 2264 |
| 2260 HInstruction* BuildThisFunction(); | 2265 HInstruction* BuildThisFunction(); |
| 2261 | 2266 |
| 2262 HInstruction* BuildFastLiteral(Handle<JSObject> boilerplate_object); | 2267 HInstruction* BuildFastLiteral(Handle<JSObject> boilerplate_object, |
| 2268 AllocationSiteContext* site_context); |
| 2263 | 2269 |
| 2264 void BuildEmitObjectHeader(Handle<JSObject> boilerplate_object, | 2270 void BuildEmitObjectHeader(Handle<JSObject> boilerplate_object, |
| 2265 HInstruction* object); | 2271 HInstruction* object); |
| 2266 | 2272 |
| 2267 void BuildInitElementsInObjectHeader(Handle<JSObject> boilerplate_object, | 2273 void BuildInitElementsInObjectHeader(Handle<JSObject> boilerplate_object, |
| 2268 HInstruction* object, | 2274 HInstruction* object, |
| 2269 HInstruction* object_elements); | 2275 HInstruction* object_elements); |
| 2270 | 2276 |
| 2271 void BuildEmitInObjectProperties(Handle<JSObject> boilerplate_object, | 2277 void BuildEmitInObjectProperties(Handle<JSObject> boilerplate_object, |
| 2272 HInstruction* object); | 2278 HInstruction* object, |
| 2279 AllocationSiteContext* site_context); |
| 2273 | 2280 |
| 2274 void BuildEmitElements(Handle<JSObject> boilerplate_object, | 2281 void BuildEmitElements(Handle<JSObject> boilerplate_object, |
| 2275 Handle<FixedArrayBase> elements, | 2282 Handle<FixedArrayBase> elements, |
| 2276 HValue* object_elements); | 2283 HValue* object_elements, |
| 2284 AllocationSiteContext* site_context); |
| 2277 | 2285 |
| 2278 void BuildEmitFixedDoubleArray(Handle<FixedArrayBase> elements, | 2286 void BuildEmitFixedDoubleArray(Handle<FixedArrayBase> elements, |
| 2279 ElementsKind kind, | 2287 ElementsKind kind, |
| 2280 HValue* object_elements); | 2288 HValue* object_elements); |
| 2281 | 2289 |
| 2282 void BuildEmitFixedArray(Handle<FixedArrayBase> elements, | 2290 void BuildEmitFixedArray(Handle<FixedArrayBase> elements, |
| 2283 ElementsKind kind, | 2291 ElementsKind kind, |
| 2284 HValue* object_elements); | 2292 HValue* object_elements, |
| 2293 AllocationSiteContext* site_context); |
| 2285 | 2294 |
| 2286 void AddCheckPrototypeMaps(Handle<JSObject> holder, | 2295 void AddCheckPrototypeMaps(Handle<JSObject> holder, |
| 2287 Handle<Map> receiver_map); | 2296 Handle<Map> receiver_map); |
| 2288 | 2297 |
| 2289 void AddCheckConstantFunction(Handle<JSObject> holder, | 2298 void AddCheckConstantFunction(Handle<JSObject> holder, |
| 2290 HValue* receiver, | 2299 HValue* receiver, |
| 2291 Handle<Map> receiver_map); | 2300 Handle<Map> receiver_map); |
| 2292 | 2301 |
| 2293 // The translation state of the currently-being-translated function. | 2302 // The translation state of the currently-being-translated function. |
| 2294 FunctionState* function_state_; | 2303 FunctionState* function_state_; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2474 } | 2483 } |
| 2475 | 2484 |
| 2476 private: | 2485 private: |
| 2477 HGraphBuilder* builder_; | 2486 HGraphBuilder* builder_; |
| 2478 }; | 2487 }; |
| 2479 | 2488 |
| 2480 | 2489 |
| 2481 } } // namespace v8::internal | 2490 } } // namespace v8::internal |
| 2482 | 2491 |
| 2483 #endif // V8_HYDROGEN_H_ | 2492 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |