| 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 bool ExpressionStackIsEmpty() const; | 519 bool ExpressionStackIsEmpty() const; |
| 520 | 520 |
| 521 HValue* ExpressionStackAt(int index_from_top) const { | 521 HValue* ExpressionStackAt(int index_from_top) const { |
| 522 int index = length() - index_from_top - 1; | 522 int index = length() - index_from_top - 1; |
| 523 ASSERT(HasExpressionAt(index)); | 523 ASSERT(HasExpressionAt(index)); |
| 524 return values_[index]; | 524 return values_[index]; |
| 525 } | 525 } |
| 526 | 526 |
| 527 void SetExpressionStackAt(int index_from_top, HValue* value); | 527 void SetExpressionStackAt(int index_from_top, HValue* value); |
| 528 | 528 |
| 529 int handler_count() { return handler_count_; } |
| 530 void AddExceptionHandler() { ++handler_count_; } |
| 531 void RemoveExceptionHandler() { |
| 532 ASSERT(handler_count_ > 0); |
| 533 --handler_count_; |
| 534 } |
| 535 |
| 529 HEnvironment* Copy() const; | 536 HEnvironment* Copy() const; |
| 530 HEnvironment* CopyWithoutHistory() const; | 537 HEnvironment* CopyWithoutHistory() const; |
| 531 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const; | 538 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const; |
| 532 | 539 |
| 533 // Create an "inlined version" of this environment, where the original | 540 // Create an "inlined version" of this environment, where the original |
| 534 // environment is the outer environment but the top expression stack | 541 // environment is the outer environment but the top expression stack |
| 535 // elements are moved to an inner environment as parameters. | 542 // elements are moved to an inner environment as parameters. |
| 536 HEnvironment* CopyForInlining(Handle<JSFunction> target, | 543 HEnvironment* CopyForInlining(Handle<JSFunction> target, |
| 537 int arguments, | 544 int arguments, |
| 538 FunctionLiteral* function, | 545 FunctionLiteral* function, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 } | 599 } |
| 593 | 600 |
| 594 Handle<JSFunction> closure_; | 601 Handle<JSFunction> closure_; |
| 595 // Value array [parameters] [specials] [locals] [temporaries]. | 602 // Value array [parameters] [specials] [locals] [temporaries]. |
| 596 ZoneList<HValue*> values_; | 603 ZoneList<HValue*> values_; |
| 597 ZoneList<int> assigned_variables_; | 604 ZoneList<int> assigned_variables_; |
| 598 FrameType frame_type_; | 605 FrameType frame_type_; |
| 599 int parameter_count_; | 606 int parameter_count_; |
| 600 int specials_count_; | 607 int specials_count_; |
| 601 int local_count_; | 608 int local_count_; |
| 609 int handler_count_; |
| 602 HEnvironment* outer_; | 610 HEnvironment* outer_; |
| 603 int pop_count_; | 611 int pop_count_; |
| 604 int push_count_; | 612 int push_count_; |
| 605 BailoutId ast_id_; | 613 BailoutId ast_id_; |
| 606 Zone* zone_; | 614 Zone* zone_; |
| 607 }; | 615 }; |
| 608 | 616 |
| 609 | 617 |
| 610 class HGraphBuilder; | 618 class HGraphBuilder; |
| 611 | 619 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 class HGraphBuilder: public AstVisitor { | 810 class HGraphBuilder: public AstVisitor { |
| 803 public: | 811 public: |
| 804 enum BreakType { BREAK, CONTINUE }; | 812 enum BreakType { BREAK, CONTINUE }; |
| 805 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH }; | 813 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH }; |
| 806 | 814 |
| 807 // A class encapsulating (lazily-allocated) break and continue blocks for | 815 // A class encapsulating (lazily-allocated) break and continue blocks for |
| 808 // a breakable statement. Separated from BreakAndContinueScope so that it | 816 // a breakable statement. Separated from BreakAndContinueScope so that it |
| 809 // can have a separate lifetime. | 817 // can have a separate lifetime. |
| 810 class BreakAndContinueInfo BASE_EMBEDDED { | 818 class BreakAndContinueInfo BASE_EMBEDDED { |
| 811 public: | 819 public: |
| 812 explicit BreakAndContinueInfo(BreakableStatement* target, | 820 BreakAndContinueInfo(Statement* statement, int drop_extra) |
| 813 int drop_extra = 0) | 821 : statement_(statement), |
| 814 : target_(target), | |
| 815 break_block_(NULL), | 822 break_block_(NULL), |
| 816 continue_block_(NULL), | 823 continue_block_(NULL), |
| 817 drop_extra_(drop_extra) { | 824 drop_extra_(drop_extra) { |
| 818 } | 825 } |
| 819 | 826 |
| 820 BreakableStatement* target() { return target_; } | 827 Statement* statement() { return statement_; } |
| 828 |
| 821 HBasicBlock* break_block() { return break_block_; } | 829 HBasicBlock* break_block() { return break_block_; } |
| 822 void set_break_block(HBasicBlock* block) { break_block_ = block; } | 830 void set_break_block(HBasicBlock* block) { break_block_ = block; } |
| 823 HBasicBlock* continue_block() { return continue_block_; } | 831 HBasicBlock* continue_block() { return continue_block_; } |
| 824 void set_continue_block(HBasicBlock* block) { continue_block_ = block; } | 832 void set_continue_block(HBasicBlock* block) { continue_block_ = block; } |
| 825 int drop_extra() { return drop_extra_; } | 833 int drop_extra() { return drop_extra_; } |
| 826 | 834 |
| 827 private: | 835 private: |
| 828 BreakableStatement* target_; | 836 Statement* statement_; |
| 829 HBasicBlock* break_block_; | 837 HBasicBlock* break_block_; |
| 830 HBasicBlock* continue_block_; | 838 HBasicBlock* continue_block_; |
| 831 int drop_extra_; | 839 int drop_extra_; |
| 832 }; | 840 }; |
| 833 | 841 |
| 834 // A helper class to maintain a stack of current BreakAndContinueInfo | 842 // A helper class to maintain a stack of current BreakAndContinueInfo |
| 835 // structures mirroring BreakableStatement nesting. | 843 // structures mirroring BreakableStatement nesting. |
| 836 class BreakAndContinueScope BASE_EMBEDDED { | 844 class BreakAndContinueScope BASE_EMBEDDED { |
| 837 public: | 845 public: |
| 838 BreakAndContinueScope(BreakAndContinueInfo* info, HGraphBuilder* owner) | 846 BreakAndContinueScope(BreakAndContinueInfo* info, HGraphBuilder* owner) |
| 839 : info_(info), owner_(owner), next_(owner->break_scope()) { | 847 : info_(info), owner_(owner), next_(owner->break_scope()) { |
| 840 owner->set_break_scope(this); | 848 owner->set_break_scope(this); |
| 841 } | 849 } |
| 842 | 850 |
| 843 ~BreakAndContinueScope() { owner_->set_break_scope(next_); } | 851 ~BreakAndContinueScope() { owner_->set_break_scope(next_); } |
| 844 | 852 |
| 845 BreakAndContinueInfo* info() { return info_; } | 853 BreakAndContinueInfo* info() { return info_; } |
| 846 HGraphBuilder* owner() { return owner_; } | 854 HGraphBuilder* owner() { return owner_; } |
| 847 BreakAndContinueScope* next() { return next_; } | 855 BreakAndContinueScope* next() { return next_; } |
| 848 | 856 |
| 849 // Search the break stack for a break or continue target. | 857 // Search the break stack for a break or continue target, emit any |
| 850 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra); | 858 // instructions necessary to unwind the break stack and emit a jump to |
| 859 // the target block. |
| 860 void Unwind(BreakableStatement* target, BreakType type); |
| 861 |
| 862 // Unwind the entire break stack for returning from the function. |
| 863 void UnwindReturn(); |
| 851 | 864 |
| 852 private: | 865 private: |
| 853 BreakAndContinueInfo* info_; | 866 BreakAndContinueInfo* info_; |
| 854 HGraphBuilder* owner_; | 867 HGraphBuilder* owner_; |
| 855 BreakAndContinueScope* next_; | 868 BreakAndContinueScope* next_; |
| 856 }; | 869 }; |
| 857 | 870 |
| 858 HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle); | 871 HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle); |
| 859 | 872 |
| 860 HGraph* CreateGraph(); | 873 HGraph* CreateGraph(); |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 const char* filename_; | 1495 const char* filename_; |
| 1483 HeapStringAllocator string_allocator_; | 1496 HeapStringAllocator string_allocator_; |
| 1484 StringStream trace_; | 1497 StringStream trace_; |
| 1485 int indent_; | 1498 int indent_; |
| 1486 }; | 1499 }; |
| 1487 | 1500 |
| 1488 | 1501 |
| 1489 } } // namespace v8::internal | 1502 } } // namespace v8::internal |
| 1490 | 1503 |
| 1491 #endif // V8_HYDROGEN_H_ | 1504 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |