OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 // have already been inserted in the instruction stream (or not need to | 491 // have already been inserted in the instruction stream (or not need to |
492 // be, e.g., HPhi). Call this function in tail position in the Visit | 492 // be, e.g., HPhi). Call this function in tail position in the Visit |
493 // functions for expressions. | 493 // functions for expressions. |
494 virtual void ReturnValue(HValue* value) = 0; | 494 virtual void ReturnValue(HValue* value) = 0; |
495 | 495 |
496 // Add a hydrogen instruction to the instruction stream (recording an | 496 // Add a hydrogen instruction to the instruction stream (recording an |
497 // environment simulation if necessary) and then fill this context with | 497 // environment simulation if necessary) and then fill this context with |
498 // the instruction as value. | 498 // the instruction as value. |
499 virtual void ReturnInstruction(HInstruction* instr, int ast_id) = 0; | 499 virtual void ReturnInstruction(HInstruction* instr, int ast_id) = 0; |
500 | 500 |
501 virtual void ReturnControl(HControlInstruction* instr, int ast_id) = 0; | |
Kevin Millikin (Chromium)
2011/06/30 13:31:05
Needs a comment in similar detail to ReturnValue a
| |
502 | |
501 void set_for_typeof(bool for_typeof) { for_typeof_ = for_typeof; } | 503 void set_for_typeof(bool for_typeof) { for_typeof_ = for_typeof; } |
502 bool is_for_typeof() { return for_typeof_; } | 504 bool is_for_typeof() { return for_typeof_; } |
503 | 505 |
504 protected: | 506 protected: |
505 AstContext(HGraphBuilder* owner, Expression::Context kind); | 507 AstContext(HGraphBuilder* owner, Expression::Context kind); |
506 virtual ~AstContext(); | 508 virtual ~AstContext(); |
507 | 509 |
508 HGraphBuilder* owner() const { return owner_; } | 510 HGraphBuilder* owner() const { return owner_; } |
509 | 511 |
510 inline Zone* zone(); | 512 inline Zone* zone(); |
(...skipping 14 matching lines...) Expand all Loading... | |
525 | 527 |
526 class EffectContext: public AstContext { | 528 class EffectContext: public AstContext { |
527 public: | 529 public: |
528 explicit EffectContext(HGraphBuilder* owner) | 530 explicit EffectContext(HGraphBuilder* owner) |
529 : AstContext(owner, Expression::kEffect) { | 531 : AstContext(owner, Expression::kEffect) { |
530 } | 532 } |
531 virtual ~EffectContext(); | 533 virtual ~EffectContext(); |
532 | 534 |
533 virtual void ReturnValue(HValue* value); | 535 virtual void ReturnValue(HValue* value); |
534 virtual void ReturnInstruction(HInstruction* instr, int ast_id); | 536 virtual void ReturnInstruction(HInstruction* instr, int ast_id); |
537 virtual void ReturnControl(HControlInstruction* instr, int ast_id); | |
535 }; | 538 }; |
536 | 539 |
537 | 540 |
538 class ValueContext: public AstContext { | 541 class ValueContext: public AstContext { |
539 public: | 542 public: |
540 explicit ValueContext(HGraphBuilder* owner, ArgumentsAllowedFlag flag) | 543 explicit ValueContext(HGraphBuilder* owner, ArgumentsAllowedFlag flag) |
541 : AstContext(owner, Expression::kValue), flag_(flag) { | 544 : AstContext(owner, Expression::kValue), flag_(flag) { |
542 } | 545 } |
543 virtual ~ValueContext(); | 546 virtual ~ValueContext(); |
544 | 547 |
545 virtual void ReturnValue(HValue* value); | 548 virtual void ReturnValue(HValue* value); |
546 virtual void ReturnInstruction(HInstruction* instr, int ast_id); | 549 virtual void ReturnInstruction(HInstruction* instr, int ast_id); |
550 virtual void ReturnControl(HControlInstruction* instr, int ast_id); | |
547 | 551 |
548 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } | 552 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } |
549 | 553 |
550 private: | 554 private: |
551 ArgumentsAllowedFlag flag_; | 555 ArgumentsAllowedFlag flag_; |
552 }; | 556 }; |
553 | 557 |
554 | 558 |
555 class TestContext: public AstContext { | 559 class TestContext: public AstContext { |
556 public: | 560 public: |
557 TestContext(HGraphBuilder* owner, | 561 TestContext(HGraphBuilder* owner, |
558 Expression* condition, | 562 Expression* condition, |
559 HBasicBlock* if_true, | 563 HBasicBlock* if_true, |
560 HBasicBlock* if_false) | 564 HBasicBlock* if_false) |
561 : AstContext(owner, Expression::kTest), | 565 : AstContext(owner, Expression::kTest), |
562 condition_(condition), | 566 condition_(condition), |
563 if_true_(if_true), | 567 if_true_(if_true), |
564 if_false_(if_false) { | 568 if_false_(if_false) { |
565 } | 569 } |
566 | 570 |
567 virtual void ReturnValue(HValue* value); | 571 virtual void ReturnValue(HValue* value); |
568 virtual void ReturnInstruction(HInstruction* instr, int ast_id); | 572 virtual void ReturnInstruction(HInstruction* instr, int ast_id); |
573 virtual void ReturnControl(HControlInstruction* instr, int ast_id); | |
569 | 574 |
570 static TestContext* cast(AstContext* context) { | 575 static TestContext* cast(AstContext* context) { |
571 ASSERT(context->IsTest()); | 576 ASSERT(context->IsTest()); |
572 return reinterpret_cast<TestContext*>(context); | 577 return reinterpret_cast<TestContext*>(context); |
573 } | 578 } |
574 | 579 |
575 Expression* condition() const { return condition_; } | 580 Expression* condition() const { return condition_; } |
576 HBasicBlock* if_true() const { return if_true_; } | 581 HBasicBlock* if_true() const { return if_true_; } |
577 HBasicBlock* if_false() const { return if_false_; } | 582 HBasicBlock* if_false() const { return if_false_; } |
578 | 583 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
699 // Adding instructions. | 704 // Adding instructions. |
700 HInstruction* AddInstruction(HInstruction* instr); | 705 HInstruction* AddInstruction(HInstruction* instr); |
701 void AddSimulate(int ast_id); | 706 void AddSimulate(int ast_id); |
702 | 707 |
703 // Bailout environment manipulation. | 708 // Bailout environment manipulation. |
704 void Push(HValue* value) { environment()->Push(value); } | 709 void Push(HValue* value) { environment()->Push(value); } |
705 HValue* Pop() { return environment()->Pop(); } | 710 HValue* Pop() { return environment()->Pop(); } |
706 | 711 |
707 void Bailout(const char* reason); | 712 void Bailout(const char* reason); |
708 | 713 |
714 HBasicBlock* CreateJoin(HBasicBlock* first, | |
715 HBasicBlock* second, | |
716 int join_id); | |
717 | |
709 private: | 718 private: |
710 // Type of a member function that generates inline code for a native function. | 719 // Type of a member function that generates inline code for a native function. |
711 typedef void (HGraphBuilder::*InlineFunctionGenerator)(CallRuntime* call); | 720 typedef void (HGraphBuilder::*InlineFunctionGenerator)(CallRuntime* call); |
712 | 721 |
713 // Forward declarations for inner scope classes. | 722 // Forward declarations for inner scope classes. |
714 class SubgraphScope; | 723 class SubgraphScope; |
715 | 724 |
716 static const InlineFunctionGenerator kInlineFunctionGenerators[]; | 725 static const InlineFunctionGenerator kInlineFunctionGenerators[]; |
717 | 726 |
718 static const int kMaxCallPolymorphism = 4; | 727 static const int kMaxCallPolymorphism = 4; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 void VisitLogicalExpression(BinaryOperation* expr); | 781 void VisitLogicalExpression(BinaryOperation* expr); |
773 void VisitArithmeticExpression(BinaryOperation* expr); | 782 void VisitArithmeticExpression(BinaryOperation* expr); |
774 | 783 |
775 void PreProcessOsrEntry(IterationStatement* statement); | 784 void PreProcessOsrEntry(IterationStatement* statement); |
776 // True iff. we are compiling for OSR and the statement is the entry. | 785 // True iff. we are compiling for OSR and the statement is the entry. |
777 bool HasOsrEntryAt(IterationStatement* statement); | 786 bool HasOsrEntryAt(IterationStatement* statement); |
778 void VisitLoopBody(Statement* body, | 787 void VisitLoopBody(Statement* body, |
779 HBasicBlock* loop_entry, | 788 HBasicBlock* loop_entry, |
780 BreakAndContinueInfo* break_info); | 789 BreakAndContinueInfo* break_info); |
781 | 790 |
782 HBasicBlock* CreateJoin(HBasicBlock* first, | |
783 HBasicBlock* second, | |
784 int join_id); | |
785 | |
786 // Create a back edge in the flow graph. body_exit is the predecessor | 791 // Create a back edge in the flow graph. body_exit is the predecessor |
787 // block and loop_entry is the successor block. loop_successor is the | 792 // block and loop_entry is the successor block. loop_successor is the |
788 // block where control flow exits the loop normally (e.g., via failure of | 793 // block where control flow exits the loop normally (e.g., via failure of |
789 // the condition) and break_block is the block where control flow breaks | 794 // the condition) and break_block is the block where control flow breaks |
790 // from the loop. All blocks except loop_entry can be NULL. The return | 795 // from the loop. All blocks except loop_entry can be NULL. The return |
791 // value is the new successor block which is the join of loop_successor | 796 // value is the new successor block which is the join of loop_successor |
792 // and break_block, or NULL. | 797 // and break_block, or NULL. |
793 HBasicBlock* CreateLoop(IterationStatement* statement, | 798 HBasicBlock* CreateLoop(IterationStatement* statement, |
794 HBasicBlock* loop_entry, | 799 HBasicBlock* loop_entry, |
795 HBasicBlock* body_exit, | 800 HBasicBlock* body_exit, |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1210 const char* filename_; | 1215 const char* filename_; |
1211 HeapStringAllocator string_allocator_; | 1216 HeapStringAllocator string_allocator_; |
1212 StringStream trace_; | 1217 StringStream trace_; |
1213 int indent_; | 1218 int indent_; |
1214 }; | 1219 }; |
1215 | 1220 |
1216 | 1221 |
1217 } } // namespace v8::internal | 1222 } } // namespace v8::internal |
1218 | 1223 |
1219 #endif // V8_HYDROGEN_H_ | 1224 #endif // V8_HYDROGEN_H_ |
OLD | NEW |