| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 // If a target block is tagged as an inline function return, all | 130 // If a target block is tagged as an inline function return, all |
| 131 // predecessors should contain the inlined exit sequence: | 131 // predecessors should contain the inlined exit sequence: |
| 132 // | 132 // |
| 133 // LeaveInlined | 133 // LeaveInlined |
| 134 // Simulate (caller's environment) | 134 // Simulate (caller's environment) |
| 135 // Goto (target block) | 135 // Goto (target block) |
| 136 bool IsInlineReturnTarget() const { return is_inline_return_target_; } | 136 bool IsInlineReturnTarget() const { return is_inline_return_target_; } |
| 137 void MarkAsInlineReturnTarget() { is_inline_return_target_ = true; } | 137 void MarkAsInlineReturnTarget() { is_inline_return_target_ = true; } |
| 138 | 138 |
| 139 // If this block is a successor of a branch, his flags tells whether the | |
| 140 // preceding branch was inverted or not. | |
| 141 bool inverted() { return inverted_; } | |
| 142 void set_inverted(bool b) { inverted_ = b; } | |
| 143 | |
| 144 HBasicBlock* deopt_predecessor() { return deopt_predecessor_; } | |
| 145 void set_deopt_predecessor(HBasicBlock* block) { deopt_predecessor_ = block; } | |
| 146 | |
| 147 Handle<Object> cond() { return cond_; } | 139 Handle<Object> cond() { return cond_; } |
| 148 void set_cond(Handle<Object> value) { cond_ = value; } | 140 void set_cond(Handle<Object> value) { cond_ = value; } |
| 149 | 141 |
| 150 #ifdef DEBUG | 142 #ifdef DEBUG |
| 151 void Verify(); | 143 void Verify(); |
| 152 #endif | 144 #endif |
| 153 | 145 |
| 154 private: | 146 private: |
| 155 void RegisterPredecessor(HBasicBlock* pred); | 147 void RegisterPredecessor(HBasicBlock* pred); |
| 156 void AddDominatedBlock(HBasicBlock* block); | 148 void AddDominatedBlock(HBasicBlock* block); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 169 ZoneList<HBasicBlock*> dominated_blocks_; | 161 ZoneList<HBasicBlock*> dominated_blocks_; |
| 170 HEnvironment* last_environment_; | 162 HEnvironment* last_environment_; |
| 171 // Outgoing parameter count at block exit, set during lithium translation. | 163 // Outgoing parameter count at block exit, set during lithium translation. |
| 172 int argument_count_; | 164 int argument_count_; |
| 173 // Instruction indices into the lithium code stream. | 165 // Instruction indices into the lithium code stream. |
| 174 int first_instruction_index_; | 166 int first_instruction_index_; |
| 175 int last_instruction_index_; | 167 int last_instruction_index_; |
| 176 ZoneList<int> deleted_phis_; | 168 ZoneList<int> deleted_phis_; |
| 177 SetOncePointer<HBasicBlock> parent_loop_header_; | 169 SetOncePointer<HBasicBlock> parent_loop_header_; |
| 178 bool is_inline_return_target_; | 170 bool is_inline_return_target_; |
| 179 bool inverted_; | |
| 180 HBasicBlock* deopt_predecessor_; | |
| 181 Handle<Object> cond_; | 171 Handle<Object> cond_; |
| 182 }; | 172 }; |
| 183 | 173 |
| 184 | 174 |
| 185 class HLoopInformation: public ZoneObject { | 175 class HLoopInformation: public ZoneObject { |
| 186 public: | 176 public: |
| 187 explicit HLoopInformation(HBasicBlock* loop_header) | 177 explicit HLoopInformation(HBasicBlock* loop_header) |
| 188 : back_edges_(4), loop_header_(loop_header), blocks_(8) { | 178 : back_edges_(4), loop_header_(loop_header), blocks_(8) { |
| 189 blocks_.Add(loop_header); | 179 blocks_.Add(loop_header); |
| 190 } | 180 } |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 | 598 |
| 609 virtual void ReturnValue(HValue* value); | 599 virtual void ReturnValue(HValue* value); |
| 610 virtual void ReturnInstruction(HInstruction* instr, int ast_id); | 600 virtual void ReturnInstruction(HInstruction* instr, int ast_id); |
| 611 }; | 601 }; |
| 612 | 602 |
| 613 | 603 |
| 614 class TestContext: public AstContext { | 604 class TestContext: public AstContext { |
| 615 public: | 605 public: |
| 616 TestContext(HGraphBuilder* owner, | 606 TestContext(HGraphBuilder* owner, |
| 617 HBasicBlock* if_true, | 607 HBasicBlock* if_true, |
| 618 HBasicBlock* if_false, | 608 HBasicBlock* if_false) |
| 619 bool invert_true, | |
| 620 bool invert_false) | |
| 621 : AstContext(owner, Expression::kTest), | 609 : AstContext(owner, Expression::kTest), |
| 622 if_true_(if_true), | 610 if_true_(if_true), |
| 623 if_false_(if_false), | 611 if_false_(if_false) { |
| 624 invert_true_(invert_true), | |
| 625 invert_false_(invert_false) { | |
| 626 } | 612 } |
| 627 | 613 |
| 628 virtual void ReturnValue(HValue* value); | 614 virtual void ReturnValue(HValue* value); |
| 629 virtual void ReturnInstruction(HInstruction* instr, int ast_id); | 615 virtual void ReturnInstruction(HInstruction* instr, int ast_id); |
| 630 | 616 |
| 631 static TestContext* cast(AstContext* context) { | 617 static TestContext* cast(AstContext* context) { |
| 632 ASSERT(context->IsTest()); | 618 ASSERT(context->IsTest()); |
| 633 return reinterpret_cast<TestContext*>(context); | 619 return reinterpret_cast<TestContext*>(context); |
| 634 } | 620 } |
| 635 | 621 |
| 636 HBasicBlock* if_true() const { return if_true_; } | 622 HBasicBlock* if_true() const { return if_true_; } |
| 637 HBasicBlock* if_false() const { return if_false_; } | 623 HBasicBlock* if_false() const { return if_false_; } |
| 638 | 624 |
| 639 bool invert_true() { return invert_true_; } | |
| 640 bool invert_false() { return invert_false_; } | |
| 641 | |
| 642 private: | 625 private: |
| 643 // Build the shared core part of the translation unpacking a value into | 626 // Build the shared core part of the translation unpacking a value into |
| 644 // control flow. | 627 // control flow. |
| 645 void BuildBranch(HValue* value); | 628 void BuildBranch(HValue* value); |
| 646 | 629 |
| 647 HBasicBlock* if_true_; | 630 HBasicBlock* if_true_; |
| 648 HBasicBlock* if_false_; | 631 HBasicBlock* if_false_; |
| 649 bool invert_true_; | |
| 650 bool invert_false_; | |
| 651 }; | 632 }; |
| 652 | 633 |
| 653 | 634 |
| 654 class HGraphBuilder: public AstVisitor { | 635 class HGraphBuilder: public AstVisitor { |
| 655 public: | 636 public: |
| 656 explicit HGraphBuilder(TypeFeedbackOracle* oracle) | 637 explicit HGraphBuilder(TypeFeedbackOracle* oracle) |
| 657 : oracle_(oracle), | 638 : oracle_(oracle), |
| 658 graph_(NULL), | 639 graph_(NULL), |
| 659 current_subgraph_(NULL), | 640 current_subgraph_(NULL), |
| 660 peeled_statement_(NULL), | 641 peeled_statement_(NULL), |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 void Bailout(const char* reason); | 697 void Bailout(const char* reason); |
| 717 | 698 |
| 718 void AppendPeeledWhile(IterationStatement* stmt, | 699 void AppendPeeledWhile(IterationStatement* stmt, |
| 719 HSubgraph* cond_graph, | 700 HSubgraph* cond_graph, |
| 720 HSubgraph* body_graph, | 701 HSubgraph* body_graph, |
| 721 HSubgraph* exit_graph); | 702 HSubgraph* exit_graph); |
| 722 | 703 |
| 723 void AddToSubgraph(HSubgraph* graph, ZoneList<Statement*>* stmts); | 704 void AddToSubgraph(HSubgraph* graph, ZoneList<Statement*>* stmts); |
| 724 void AddToSubgraph(HSubgraph* graph, Statement* stmt); | 705 void AddToSubgraph(HSubgraph* graph, Statement* stmt); |
| 725 void AddToSubgraph(HSubgraph* graph, Expression* expr); | 706 void AddToSubgraph(HSubgraph* graph, Expression* expr); |
| 726 void AddConditionToSubgraph(HSubgraph* subgraph, | |
| 727 Expression* expr, | |
| 728 HSubgraph* true_graph, | |
| 729 HSubgraph* false_graph); | |
| 730 | 707 |
| 731 HValue* Top() const { return environment()->Top(); } | 708 HValue* Top() const { return environment()->Top(); } |
| 732 void Drop(int n) { environment()->Drop(n); } | 709 void Drop(int n) { environment()->Drop(n); } |
| 733 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); } | 710 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); } |
| 734 | 711 |
| 735 void VisitForValue(Expression* expr); | 712 void VisitForValue(Expression* expr); |
| 736 void VisitForEffect(Expression* expr); | 713 void VisitForEffect(Expression* expr); |
| 737 void VisitForControl(Expression* expr, | 714 void VisitForControl(Expression* expr, |
| 738 HBasicBlock* true_block, | 715 HBasicBlock* true_block, |
| 739 HBasicBlock* false_block, | 716 HBasicBlock* false_block); |
| 740 bool invert_true, | |
| 741 bool invert_false); | |
| 742 | 717 |
| 743 // Visit an expression in a 'condition' context, i.e., in a control | |
| 744 // context but not a subexpression of logical and, or, or not. | |
| 745 void VisitCondition(Expression* expr, | |
| 746 HBasicBlock* true_graph, | |
| 747 HBasicBlock* false_graph, | |
| 748 bool invert_true, | |
| 749 bool invert_false); | |
| 750 // Visit an argument and wrap it in a PushArgument instruction. | 718 // Visit an argument and wrap it in a PushArgument instruction. |
| 751 HValue* VisitArgument(Expression* expr); | 719 HValue* VisitArgument(Expression* expr); |
| 752 void VisitArgumentList(ZoneList<Expression*>* arguments); | 720 void VisitArgumentList(ZoneList<Expression*>* arguments); |
| 753 | 721 |
| 754 void AddPhi(HPhi* phi); | 722 void AddPhi(HPhi* phi); |
| 755 | 723 |
| 756 void PushAndAdd(HInstruction* instr); | 724 void PushAndAdd(HInstruction* instr); |
| 757 | 725 |
| 758 void PushArgumentsForStubCall(int argument_count); | 726 void PushArgumentsForStubCall(int argument_count); |
| 759 | 727 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 const char* filename_; | 1061 const char* filename_; |
| 1094 HeapStringAllocator string_allocator_; | 1062 HeapStringAllocator string_allocator_; |
| 1095 StringStream trace_; | 1063 StringStream trace_; |
| 1096 int indent_; | 1064 int indent_; |
| 1097 }; | 1065 }; |
| 1098 | 1066 |
| 1099 | 1067 |
| 1100 } } // namespace v8::internal | 1068 } } // namespace v8::internal |
| 1101 | 1069 |
| 1102 #endif // V8_HYDROGEN_H_ | 1070 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |