| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 class HEnvironment; | 46 class HEnvironment; |
| 47 class HGraph; | 47 class HGraph; |
| 48 class HLoopInformation; | 48 class HLoopInformation; |
| 49 class HOsrBuilder; | 49 class HOsrBuilder; |
| 50 class HTracer; | 50 class HTracer; |
| 51 class LAllocator; | 51 class LAllocator; |
| 52 class LChunk; | 52 class LChunk; |
| 53 class LiveRange; | 53 class LiveRange; |
| 54 | 54 |
| 55 | 55 |
| 56 class HBasicBlock: public ZoneObject { | 56 class HBasicBlock V8_FINAL : public ZoneObject { |
| 57 public: | 57 public: |
| 58 explicit HBasicBlock(HGraph* graph); | 58 explicit HBasicBlock(HGraph* graph); |
| 59 virtual ~HBasicBlock() { } | 59 ~HBasicBlock() { } |
| 60 | 60 |
| 61 // Simple accessors. | 61 // Simple accessors. |
| 62 int block_id() const { return block_id_; } | 62 int block_id() const { return block_id_; } |
| 63 void set_block_id(int id) { block_id_ = id; } | 63 void set_block_id(int id) { block_id_ = id; } |
| 64 HGraph* graph() const { return graph_; } | 64 HGraph* graph() const { return graph_; } |
| 65 Isolate* isolate() const; | 65 Isolate* isolate() const; |
| 66 const ZoneList<HPhi*>* phis() const { return &phis_; } | 66 const ZoneList<HPhi*>* phis() const { return &phis_; } |
| 67 HInstruction* first() const { return first_; } | 67 HInstruction* first() const { return first_; } |
| 68 HInstruction* last() const { return last_; } | 68 HInstruction* last() const { return last_; } |
| 69 void set_last(HInstruction* instr) { last_ = instr; } | 69 void set_last(HInstruction* instr) { last_ = instr; } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 void Finish(HControlInstruction* last); | 135 void Finish(HControlInstruction* last); |
| 136 void FinishExit(HControlInstruction* instruction); | 136 void FinishExit(HControlInstruction* instruction); |
| 137 void Goto(HBasicBlock* block, | 137 void Goto(HBasicBlock* block, |
| 138 FunctionState* state = NULL, | 138 FunctionState* state = NULL, |
| 139 bool add_simulate = true); | 139 bool add_simulate = true); |
| 140 void GotoNoSimulate(HBasicBlock* block) { | 140 void GotoNoSimulate(HBasicBlock* block) { |
| 141 Goto(block, NULL, false); | 141 Goto(block, NULL, false); |
| 142 } | 142 } |
| 143 | 143 |
| 144 int PredecessorIndexOf(HBasicBlock* predecessor) const; | 144 int PredecessorIndexOf(HBasicBlock* predecessor) const; |
| 145 HSimulate* AddSimulate(BailoutId ast_id, | 145 HPhi* AddNewPhi(int merged_index); |
| 146 RemovableSimulate removable = FIXED_SIMULATE) { | 146 HSimulate* AddNewSimulate(BailoutId ast_id, |
| 147 RemovableSimulate removable = FIXED_SIMULATE) { |
| 147 HSimulate* instr = CreateSimulate(ast_id, removable); | 148 HSimulate* instr = CreateSimulate(ast_id, removable); |
| 148 AddInstruction(instr); | 149 AddInstruction(instr); |
| 149 return instr; | 150 return instr; |
| 150 } | 151 } |
| 151 void AssignCommonDominator(HBasicBlock* other); | 152 void AssignCommonDominator(HBasicBlock* other); |
| 152 void AssignLoopSuccessorDominators(); | 153 void AssignLoopSuccessorDominators(); |
| 153 | 154 |
| 154 // Add the inlined function exit sequence, adding an HLeaveInlined | 155 // Add the inlined function exit sequence, adding an HLeaveInlined |
| 155 // instruction and updating the bailout environment. | 156 // instruction and updating the bailout environment. |
| 156 void AddLeaveInlined(HValue* return_value, FunctionState* state); | 157 void AddLeaveInlined(HValue* return_value, FunctionState* state); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 HBasicBlock* parent_loop_header_; | 213 HBasicBlock* parent_loop_header_; |
| 213 // For blocks marked as inline return target: the block with HEnterInlined. | 214 // For blocks marked as inline return target: the block with HEnterInlined. |
| 214 HBasicBlock* inlined_entry_block_; | 215 HBasicBlock* inlined_entry_block_; |
| 215 bool is_inline_return_target_ : 1; | 216 bool is_inline_return_target_ : 1; |
| 216 bool is_deoptimizing_ : 1; | 217 bool is_deoptimizing_ : 1; |
| 217 bool dominates_loop_successors_ : 1; | 218 bool dominates_loop_successors_ : 1; |
| 218 bool is_osr_entry_ : 1; | 219 bool is_osr_entry_ : 1; |
| 219 }; | 220 }; |
| 220 | 221 |
| 221 | 222 |
| 222 class HPredecessorIterator BASE_EMBEDDED { | 223 class HPredecessorIterator V8_FINAL BASE_EMBEDDED { |
| 223 public: | 224 public: |
| 224 explicit HPredecessorIterator(HBasicBlock* block) | 225 explicit HPredecessorIterator(HBasicBlock* block) |
| 225 : predecessor_list_(block->predecessors()), current_(0) { } | 226 : predecessor_list_(block->predecessors()), current_(0) { } |
| 226 | 227 |
| 227 bool Done() { return current_ >= predecessor_list_->length(); } | 228 bool Done() { return current_ >= predecessor_list_->length(); } |
| 228 HBasicBlock* Current() { return predecessor_list_->at(current_); } | 229 HBasicBlock* Current() { return predecessor_list_->at(current_); } |
| 229 void Advance() { current_++; } | 230 void Advance() { current_++; } |
| 230 | 231 |
| 231 private: | 232 private: |
| 232 const ZoneList<HBasicBlock*>* predecessor_list_; | 233 const ZoneList<HBasicBlock*>* predecessor_list_; |
| 233 int current_; | 234 int current_; |
| 234 }; | 235 }; |
| 235 | 236 |
| 236 | 237 |
| 237 class HInstructionIterator BASE_EMBEDDED { | 238 class HInstructionIterator V8_FINAL BASE_EMBEDDED { |
| 238 public: | 239 public: |
| 239 explicit HInstructionIterator(HBasicBlock* block) | 240 explicit HInstructionIterator(HBasicBlock* block) |
| 240 : instr_(block->first()) { | 241 : instr_(block->first()) { |
| 241 next_ = Done() ? NULL : instr_->next(); | 242 next_ = Done() ? NULL : instr_->next(); |
| 242 } | 243 } |
| 243 | 244 |
| 244 inline bool Done() const { return instr_ == NULL; } | 245 inline bool Done() const { return instr_ == NULL; } |
| 245 inline HInstruction* Current() { return instr_; } | 246 inline HInstruction* Current() { return instr_; } |
| 246 inline void Advance() { | 247 inline void Advance() { |
| 247 instr_ = next_; | 248 instr_ = next_; |
| 248 next_ = Done() ? NULL : instr_->next(); | 249 next_ = Done() ? NULL : instr_->next(); |
| 249 } | 250 } |
| 250 | 251 |
| 251 private: | 252 private: |
| 252 HInstruction* instr_; | 253 HInstruction* instr_; |
| 253 HInstruction* next_; | 254 HInstruction* next_; |
| 254 }; | 255 }; |
| 255 | 256 |
| 256 | 257 |
| 257 class HLoopInformation: public ZoneObject { | 258 class HLoopInformation V8_FINAL : public ZoneObject { |
| 258 public: | 259 public: |
| 259 HLoopInformation(HBasicBlock* loop_header, Zone* zone) | 260 HLoopInformation(HBasicBlock* loop_header, Zone* zone) |
| 260 : back_edges_(4, zone), | 261 : back_edges_(4, zone), |
| 261 loop_header_(loop_header), | 262 loop_header_(loop_header), |
| 262 blocks_(8, zone), | 263 blocks_(8, zone), |
| 263 stack_check_(NULL) { | 264 stack_check_(NULL) { |
| 264 blocks_.Add(loop_header, zone); | 265 blocks_.Add(loop_header, zone); |
| 265 } | 266 } |
| 266 virtual ~HLoopInformation() {} | 267 ~HLoopInformation() {} |
| 267 | 268 |
| 268 const ZoneList<HBasicBlock*>* back_edges() const { return &back_edges_; } | 269 const ZoneList<HBasicBlock*>* back_edges() const { return &back_edges_; } |
| 269 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } | 270 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } |
| 270 HBasicBlock* loop_header() const { return loop_header_; } | 271 HBasicBlock* loop_header() const { return loop_header_; } |
| 271 HBasicBlock* GetLastBackEdge() const; | 272 HBasicBlock* GetLastBackEdge() const; |
| 272 void RegisterBackEdge(HBasicBlock* block); | 273 void RegisterBackEdge(HBasicBlock* block); |
| 273 | 274 |
| 274 HStackCheck* stack_check() const { return stack_check_; } | 275 HStackCheck* stack_check() const { return stack_check_; } |
| 275 void set_stack_check(HStackCheck* stack_check) { | 276 void set_stack_check(HStackCheck* stack_check) { |
| 276 stack_check_ = stack_check; | 277 stack_check_ = stack_check; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 295 | 296 |
| 296 ZoneList<HBasicBlock*> back_edges_; | 297 ZoneList<HBasicBlock*> back_edges_; |
| 297 HBasicBlock* loop_header_; | 298 HBasicBlock* loop_header_; |
| 298 ZoneList<HBasicBlock*> blocks_; | 299 ZoneList<HBasicBlock*> blocks_; |
| 299 HStackCheck* stack_check_; | 300 HStackCheck* stack_check_; |
| 300 }; | 301 }; |
| 301 | 302 |
| 302 | 303 |
| 303 class BoundsCheckTable; | 304 class BoundsCheckTable; |
| 304 class InductionVariableBlocksTable; | 305 class InductionVariableBlocksTable; |
| 305 class HGraph: public ZoneObject { | 306 class HGraph V8_FINAL : public ZoneObject { |
| 306 public: | 307 public: |
| 307 explicit HGraph(CompilationInfo* info); | 308 explicit HGraph(CompilationInfo* info); |
| 308 | 309 |
| 309 Isolate* isolate() const { return isolate_; } | 310 Isolate* isolate() const { return isolate_; } |
| 310 Zone* zone() const { return zone_; } | 311 Zone* zone() const { return zone_; } |
| 311 CompilationInfo* info() const { return info_; } | 312 CompilationInfo* info() const { return info_; } |
| 312 | 313 |
| 313 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } | 314 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } |
| 314 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } | 315 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } |
| 315 HBasicBlock* entry_block() const { return entry_block_; } | 316 HBasicBlock* entry_block() const { return entry_block_; } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 } | 447 } |
| 447 | 448 |
| 448 void RecordUint32Instruction(HInstruction* instr) { | 449 void RecordUint32Instruction(HInstruction* instr) { |
| 449 ASSERT(uint32_instructions_ == NULL || !uint32_instructions_->is_empty()); | 450 ASSERT(uint32_instructions_ == NULL || !uint32_instructions_->is_empty()); |
| 450 if (uint32_instructions_ == NULL) { | 451 if (uint32_instructions_ == NULL) { |
| 451 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); | 452 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); |
| 452 } | 453 } |
| 453 uint32_instructions_->Add(instr, zone()); | 454 uint32_instructions_->Add(instr, zone()); |
| 454 } | 455 } |
| 455 | 456 |
| 457 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } |
| 458 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } |
| 459 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } |
| 460 |
| 456 private: | 461 private: |
| 457 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, | 462 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, |
| 458 int32_t integer_value); | 463 int32_t integer_value); |
| 459 | 464 |
| 460 template<class Phase> | 465 template<class Phase> |
| 461 void Run() { | 466 void Run() { |
| 462 Phase phase(this); | 467 Phase phase(this); |
| 463 phase.Run(); | 468 phase.Run(); |
| 464 } | 469 } |
| 465 | 470 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 491 | 496 |
| 492 CompilationInfo* info_; | 497 CompilationInfo* info_; |
| 493 Zone* zone_; | 498 Zone* zone_; |
| 494 | 499 |
| 495 bool is_recursive_; | 500 bool is_recursive_; |
| 496 bool use_optimistic_licm_; | 501 bool use_optimistic_licm_; |
| 497 bool has_soft_deoptimize_; | 502 bool has_soft_deoptimize_; |
| 498 bool depends_on_empty_array_proto_elements_; | 503 bool depends_on_empty_array_proto_elements_; |
| 499 int type_change_checksum_; | 504 int type_change_checksum_; |
| 500 int maximum_environment_size_; | 505 int maximum_environment_size_; |
| 506 int no_side_effects_scope_count_; |
| 501 | 507 |
| 502 DISALLOW_COPY_AND_ASSIGN(HGraph); | 508 DISALLOW_COPY_AND_ASSIGN(HGraph); |
| 503 }; | 509 }; |
| 504 | 510 |
| 505 | 511 |
| 506 Zone* HBasicBlock::zone() const { return graph_->zone(); } | 512 Zone* HBasicBlock::zone() const { return graph_->zone(); } |
| 507 | 513 |
| 508 | 514 |
| 509 // Type of stack frame an environment might refer to. | 515 // Type of stack frame an environment might refer to. |
| 510 enum FrameType { | 516 enum FrameType { |
| 511 JS_FUNCTION, | 517 JS_FUNCTION, |
| 512 JS_CONSTRUCT, | 518 JS_CONSTRUCT, |
| 513 JS_GETTER, | 519 JS_GETTER, |
| 514 JS_SETTER, | 520 JS_SETTER, |
| 515 ARGUMENTS_ADAPTOR, | 521 ARGUMENTS_ADAPTOR, |
| 516 STUB | 522 STUB |
| 517 }; | 523 }; |
| 518 | 524 |
| 519 | 525 |
| 520 class HEnvironment: public ZoneObject { | 526 class HEnvironment V8_FINAL : public ZoneObject { |
| 521 public: | 527 public: |
| 522 HEnvironment(HEnvironment* outer, | 528 HEnvironment(HEnvironment* outer, |
| 523 Scope* scope, | 529 Scope* scope, |
| 524 Handle<JSFunction> closure, | 530 Handle<JSFunction> closure, |
| 525 Zone* zone); | 531 Zone* zone); |
| 526 | 532 |
| 527 HEnvironment(Zone* zone, int parameter_count); | 533 HEnvironment(Zone* zone, int parameter_count); |
| 528 | 534 |
| 529 HEnvironment* arguments_environment() { | 535 HEnvironment* arguments_environment() { |
| 530 return outer()->frame_type() == ARGUMENTS_ADAPTOR ? outer() : this; | 536 return outer()->frame_type() == ARGUMENTS_ADAPTOR ? outer() : this; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 #endif | 786 #endif |
| 781 | 787 |
| 782 private: | 788 private: |
| 783 HOptimizedGraphBuilder* owner_; | 789 HOptimizedGraphBuilder* owner_; |
| 784 Expression::Context kind_; | 790 Expression::Context kind_; |
| 785 AstContext* outer_; | 791 AstContext* outer_; |
| 786 bool for_typeof_; | 792 bool for_typeof_; |
| 787 }; | 793 }; |
| 788 | 794 |
| 789 | 795 |
| 790 class EffectContext: public AstContext { | 796 class EffectContext V8_FINAL : public AstContext { |
| 791 public: | 797 public: |
| 792 explicit EffectContext(HOptimizedGraphBuilder* owner) | 798 explicit EffectContext(HOptimizedGraphBuilder* owner) |
| 793 : AstContext(owner, Expression::kEffect) { | 799 : AstContext(owner, Expression::kEffect) { |
| 794 } | 800 } |
| 795 virtual ~EffectContext(); | 801 virtual ~EffectContext(); |
| 796 | 802 |
| 797 virtual void ReturnValue(HValue* value); | 803 virtual void ReturnValue(HValue* value) V8_OVERRIDE; |
| 798 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); | 804 virtual void ReturnInstruction(HInstruction* instr, |
| 799 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); | 805 BailoutId ast_id) V8_OVERRIDE; |
| 806 virtual void ReturnControl(HControlInstruction* instr, |
| 807 BailoutId ast_id) V8_OVERRIDE; |
| 800 virtual void ReturnContinuation(HIfContinuation* continuation, | 808 virtual void ReturnContinuation(HIfContinuation* continuation, |
| 801 BailoutId ast_id); | 809 BailoutId ast_id) V8_OVERRIDE; |
| 802 }; | 810 }; |
| 803 | 811 |
| 804 | 812 |
| 805 class ValueContext: public AstContext { | 813 class ValueContext V8_FINAL : public AstContext { |
| 806 public: | 814 public: |
| 807 ValueContext(HOptimizedGraphBuilder* owner, ArgumentsAllowedFlag flag) | 815 ValueContext(HOptimizedGraphBuilder* owner, ArgumentsAllowedFlag flag) |
| 808 : AstContext(owner, Expression::kValue), flag_(flag) { | 816 : AstContext(owner, Expression::kValue), flag_(flag) { |
| 809 } | 817 } |
| 810 virtual ~ValueContext(); | 818 virtual ~ValueContext(); |
| 811 | 819 |
| 812 virtual void ReturnValue(HValue* value); | 820 virtual void ReturnValue(HValue* value) V8_OVERRIDE; |
| 813 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); | 821 virtual void ReturnInstruction(HInstruction* instr, |
| 814 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); | 822 BailoutId ast_id) V8_OVERRIDE; |
| 823 virtual void ReturnControl(HControlInstruction* instr, |
| 824 BailoutId ast_id) V8_OVERRIDE; |
| 815 virtual void ReturnContinuation(HIfContinuation* continuation, | 825 virtual void ReturnContinuation(HIfContinuation* continuation, |
| 816 BailoutId ast_id); | 826 BailoutId ast_id) V8_OVERRIDE; |
| 817 | 827 |
| 818 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } | 828 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } |
| 819 | 829 |
| 820 private: | 830 private: |
| 821 ArgumentsAllowedFlag flag_; | 831 ArgumentsAllowedFlag flag_; |
| 822 }; | 832 }; |
| 823 | 833 |
| 824 | 834 |
| 825 class TestContext: public AstContext { | 835 class TestContext V8_FINAL : public AstContext { |
| 826 public: | 836 public: |
| 827 TestContext(HOptimizedGraphBuilder* owner, | 837 TestContext(HOptimizedGraphBuilder* owner, |
| 828 Expression* condition, | 838 Expression* condition, |
| 829 HBasicBlock* if_true, | 839 HBasicBlock* if_true, |
| 830 HBasicBlock* if_false) | 840 HBasicBlock* if_false) |
| 831 : AstContext(owner, Expression::kTest), | 841 : AstContext(owner, Expression::kTest), |
| 832 condition_(condition), | 842 condition_(condition), |
| 833 if_true_(if_true), | 843 if_true_(if_true), |
| 834 if_false_(if_false) { | 844 if_false_(if_false) { |
| 835 } | 845 } |
| 836 | 846 |
| 837 virtual void ReturnValue(HValue* value); | 847 virtual void ReturnValue(HValue* value) V8_OVERRIDE; |
| 838 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); | 848 virtual void ReturnInstruction(HInstruction* instr, |
| 839 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); | 849 BailoutId ast_id) V8_OVERRIDE; |
| 850 virtual void ReturnControl(HControlInstruction* instr, |
| 851 BailoutId ast_id) V8_OVERRIDE; |
| 840 virtual void ReturnContinuation(HIfContinuation* continuation, | 852 virtual void ReturnContinuation(HIfContinuation* continuation, |
| 841 BailoutId ast_id); | 853 BailoutId ast_id) V8_OVERRIDE; |
| 842 | 854 |
| 843 static TestContext* cast(AstContext* context) { | 855 static TestContext* cast(AstContext* context) { |
| 844 ASSERT(context->IsTest()); | 856 ASSERT(context->IsTest()); |
| 845 return reinterpret_cast<TestContext*>(context); | 857 return reinterpret_cast<TestContext*>(context); |
| 846 } | 858 } |
| 847 | 859 |
| 848 Expression* condition() const { return condition_; } | 860 Expression* condition() const { return condition_; } |
| 849 HBasicBlock* if_true() const { return if_true_; } | 861 HBasicBlock* if_true() const { return if_true_; } |
| 850 HBasicBlock* if_false() const { return if_false_; } | 862 HBasicBlock* if_false() const { return if_false_; } |
| 851 | 863 |
| 852 private: | 864 private: |
| 853 // Build the shared core part of the translation unpacking a value into | 865 // Build the shared core part of the translation unpacking a value into |
| 854 // control flow. | 866 // control flow. |
| 855 void BuildBranch(HValue* value); | 867 void BuildBranch(HValue* value); |
| 856 | 868 |
| 857 Expression* condition_; | 869 Expression* condition_; |
| 858 HBasicBlock* if_true_; | 870 HBasicBlock* if_true_; |
| 859 HBasicBlock* if_false_; | 871 HBasicBlock* if_false_; |
| 860 }; | 872 }; |
| 861 | 873 |
| 862 | 874 |
| 863 class FunctionState { | 875 class FunctionState V8_FINAL { |
| 864 public: | 876 public: |
| 865 FunctionState(HOptimizedGraphBuilder* owner, | 877 FunctionState(HOptimizedGraphBuilder* owner, |
| 866 CompilationInfo* info, | 878 CompilationInfo* info, |
| 867 InliningKind inlining_kind); | 879 InliningKind inlining_kind); |
| 868 ~FunctionState(); | 880 ~FunctionState(); |
| 869 | 881 |
| 870 CompilationInfo* compilation_info() { return compilation_info_; } | 882 CompilationInfo* compilation_info() { return compilation_info_; } |
| 871 AstContext* call_context() { return call_context_; } | 883 AstContext* call_context() { return call_context_; } |
| 872 InliningKind inlining_kind() const { return inlining_kind_; } | 884 InliningKind inlining_kind() const { return inlining_kind_; } |
| 873 HBasicBlock* function_return() { return function_return_; } | 885 HBasicBlock* function_return() { return function_return_; } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 // entry. | 932 // entry. |
| 921 HEnterInlined* entry_; | 933 HEnterInlined* entry_; |
| 922 | 934 |
| 923 HArgumentsObject* arguments_object_; | 935 HArgumentsObject* arguments_object_; |
| 924 HArgumentsElements* arguments_elements_; | 936 HArgumentsElements* arguments_elements_; |
| 925 | 937 |
| 926 FunctionState* outer_; | 938 FunctionState* outer_; |
| 927 }; | 939 }; |
| 928 | 940 |
| 929 | 941 |
| 930 class HIfContinuation { | 942 class HIfContinuation V8_FINAL { |
| 931 public: | 943 public: |
| 932 HIfContinuation() { continuation_captured_ = false; } | 944 HIfContinuation() { continuation_captured_ = false; } |
| 933 ~HIfContinuation() { ASSERT(!continuation_captured_); } | 945 ~HIfContinuation() { ASSERT(!continuation_captured_); } |
| 934 | 946 |
| 935 void Capture(HBasicBlock* true_branch, | 947 void Capture(HBasicBlock* true_branch, |
| 936 HBasicBlock* false_branch, | 948 HBasicBlock* false_branch, |
| 937 int position) { | 949 int position) { |
| 938 ASSERT(!continuation_captured_); | 950 ASSERT(!continuation_captured_); |
| 939 true_branch_ = true_branch; | 951 true_branch_ = true_branch; |
| 940 false_branch_ = false_branch; | 952 false_branch_ = false_branch; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 963 HBasicBlock* false_branch_; | 975 HBasicBlock* false_branch_; |
| 964 int position_; | 976 int position_; |
| 965 }; | 977 }; |
| 966 | 978 |
| 967 | 979 |
| 968 class HGraphBuilder { | 980 class HGraphBuilder { |
| 969 public: | 981 public: |
| 970 explicit HGraphBuilder(CompilationInfo* info) | 982 explicit HGraphBuilder(CompilationInfo* info) |
| 971 : info_(info), | 983 : info_(info), |
| 972 graph_(NULL), | 984 graph_(NULL), |
| 973 current_block_(NULL), | 985 current_block_(NULL) {} |
| 974 no_side_effects_scope_count_(0) {} | |
| 975 virtual ~HGraphBuilder() {} | 986 virtual ~HGraphBuilder() {} |
| 976 | 987 |
| 977 HBasicBlock* current_block() const { return current_block_; } | 988 HBasicBlock* current_block() const { return current_block_; } |
| 978 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 989 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
| 979 HEnvironment* environment() const { | 990 HEnvironment* environment() const { |
| 980 return current_block()->last_environment(); | 991 return current_block()->last_environment(); |
| 981 } | 992 } |
| 982 Zone* zone() const { return info_->zone(); } | 993 Zone* zone() const { return info_->zone(); } |
| 983 HGraph* graph() const { return graph_; } | 994 HGraph* graph() const { return graph_; } |
| 984 Isolate* isolate() const { return graph_->isolate(); } | 995 Isolate* isolate() const { return graph_->isolate(); } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8)); | 1190 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8)); |
| 1180 } | 1191 } |
| 1181 | 1192 |
| 1182 template<class I, class P1, class P2, class P3, class P4, | 1193 template<class I, class P1, class P2, class P3, class P4, |
| 1183 class P5, class P6, class P7, class P8> | 1194 class P5, class P6, class P7, class P8> |
| 1184 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { | 1195 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { |
| 1185 return I::cast( | 1196 return I::cast( |
| 1186 AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8))); | 1197 AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8))); |
| 1187 } | 1198 } |
| 1188 | 1199 |
| 1189 void AddSimulate(BailoutId id, | 1200 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); |
| 1190 RemovableSimulate removable = FIXED_SIMULATE); | |
| 1191 | |
| 1192 void IncrementInNoSideEffectsScope() { | |
| 1193 no_side_effects_scope_count_++; | |
| 1194 } | |
| 1195 | |
| 1196 void DecrementInNoSideEffectsScope() { | |
| 1197 no_side_effects_scope_count_--; | |
| 1198 } | |
| 1199 | 1201 |
| 1200 protected: | 1202 protected: |
| 1201 virtual bool BuildGraph() = 0; | 1203 virtual bool BuildGraph() = 0; |
| 1202 | 1204 |
| 1203 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 1205 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
| 1204 HBasicBlock* CreateLoopHeaderBlock(); | 1206 HBasicBlock* CreateLoopHeaderBlock(); |
| 1205 | 1207 |
| 1206 HValue* BuildCheckHeapObject(HValue* object); | 1208 HValue* BuildCheckHeapObject(HValue* object); |
| 1207 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); | 1209 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); |
| 1208 HValue* BuildWrapReceiver(HValue* object, HValue* function); | 1210 HValue* BuildWrapReceiver(HValue* object, HValue* function); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 HValue* val, | 1253 HValue* val, |
| 1252 HValue* dependency, | 1254 HValue* dependency, |
| 1253 ElementsKind elements_kind, | 1255 ElementsKind elements_kind, |
| 1254 bool is_store, | 1256 bool is_store, |
| 1255 LoadKeyedHoleMode load_mode, | 1257 LoadKeyedHoleMode load_mode, |
| 1256 KeyedAccessStoreMode store_mode); | 1258 KeyedAccessStoreMode store_mode); |
| 1257 | 1259 |
| 1258 HLoadNamedField* BuildLoadNamedField( | 1260 HLoadNamedField* BuildLoadNamedField( |
| 1259 HValue* object, | 1261 HValue* object, |
| 1260 HObjectAccess access, | 1262 HObjectAccess access, |
| 1261 HValue* typecheck = NULL); | 1263 HValue* typecheck); |
| 1262 HInstruction* BuildLoadStringLength(HValue* object, HValue* typecheck = NULL); | 1264 HInstruction* BuildLoadStringLength(HValue* object, HValue* typecheck); |
| 1263 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); | 1265 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); |
| 1264 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); | 1266 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck); |
| 1265 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); | 1267 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); |
| 1266 | 1268 |
| 1267 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin); | 1269 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin); |
| 1268 | 1270 |
| 1269 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); | 1271 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); |
| 1270 | 1272 |
| 1271 void PushAndAdd(HInstruction* instr); | 1273 void PushAndAdd(HInstruction* instr); |
| 1272 | 1274 |
| 1273 void FinishExitWithHardDeoptimization(HBasicBlock* continuation); | 1275 void FinishExitWithHardDeoptimization(const char* reason, |
| 1276 HBasicBlock* continuation); |
| 1274 | 1277 |
| 1275 void AddIncrementCounter(StatsCounter* counter, | 1278 void AddIncrementCounter(StatsCounter* counter, |
| 1276 HValue* context); | 1279 HValue* context); |
| 1277 | 1280 |
| 1278 class IfBuilder { | 1281 class IfBuilder V8_FINAL { |
| 1279 public: | 1282 public: |
| 1280 explicit IfBuilder(HGraphBuilder* builder, | 1283 explicit IfBuilder(HGraphBuilder* builder, |
| 1281 int position = RelocInfo::kNoPosition); | 1284 int position = RelocInfo::kNoPosition); |
| 1282 IfBuilder(HGraphBuilder* builder, | 1285 IfBuilder(HGraphBuilder* builder, |
| 1283 HIfContinuation* continuation); | 1286 HIfContinuation* continuation); |
| 1284 | 1287 |
| 1285 ~IfBuilder() { | 1288 ~IfBuilder() { |
| 1286 if (!finished_) End(); | 1289 if (!finished_) End(); |
| 1287 } | 1290 } |
| 1288 | 1291 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 | 1370 |
| 1368 void Or(); | 1371 void Or(); |
| 1369 void And(); | 1372 void And(); |
| 1370 | 1373 |
| 1371 void CaptureContinuation(HIfContinuation* continuation); | 1374 void CaptureContinuation(HIfContinuation* continuation); |
| 1372 | 1375 |
| 1373 void Then(); | 1376 void Then(); |
| 1374 void Else(); | 1377 void Else(); |
| 1375 void End(); | 1378 void End(); |
| 1376 | 1379 |
| 1377 void Deopt(); | 1380 void Deopt(const char* reason); |
| 1378 void ElseDeopt() { | 1381 void ElseDeopt(const char* reason) { |
| 1379 Else(); | 1382 Else(); |
| 1380 Deopt(); | 1383 Deopt(reason); |
| 1381 } | 1384 } |
| 1382 | 1385 |
| 1383 void Return(HValue* value); | 1386 void Return(HValue* value); |
| 1384 | 1387 |
| 1385 private: | 1388 private: |
| 1386 void AddCompare(HControlInstruction* compare); | 1389 void AddCompare(HControlInstruction* compare); |
| 1387 | 1390 |
| 1388 Zone* zone() { return builder_->zone(); } | 1391 Zone* zone() { return builder_->zone(); } |
| 1389 | 1392 |
| 1390 HGraphBuilder* builder_; | 1393 HGraphBuilder* builder_; |
| 1391 int position_; | 1394 int position_; |
| 1392 bool finished_ : 1; | 1395 bool finished_ : 1; |
| 1393 bool deopt_then_ : 1; | 1396 bool deopt_then_ : 1; |
| 1394 bool deopt_else_ : 1; | 1397 bool deopt_else_ : 1; |
| 1395 bool did_then_ : 1; | 1398 bool did_then_ : 1; |
| 1396 bool did_else_ : 1; | 1399 bool did_else_ : 1; |
| 1397 bool did_and_ : 1; | 1400 bool did_and_ : 1; |
| 1398 bool did_or_ : 1; | 1401 bool did_or_ : 1; |
| 1399 bool captured_ : 1; | 1402 bool captured_ : 1; |
| 1400 bool needs_compare_ : 1; | 1403 bool needs_compare_ : 1; |
| 1401 HBasicBlock* first_true_block_; | 1404 HBasicBlock* first_true_block_; |
| 1402 HBasicBlock* last_true_block_; | 1405 HBasicBlock* last_true_block_; |
| 1403 HBasicBlock* first_false_block_; | 1406 HBasicBlock* first_false_block_; |
| 1404 HBasicBlock* split_edge_merge_block_; | 1407 HBasicBlock* split_edge_merge_block_; |
| 1405 HBasicBlock* merge_block_; | 1408 HBasicBlock* merge_block_; |
| 1406 }; | 1409 }; |
| 1407 | 1410 |
| 1408 class LoopBuilder { | 1411 class LoopBuilder V8_FINAL { |
| 1409 public: | 1412 public: |
| 1410 enum Direction { | 1413 enum Direction { |
| 1411 kPreIncrement, | 1414 kPreIncrement, |
| 1412 kPostIncrement, | 1415 kPostIncrement, |
| 1413 kPreDecrement, | 1416 kPreDecrement, |
| 1414 kPostDecrement | 1417 kPostDecrement |
| 1415 }; | 1418 }; |
| 1416 | 1419 |
| 1417 LoopBuilder(HGraphBuilder* builder, | 1420 LoopBuilder(HGraphBuilder* builder, |
| 1418 HValue* context, | 1421 HValue* context, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1434 HValue* context_; | 1437 HValue* context_; |
| 1435 HInstruction* increment_; | 1438 HInstruction* increment_; |
| 1436 HPhi* phi_; | 1439 HPhi* phi_; |
| 1437 HBasicBlock* header_block_; | 1440 HBasicBlock* header_block_; |
| 1438 HBasicBlock* body_block_; | 1441 HBasicBlock* body_block_; |
| 1439 HBasicBlock* exit_block_; | 1442 HBasicBlock* exit_block_; |
| 1440 Direction direction_; | 1443 Direction direction_; |
| 1441 bool finished_; | 1444 bool finished_; |
| 1442 }; | 1445 }; |
| 1443 | 1446 |
| 1444 class NoObservableSideEffectsScope { | |
| 1445 public: | |
| 1446 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : | |
| 1447 builder_(builder) { | |
| 1448 builder_->IncrementInNoSideEffectsScope(); | |
| 1449 } | |
| 1450 ~NoObservableSideEffectsScope() { | |
| 1451 builder_->DecrementInNoSideEffectsScope(); | |
| 1452 } | |
| 1453 | |
| 1454 private: | |
| 1455 HGraphBuilder* builder_; | |
| 1456 }; | |
| 1457 | |
| 1458 HValue* BuildNewElementsCapacity(HValue* old_capacity); | 1447 HValue* BuildNewElementsCapacity(HValue* old_capacity); |
| 1459 | 1448 |
| 1460 void BuildNewSpaceArrayCheck(HValue* length, | 1449 void BuildNewSpaceArrayCheck(HValue* length, |
| 1461 ElementsKind kind); | 1450 ElementsKind kind); |
| 1462 | 1451 |
| 1463 class JSArrayBuilder { | 1452 class JSArrayBuilder V8_FINAL { |
| 1464 public: | 1453 public: |
| 1465 JSArrayBuilder(HGraphBuilder* builder, | 1454 JSArrayBuilder(HGraphBuilder* builder, |
| 1466 ElementsKind kind, | 1455 ElementsKind kind, |
| 1467 HValue* allocation_site_payload, | 1456 HValue* allocation_site_payload, |
| 1468 HValue* constructor_function, | 1457 HValue* constructor_function, |
| 1469 AllocationSiteOverrideMode override_mode); | 1458 AllocationSiteOverrideMode override_mode); |
| 1470 | 1459 |
| 1471 JSArrayBuilder(HGraphBuilder* builder, | 1460 JSArrayBuilder(HGraphBuilder* builder, |
| 1472 ElementsKind kind, | 1461 ElementsKind kind, |
| 1473 HValue* constructor_function); | 1462 HValue* constructor_function); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 | 1558 |
| 1570 private: | 1559 private: |
| 1571 HGraphBuilder(); | 1560 HGraphBuilder(); |
| 1572 | 1561 |
| 1573 void PadEnvironmentForContinuation(HBasicBlock* from, | 1562 void PadEnvironmentForContinuation(HBasicBlock* from, |
| 1574 HBasicBlock* continuation); | 1563 HBasicBlock* continuation); |
| 1575 | 1564 |
| 1576 CompilationInfo* info_; | 1565 CompilationInfo* info_; |
| 1577 HGraph* graph_; | 1566 HGraph* graph_; |
| 1578 HBasicBlock* current_block_; | 1567 HBasicBlock* current_block_; |
| 1579 int no_side_effects_scope_count_; | |
| 1580 }; | 1568 }; |
| 1581 | 1569 |
| 1582 | 1570 |
| 1583 template<> | 1571 template<> |
| 1584 inline HInstruction* HGraphBuilder::AddUncasted<HDeoptimize>( | 1572 inline HInstruction* HGraphBuilder::AddUncasted<HDeoptimize>( |
| 1585 Deoptimizer::BailoutType type) { | 1573 const char* reason, Deoptimizer::BailoutType type) { |
| 1586 if (type == Deoptimizer::SOFT) { | 1574 if (type == Deoptimizer::SOFT) { |
| 1587 isolate()->counters()->soft_deopts_requested()->Increment(); | 1575 isolate()->counters()->soft_deopts_requested()->Increment(); |
| 1588 if (FLAG_always_opt) return NULL; | 1576 if (FLAG_always_opt) return NULL; |
| 1589 } | 1577 } |
| 1590 if (current_block()->IsDeoptimizing()) return NULL; | 1578 if (current_block()->IsDeoptimizing()) return NULL; |
| 1591 HDeoptimize* instr = New<HDeoptimize>(type); | 1579 HDeoptimize* instr = New<HDeoptimize>(reason, type); |
| 1592 AddInstruction(instr); | 1580 AddInstruction(instr); |
| 1593 if (type == Deoptimizer::SOFT) { | 1581 if (type == Deoptimizer::SOFT) { |
| 1594 isolate()->counters()->soft_deopts_inserted()->Increment(); | 1582 isolate()->counters()->soft_deopts_inserted()->Increment(); |
| 1595 graph()->set_has_soft_deoptimize(true); | 1583 graph()->set_has_soft_deoptimize(true); |
| 1596 } | 1584 } |
| 1597 current_block()->MarkAsDeoptimizing(); | 1585 current_block()->MarkAsDeoptimizing(); |
| 1598 return instr; | 1586 return instr; |
| 1599 } | 1587 } |
| 1600 | 1588 |
| 1601 | 1589 |
| 1602 template<> | 1590 template<> |
| 1603 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( | 1591 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( |
| 1604 Deoptimizer::BailoutType type) { | 1592 const char* reason, Deoptimizer::BailoutType type) { |
| 1605 return static_cast<HDeoptimize*>(AddUncasted<HDeoptimize>(type)); | 1593 return static_cast<HDeoptimize*>(AddUncasted<HDeoptimize>(reason, type)); |
| 1606 } | 1594 } |
| 1607 | 1595 |
| 1608 | 1596 |
| 1609 template<> | 1597 template<> |
| 1610 inline HInstruction* HGraphBuilder::AddUncasted<HSimulate>( | 1598 inline HInstruction* HGraphBuilder::AddUncasted<HSimulate>( |
| 1611 BailoutId id, | 1599 BailoutId id, |
| 1612 RemovableSimulate removable) { | 1600 RemovableSimulate removable) { |
| 1613 HSimulate* instr = current_block()->CreateSimulate(id, removable); | 1601 HSimulate* instr = current_block()->CreateSimulate(id, removable); |
| 1614 AddInstruction(instr); | 1602 AddInstruction(instr); |
| 1615 return instr; | 1603 return instr; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 return AddUncasted<HReturn>(static_cast<HValue*>(value)); | 1641 return AddUncasted<HReturn>(static_cast<HValue*>(value)); |
| 1654 } | 1642 } |
| 1655 | 1643 |
| 1656 | 1644 |
| 1657 template<> | 1645 template<> |
| 1658 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() { | 1646 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() { |
| 1659 return HContext::New(zone()); | 1647 return HContext::New(zone()); |
| 1660 } | 1648 } |
| 1661 | 1649 |
| 1662 | 1650 |
| 1663 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1651 class HOptimizedGraphBuilder V8_FINAL |
| 1652 : public HGraphBuilder, public AstVisitor { |
| 1664 public: | 1653 public: |
| 1665 // A class encapsulating (lazily-allocated) break and continue blocks for | 1654 // A class encapsulating (lazily-allocated) break and continue blocks for |
| 1666 // a breakable statement. Separated from BreakAndContinueScope so that it | 1655 // a breakable statement. Separated from BreakAndContinueScope so that it |
| 1667 // can have a separate lifetime. | 1656 // can have a separate lifetime. |
| 1668 class BreakAndContinueInfo BASE_EMBEDDED { | 1657 class BreakAndContinueInfo V8_FINAL BASE_EMBEDDED { |
| 1669 public: | 1658 public: |
| 1670 explicit BreakAndContinueInfo(BreakableStatement* target, | 1659 explicit BreakAndContinueInfo(BreakableStatement* target, |
| 1671 int drop_extra = 0) | 1660 int drop_extra = 0) |
| 1672 : target_(target), | 1661 : target_(target), |
| 1673 break_block_(NULL), | 1662 break_block_(NULL), |
| 1674 continue_block_(NULL), | 1663 continue_block_(NULL), |
| 1675 drop_extra_(drop_extra) { | 1664 drop_extra_(drop_extra) { |
| 1676 } | 1665 } |
| 1677 | 1666 |
| 1678 BreakableStatement* target() { return target_; } | 1667 BreakableStatement* target() { return target_; } |
| 1679 HBasicBlock* break_block() { return break_block_; } | 1668 HBasicBlock* break_block() { return break_block_; } |
| 1680 void set_break_block(HBasicBlock* block) { break_block_ = block; } | 1669 void set_break_block(HBasicBlock* block) { break_block_ = block; } |
| 1681 HBasicBlock* continue_block() { return continue_block_; } | 1670 HBasicBlock* continue_block() { return continue_block_; } |
| 1682 void set_continue_block(HBasicBlock* block) { continue_block_ = block; } | 1671 void set_continue_block(HBasicBlock* block) { continue_block_ = block; } |
| 1683 int drop_extra() { return drop_extra_; } | 1672 int drop_extra() { return drop_extra_; } |
| 1684 | 1673 |
| 1685 private: | 1674 private: |
| 1686 BreakableStatement* target_; | 1675 BreakableStatement* target_; |
| 1687 HBasicBlock* break_block_; | 1676 HBasicBlock* break_block_; |
| 1688 HBasicBlock* continue_block_; | 1677 HBasicBlock* continue_block_; |
| 1689 int drop_extra_; | 1678 int drop_extra_; |
| 1690 }; | 1679 }; |
| 1691 | 1680 |
| 1692 // A helper class to maintain a stack of current BreakAndContinueInfo | 1681 // A helper class to maintain a stack of current BreakAndContinueInfo |
| 1693 // structures mirroring BreakableStatement nesting. | 1682 // structures mirroring BreakableStatement nesting. |
| 1694 class BreakAndContinueScope BASE_EMBEDDED { | 1683 class BreakAndContinueScope V8_FINAL BASE_EMBEDDED { |
| 1695 public: | 1684 public: |
| 1696 BreakAndContinueScope(BreakAndContinueInfo* info, | 1685 BreakAndContinueScope(BreakAndContinueInfo* info, |
| 1697 HOptimizedGraphBuilder* owner) | 1686 HOptimizedGraphBuilder* owner) |
| 1698 : info_(info), owner_(owner), next_(owner->break_scope()) { | 1687 : info_(info), owner_(owner), next_(owner->break_scope()) { |
| 1699 owner->set_break_scope(this); | 1688 owner->set_break_scope(this); |
| 1700 } | 1689 } |
| 1701 | 1690 |
| 1702 ~BreakAndContinueScope() { owner_->set_break_scope(next_); } | 1691 ~BreakAndContinueScope() { owner_->set_break_scope(next_); } |
| 1703 | 1692 |
| 1704 BreakAndContinueInfo* info() { return info_; } | 1693 BreakAndContinueInfo* info() { return info_; } |
| 1705 HOptimizedGraphBuilder* owner() { return owner_; } | 1694 HOptimizedGraphBuilder* owner() { return owner_; } |
| 1706 BreakAndContinueScope* next() { return next_; } | 1695 BreakAndContinueScope* next() { return next_; } |
| 1707 | 1696 |
| 1708 // Search the break stack for a break or continue target. | 1697 // Search the break stack for a break or continue target. |
| 1709 enum BreakType { BREAK, CONTINUE }; | 1698 enum BreakType { BREAK, CONTINUE }; |
| 1710 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra); | 1699 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra); |
| 1711 | 1700 |
| 1712 private: | 1701 private: |
| 1713 BreakAndContinueInfo* info_; | 1702 BreakAndContinueInfo* info_; |
| 1714 HOptimizedGraphBuilder* owner_; | 1703 HOptimizedGraphBuilder* owner_; |
| 1715 BreakAndContinueScope* next_; | 1704 BreakAndContinueScope* next_; |
| 1716 }; | 1705 }; |
| 1717 | 1706 |
| 1718 explicit HOptimizedGraphBuilder(CompilationInfo* info); | 1707 explicit HOptimizedGraphBuilder(CompilationInfo* info); |
| 1719 | 1708 |
| 1720 virtual bool BuildGraph(); | 1709 virtual bool BuildGraph() V8_OVERRIDE; |
| 1721 | 1710 |
| 1722 // Simple accessors. | 1711 // Simple accessors. |
| 1723 BreakAndContinueScope* break_scope() const { return break_scope_; } | 1712 BreakAndContinueScope* break_scope() const { return break_scope_; } |
| 1724 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } | 1713 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } |
| 1725 | 1714 |
| 1726 bool inline_bailout() { return inline_bailout_; } | 1715 bool inline_bailout() { return inline_bailout_; } |
| 1727 | 1716 |
| 1728 HValue* context() { return environment()->context(); } | 1717 HValue* context() { return environment()->context(); } |
| 1729 | 1718 |
| 1730 void Bailout(BailoutReason reason); | 1719 void Bailout(BailoutReason reason); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1896 void VisitArgumentList(ZoneList<Expression*>* arguments); | 1885 void VisitArgumentList(ZoneList<Expression*>* arguments); |
| 1897 | 1886 |
| 1898 // Visit a list of expressions from left to right, each in a value context. | 1887 // Visit a list of expressions from left to right, each in a value context. |
| 1899 void VisitExpressions(ZoneList<Expression*>* exprs); | 1888 void VisitExpressions(ZoneList<Expression*>* exprs); |
| 1900 | 1889 |
| 1901 // Remove the arguments from the bailout environment and emit instructions | 1890 // Remove the arguments from the bailout environment and emit instructions |
| 1902 // to push them as outgoing parameters. | 1891 // to push them as outgoing parameters. |
| 1903 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); | 1892 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); |
| 1904 | 1893 |
| 1905 void SetUpScope(Scope* scope); | 1894 void SetUpScope(Scope* scope); |
| 1906 virtual void VisitStatements(ZoneList<Statement*>* statements); | 1895 virtual void VisitStatements(ZoneList<Statement*>* statements) V8_OVERRIDE; |
| 1907 | 1896 |
| 1908 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 1897 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) V8_OVERRIDE; |
| 1909 AST_NODE_LIST(DECLARE_VISIT) | 1898 AST_NODE_LIST(DECLARE_VISIT) |
| 1910 #undef DECLARE_VISIT | 1899 #undef DECLARE_VISIT |
| 1911 | 1900 |
| 1912 // Helpers for flow graph construction. | 1901 // Helpers for flow graph construction. |
| 1913 enum GlobalPropertyAccess { | 1902 enum GlobalPropertyAccess { |
| 1914 kUseCell, | 1903 kUseCell, |
| 1915 kUseGeneric | 1904 kUseGeneric |
| 1916 }; | 1905 }; |
| 1917 GlobalPropertyAccess LookupGlobalProperty(Variable* var, | 1906 GlobalPropertyAccess LookupGlobalProperty(Variable* var, |
| 1918 LookupResult* lookup, | 1907 LookupResult* lookup, |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2047 Property* expr); | 2036 Property* expr); |
| 2048 HInstruction* BuildCallGetter(HValue* object, | 2037 HInstruction* BuildCallGetter(HValue* object, |
| 2049 Handle<Map> map, | 2038 Handle<Map> map, |
| 2050 Handle<JSFunction> getter, | 2039 Handle<JSFunction> getter, |
| 2051 Handle<JSObject> holder); | 2040 Handle<JSObject> holder); |
| 2052 HInstruction* BuildLoadNamedMonomorphic(HValue* object, | 2041 HInstruction* BuildLoadNamedMonomorphic(HValue* object, |
| 2053 Handle<String> name, | 2042 Handle<String> name, |
| 2054 Property* expr, | 2043 Property* expr, |
| 2055 Handle<Map> map); | 2044 Handle<Map> map); |
| 2056 | 2045 |
| 2057 void AddCheckMap(HValue* object, Handle<Map> map); | 2046 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); |
| 2058 | 2047 |
| 2059 void BuildStoreNamed(Expression* expression, | 2048 void BuildStoreNamed(Expression* expression, |
| 2060 BailoutId id, | 2049 BailoutId id, |
| 2061 int position, | 2050 int position, |
| 2062 BailoutId assignment_id, | 2051 BailoutId assignment_id, |
| 2063 Property* prop, | 2052 Property* prop, |
| 2064 HValue* object, | 2053 HValue* object, |
| 2065 HValue* store_value, | 2054 HValue* store_value, |
| 2066 HValue* result_value); | 2055 HValue* result_value); |
| 2067 | 2056 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2177 friend class KeyedLoadFastElementStub; | 2166 friend class KeyedLoadFastElementStub; |
| 2178 friend class HOsrBuilder; | 2167 friend class HOsrBuilder; |
| 2179 | 2168 |
| 2180 DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder); | 2169 DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder); |
| 2181 }; | 2170 }; |
| 2182 | 2171 |
| 2183 | 2172 |
| 2184 Zone* AstContext::zone() const { return owner_->zone(); } | 2173 Zone* AstContext::zone() const { return owner_->zone(); } |
| 2185 | 2174 |
| 2186 | 2175 |
| 2187 class HStatistics: public Malloced { | 2176 class HStatistics V8_FINAL: public Malloced { |
| 2188 public: | 2177 public: |
| 2189 HStatistics() | 2178 HStatistics() |
| 2190 : timing_(5), | 2179 : timing_(5), |
| 2191 names_(5), | 2180 names_(5), |
| 2192 sizes_(5), | 2181 sizes_(5), |
| 2193 create_graph_(0), | 2182 create_graph_(0), |
| 2194 optimize_graph_(0), | 2183 optimize_graph_(0), |
| 2195 generate_code_(0), | 2184 generate_code_(0), |
| 2196 total_size_(0), | 2185 total_size_(0), |
| 2197 full_code_gen_(0), | 2186 full_code_gen_(0), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2236 protected: | 2225 protected: |
| 2237 HGraph* graph() const { return graph_; } | 2226 HGraph* graph() const { return graph_; } |
| 2238 | 2227 |
| 2239 private: | 2228 private: |
| 2240 HGraph* graph_; | 2229 HGraph* graph_; |
| 2241 | 2230 |
| 2242 DISALLOW_COPY_AND_ASSIGN(HPhase); | 2231 DISALLOW_COPY_AND_ASSIGN(HPhase); |
| 2243 }; | 2232 }; |
| 2244 | 2233 |
| 2245 | 2234 |
| 2246 class HTracer: public Malloced { | 2235 class HTracer V8_FINAL : public Malloced { |
| 2247 public: | 2236 public: |
| 2248 explicit HTracer(int isolate_id) | 2237 explicit HTracer(int isolate_id) |
| 2249 : trace_(&string_allocator_), indent_(0) { | 2238 : trace_(&string_allocator_), indent_(0) { |
| 2250 if (FLAG_trace_hydrogen_file == NULL) { | 2239 if (FLAG_trace_hydrogen_file == NULL) { |
| 2251 OS::SNPrintF(filename_, | 2240 OS::SNPrintF(filename_, |
| 2252 "hydrogen-%d-%d.cfg", | 2241 "hydrogen-%d-%d.cfg", |
| 2253 OS::GetCurrentProcessId(), | 2242 OS::GetCurrentProcessId(), |
| 2254 isolate_id); | 2243 isolate_id); |
| 2255 } else { | 2244 } else { |
| 2256 OS::StrNCpy(filename_, FLAG_trace_hydrogen_file, filename_.length()); | 2245 OS::StrNCpy(filename_, FLAG_trace_hydrogen_file, filename_.length()); |
| 2257 } | 2246 } |
| 2258 WriteChars(filename_.start(), "", 0, false); | 2247 WriteChars(filename_.start(), "", 0, false); |
| 2259 } | 2248 } |
| 2260 | 2249 |
| 2261 void TraceCompilation(CompilationInfo* info); | 2250 void TraceCompilation(CompilationInfo* info); |
| 2262 void TraceHydrogen(const char* name, HGraph* graph); | 2251 void TraceHydrogen(const char* name, HGraph* graph); |
| 2263 void TraceLithium(const char* name, LChunk* chunk); | 2252 void TraceLithium(const char* name, LChunk* chunk); |
| 2264 void TraceLiveRanges(const char* name, LAllocator* allocator); | 2253 void TraceLiveRanges(const char* name, LAllocator* allocator); |
| 2265 | 2254 |
| 2266 private: | 2255 private: |
| 2267 class Tag BASE_EMBEDDED { | 2256 class Tag V8_FINAL BASE_EMBEDDED { |
| 2268 public: | 2257 public: |
| 2269 Tag(HTracer* tracer, const char* name) { | 2258 Tag(HTracer* tracer, const char* name) { |
| 2270 name_ = name; | 2259 name_ = name; |
| 2271 tracer_ = tracer; | 2260 tracer_ = tracer; |
| 2272 tracer->PrintIndent(); | 2261 tracer->PrintIndent(); |
| 2273 tracer->trace_.Add("begin_%s\n", name); | 2262 tracer->trace_.Add("begin_%s\n", name); |
| 2274 tracer->indent_++; | 2263 tracer->indent_++; |
| 2275 } | 2264 } |
| 2276 | 2265 |
| 2277 ~Tag() { | 2266 ~Tag() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2322 } | 2311 } |
| 2323 } | 2312 } |
| 2324 | 2313 |
| 2325 EmbeddedVector<char, 64> filename_; | 2314 EmbeddedVector<char, 64> filename_; |
| 2326 HeapStringAllocator string_allocator_; | 2315 HeapStringAllocator string_allocator_; |
| 2327 StringStream trace_; | 2316 StringStream trace_; |
| 2328 int indent_; | 2317 int indent_; |
| 2329 }; | 2318 }; |
| 2330 | 2319 |
| 2331 | 2320 |
| 2321 class NoObservableSideEffectsScope V8_FINAL { |
| 2322 public: |
| 2323 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : |
| 2324 builder_(builder) { |
| 2325 builder_->graph()->IncrementInNoSideEffectsScope(); |
| 2326 } |
| 2327 ~NoObservableSideEffectsScope() { |
| 2328 builder_->graph()->DecrementInNoSideEffectsScope(); |
| 2329 } |
| 2330 |
| 2331 private: |
| 2332 HGraphBuilder* builder_; |
| 2333 }; |
| 2334 |
| 2335 |
| 2332 } } // namespace v8::internal | 2336 } } // namespace v8::internal |
| 2333 | 2337 |
| 2334 #endif // V8_HYDROGEN_H_ | 2338 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |