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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 422 |
423 Zone* HBasicBlock::zone() const { return graph_->zone(); } | 423 Zone* HBasicBlock::zone() const { return graph_->zone(); } |
424 | 424 |
425 | 425 |
426 // Type of stack frame an environment might refer to. | 426 // Type of stack frame an environment might refer to. |
427 enum FrameType { | 427 enum FrameType { |
428 JS_FUNCTION, | 428 JS_FUNCTION, |
429 JS_CONSTRUCT, | 429 JS_CONSTRUCT, |
430 JS_GETTER, | 430 JS_GETTER, |
431 JS_SETTER, | 431 JS_SETTER, |
432 ARGUMENTS_ADAPTOR, | 432 ARGUMENTS_ADAPTOR |
433 STUB | |
434 }; | 433 }; |
435 | 434 |
436 | 435 |
437 class HEnvironment: public ZoneObject { | 436 class HEnvironment: public ZoneObject { |
438 public: | 437 public: |
439 HEnvironment(HEnvironment* outer, | 438 HEnvironment(HEnvironment* outer, |
440 Scope* scope, | 439 Scope* scope, |
441 Handle<JSFunction> closure, | 440 Handle<JSFunction> closure, |
442 Zone* zone); | 441 Zone* zone); |
443 | 442 |
444 explicit HEnvironment(Zone* zone); | |
445 | |
446 HEnvironment* arguments_environment() { | 443 HEnvironment* arguments_environment() { |
447 return outer()->frame_type() == ARGUMENTS_ADAPTOR ? outer() : this; | 444 return outer()->frame_type() == ARGUMENTS_ADAPTOR ? outer() : this; |
448 } | 445 } |
449 | 446 |
450 // Simple accessors. | 447 // Simple accessors. |
451 Handle<JSFunction> closure() const { return closure_; } | 448 Handle<JSFunction> closure() const { return closure_; } |
452 const ZoneList<HValue*>* values() const { return &values_; } | 449 const ZoneList<HValue*>* values() const { return &values_; } |
453 const ZoneList<int>* assigned_variables() const { | 450 const ZoneList<int>* assigned_variables() const { |
454 return &assigned_variables_; | 451 return &assigned_variables_; |
455 } | 452 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 | 629 |
633 private: | 630 private: |
634 Zone* zone() const { return graph_->zone(); } | 631 Zone* zone() const { return graph_->zone(); } |
635 | 632 |
636 HGraph* graph_; | 633 HGraph* graph_; |
637 ZoneList<HValue*> worklist_; | 634 ZoneList<HValue*> worklist_; |
638 BitVector in_worklist_; | 635 BitVector in_worklist_; |
639 }; | 636 }; |
640 | 637 |
641 | 638 |
642 class HOptimizedGraphBuilder; | 639 class HGraphBuilder; |
643 | 640 |
644 enum ArgumentsAllowedFlag { | 641 enum ArgumentsAllowedFlag { |
645 ARGUMENTS_NOT_ALLOWED, | 642 ARGUMENTS_NOT_ALLOWED, |
646 ARGUMENTS_ALLOWED | 643 ARGUMENTS_ALLOWED |
647 }; | 644 }; |
648 | 645 |
649 // This class is not BASE_EMBEDDED because our inlining implementation uses | 646 // This class is not BASE_EMBEDDED because our inlining implementation uses |
650 // new and delete. | 647 // new and delete. |
651 class AstContext { | 648 class AstContext { |
652 public: | 649 public: |
(...skipping 15 matching lines...) Expand all Loading... |
668 // Finishes the current basic block and materialize a boolean for | 665 // Finishes the current basic block and materialize a boolean for |
669 // value context, nothing for effect, generate a branch for test context. | 666 // value context, nothing for effect, generate a branch for test context. |
670 // Call this function in tail position in the Visit functions for | 667 // Call this function in tail position in the Visit functions for |
671 // expressions. | 668 // expressions. |
672 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id) = 0; | 669 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id) = 0; |
673 | 670 |
674 void set_for_typeof(bool for_typeof) { for_typeof_ = for_typeof; } | 671 void set_for_typeof(bool for_typeof) { for_typeof_ = for_typeof; } |
675 bool is_for_typeof() { return for_typeof_; } | 672 bool is_for_typeof() { return for_typeof_; } |
676 | 673 |
677 protected: | 674 protected: |
678 AstContext(HOptimizedGraphBuilder* owner, Expression::Context kind); | 675 AstContext(HGraphBuilder* owner, Expression::Context kind); |
679 virtual ~AstContext(); | 676 virtual ~AstContext(); |
680 | 677 |
681 HOptimizedGraphBuilder* owner() const { return owner_; } | 678 HGraphBuilder* owner() const { return owner_; } |
682 | 679 |
683 inline Zone* zone() const; | 680 inline Zone* zone() const; |
684 | 681 |
685 // We want to be able to assert, in a context-specific way, that the stack | 682 // We want to be able to assert, in a context-specific way, that the stack |
686 // height makes sense when the context is filled. | 683 // height makes sense when the context is filled. |
687 #ifdef DEBUG | 684 #ifdef DEBUG |
688 int original_length_; | 685 int original_length_; |
689 #endif | 686 #endif |
690 | 687 |
691 private: | 688 private: |
692 HOptimizedGraphBuilder* owner_; | 689 HGraphBuilder* owner_; |
693 Expression::Context kind_; | 690 Expression::Context kind_; |
694 AstContext* outer_; | 691 AstContext* outer_; |
695 bool for_typeof_; | 692 bool for_typeof_; |
696 }; | 693 }; |
697 | 694 |
698 | 695 |
699 class EffectContext: public AstContext { | 696 class EffectContext: public AstContext { |
700 public: | 697 public: |
701 explicit EffectContext(HOptimizedGraphBuilder* owner) | 698 explicit EffectContext(HGraphBuilder* owner) |
702 : AstContext(owner, Expression::kEffect) { | 699 : AstContext(owner, Expression::kEffect) { |
703 } | 700 } |
704 virtual ~EffectContext(); | 701 virtual ~EffectContext(); |
705 | 702 |
706 virtual void ReturnValue(HValue* value); | 703 virtual void ReturnValue(HValue* value); |
707 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); | 704 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); |
708 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); | 705 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); |
709 }; | 706 }; |
710 | 707 |
711 | 708 |
712 class ValueContext: public AstContext { | 709 class ValueContext: public AstContext { |
713 public: | 710 public: |
714 ValueContext(HOptimizedGraphBuilder* owner, ArgumentsAllowedFlag flag) | 711 explicit ValueContext(HGraphBuilder* owner, ArgumentsAllowedFlag flag) |
715 : AstContext(owner, Expression::kValue), flag_(flag) { | 712 : AstContext(owner, Expression::kValue), flag_(flag) { |
716 } | 713 } |
717 virtual ~ValueContext(); | 714 virtual ~ValueContext(); |
718 | 715 |
719 virtual void ReturnValue(HValue* value); | 716 virtual void ReturnValue(HValue* value); |
720 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); | 717 virtual void ReturnInstruction(HInstruction* instr, BailoutId ast_id); |
721 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); | 718 virtual void ReturnControl(HControlInstruction* instr, BailoutId ast_id); |
722 | 719 |
723 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } | 720 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } |
724 | 721 |
725 private: | 722 private: |
726 ArgumentsAllowedFlag flag_; | 723 ArgumentsAllowedFlag flag_; |
727 }; | 724 }; |
728 | 725 |
729 | 726 |
730 class TestContext: public AstContext { | 727 class TestContext: public AstContext { |
731 public: | 728 public: |
732 TestContext(HOptimizedGraphBuilder* owner, | 729 TestContext(HGraphBuilder* owner, |
733 Expression* condition, | 730 Expression* condition, |
734 TypeFeedbackOracle* oracle, | 731 TypeFeedbackOracle* oracle, |
735 HBasicBlock* if_true, | 732 HBasicBlock* if_true, |
736 HBasicBlock* if_false) | 733 HBasicBlock* if_false) |
737 : AstContext(owner, Expression::kTest), | 734 : AstContext(owner, Expression::kTest), |
738 condition_(condition), | 735 condition_(condition), |
739 oracle_(oracle), | 736 oracle_(oracle), |
740 if_true_(if_true), | 737 if_true_(if_true), |
741 if_false_(if_false) { | 738 if_false_(if_false) { |
742 } | 739 } |
(...skipping 19 matching lines...) Expand all Loading... |
762 | 759 |
763 Expression* condition_; | 760 Expression* condition_; |
764 TypeFeedbackOracle* oracle_; | 761 TypeFeedbackOracle* oracle_; |
765 HBasicBlock* if_true_; | 762 HBasicBlock* if_true_; |
766 HBasicBlock* if_false_; | 763 HBasicBlock* if_false_; |
767 }; | 764 }; |
768 | 765 |
769 | 766 |
770 class FunctionState { | 767 class FunctionState { |
771 public: | 768 public: |
772 FunctionState(HOptimizedGraphBuilder* owner, | 769 FunctionState(HGraphBuilder* owner, |
773 CompilationInfo* info, | 770 CompilationInfo* info, |
774 TypeFeedbackOracle* oracle, | 771 TypeFeedbackOracle* oracle, |
775 InliningKind inlining_kind); | 772 InliningKind inlining_kind); |
776 ~FunctionState(); | 773 ~FunctionState(); |
777 | 774 |
778 CompilationInfo* compilation_info() { return compilation_info_; } | 775 CompilationInfo* compilation_info() { return compilation_info_; } |
779 TypeFeedbackOracle* oracle() { return oracle_; } | 776 TypeFeedbackOracle* oracle() { return oracle_; } |
780 AstContext* call_context() { return call_context_; } | 777 AstContext* call_context() { return call_context_; } |
781 InliningKind inlining_kind() const { return inlining_kind_; } | 778 InliningKind inlining_kind() const { return inlining_kind_; } |
782 HBasicBlock* function_return() { return function_return_; } | 779 HBasicBlock* function_return() { return function_return_; } |
783 TestContext* test_context() { return test_context_; } | 780 TestContext* test_context() { return test_context_; } |
784 void ClearInlinedTestContext() { | 781 void ClearInlinedTestContext() { |
785 delete test_context_; | 782 delete test_context_; |
786 test_context_ = NULL; | 783 test_context_ = NULL; |
787 } | 784 } |
788 | 785 |
789 FunctionState* outer() { return outer_; } | 786 FunctionState* outer() { return outer_; } |
790 | 787 |
791 HEnterInlined* entry() { return entry_; } | 788 HEnterInlined* entry() { return entry_; } |
792 void set_entry(HEnterInlined* entry) { entry_ = entry; } | 789 void set_entry(HEnterInlined* entry) { entry_ = entry; } |
793 | 790 |
794 HArgumentsElements* arguments_elements() { return arguments_elements_; } | 791 HArgumentsElements* arguments_elements() { return arguments_elements_; } |
795 void set_arguments_elements(HArgumentsElements* arguments_elements) { | 792 void set_arguments_elements(HArgumentsElements* arguments_elements) { |
796 arguments_elements_ = arguments_elements; | 793 arguments_elements_ = arguments_elements; |
797 } | 794 } |
798 | 795 |
799 bool arguments_pushed() { return arguments_elements() != NULL; } | 796 bool arguments_pushed() { return arguments_elements() != NULL; } |
800 | 797 |
801 private: | 798 private: |
802 HOptimizedGraphBuilder* owner_; | 799 HGraphBuilder* owner_; |
803 | 800 |
804 CompilationInfo* compilation_info_; | 801 CompilationInfo* compilation_info_; |
805 TypeFeedbackOracle* oracle_; | 802 TypeFeedbackOracle* oracle_; |
806 | 803 |
807 // During function inlining, expression context of the call being | 804 // During function inlining, expression context of the call being |
808 // inlined. NULL when not inlining. | 805 // inlined. NULL when not inlining. |
809 AstContext* call_context_; | 806 AstContext* call_context_; |
810 | 807 |
811 // The kind of call which is currently being inlined. | 808 // The kind of call which is currently being inlined. |
812 InliningKind inlining_kind_; | 809 InliningKind inlining_kind_; |
(...skipping 11 matching lines...) Expand all Loading... |
824 // When inlining HEnterInlined instruction corresponding to the function | 821 // When inlining HEnterInlined instruction corresponding to the function |
825 // entry. | 822 // entry. |
826 HEnterInlined* entry_; | 823 HEnterInlined* entry_; |
827 | 824 |
828 HArgumentsElements* arguments_elements_; | 825 HArgumentsElements* arguments_elements_; |
829 | 826 |
830 FunctionState* outer_; | 827 FunctionState* outer_; |
831 }; | 828 }; |
832 | 829 |
833 | 830 |
834 class HGraphBuilder { | 831 class HGraphBuilder: public AstVisitor { |
835 public: | |
836 explicit HGraphBuilder(CompilationInfo* info) | |
837 : info_(info), graph_(NULL), current_block_(NULL) {} | |
838 virtual ~HGraphBuilder() {} | |
839 | |
840 HBasicBlock* current_block() const { return current_block_; } | |
841 void set_current_block(HBasicBlock* block) { current_block_ = block; } | |
842 HEnvironment* environment() const { | |
843 return current_block()->last_environment(); | |
844 } | |
845 Zone* zone() const { return info_->zone(); } | |
846 HGraph* graph() { return graph_; } | |
847 | |
848 HGraph* CreateGraph(); | |
849 | |
850 // Adding instructions. | |
851 HInstruction* AddInstruction(HInstruction* instr); | |
852 void AddSimulate(BailoutId id, | |
853 RemovableSimulate removable = FIXED_SIMULATE); | |
854 | |
855 protected: | |
856 virtual bool BuildGraph() = 0; | |
857 | |
858 // Building common constructs | |
859 HInstruction* BuildExternalArrayElementAccess( | |
860 HValue* external_elements, | |
861 HValue* checked_key, | |
862 HValue* val, | |
863 HValue* dependency, | |
864 ElementsKind elements_kind, | |
865 bool is_store); | |
866 | |
867 HInstruction* BuildFastElementAccess( | |
868 HValue* elements, | |
869 HValue* checked_key, | |
870 HValue* val, | |
871 HValue* dependency, | |
872 ElementsKind elements_kind, | |
873 bool is_store); | |
874 | |
875 HInstruction* BuildUncheckedMonomorphicElementAccess( | |
876 HValue* object, | |
877 HValue* key, | |
878 HValue* val, | |
879 HCheckMaps* mapcheck, | |
880 bool is_js_array, | |
881 ElementsKind elements_kind, | |
882 bool is_store); | |
883 | |
884 private: | |
885 HGraphBuilder(); | |
886 CompilationInfo* info_; | |
887 HGraph* graph_; | |
888 HBasicBlock* current_block_; | |
889 }; | |
890 | |
891 | |
892 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | |
893 public: | 832 public: |
894 enum BreakType { BREAK, CONTINUE }; | 833 enum BreakType { BREAK, CONTINUE }; |
895 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH }; | 834 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH }; |
896 | 835 |
897 // A class encapsulating (lazily-allocated) break and continue blocks for | 836 // A class encapsulating (lazily-allocated) break and continue blocks for |
898 // a breakable statement. Separated from BreakAndContinueScope so that it | 837 // a breakable statement. Separated from BreakAndContinueScope so that it |
899 // can have a separate lifetime. | 838 // can have a separate lifetime. |
900 class BreakAndContinueInfo BASE_EMBEDDED { | 839 class BreakAndContinueInfo BASE_EMBEDDED { |
901 public: | 840 public: |
902 explicit BreakAndContinueInfo(BreakableStatement* target, | 841 explicit BreakAndContinueInfo(BreakableStatement* target, |
(...skipping 15 matching lines...) Expand all Loading... |
918 BreakableStatement* target_; | 857 BreakableStatement* target_; |
919 HBasicBlock* break_block_; | 858 HBasicBlock* break_block_; |
920 HBasicBlock* continue_block_; | 859 HBasicBlock* continue_block_; |
921 int drop_extra_; | 860 int drop_extra_; |
922 }; | 861 }; |
923 | 862 |
924 // A helper class to maintain a stack of current BreakAndContinueInfo | 863 // A helper class to maintain a stack of current BreakAndContinueInfo |
925 // structures mirroring BreakableStatement nesting. | 864 // structures mirroring BreakableStatement nesting. |
926 class BreakAndContinueScope BASE_EMBEDDED { | 865 class BreakAndContinueScope BASE_EMBEDDED { |
927 public: | 866 public: |
928 BreakAndContinueScope(BreakAndContinueInfo* info, | 867 BreakAndContinueScope(BreakAndContinueInfo* info, HGraphBuilder* owner) |
929 HOptimizedGraphBuilder* owner) | |
930 : info_(info), owner_(owner), next_(owner->break_scope()) { | 868 : info_(info), owner_(owner), next_(owner->break_scope()) { |
931 owner->set_break_scope(this); | 869 owner->set_break_scope(this); |
932 } | 870 } |
933 | 871 |
934 ~BreakAndContinueScope() { owner_->set_break_scope(next_); } | 872 ~BreakAndContinueScope() { owner_->set_break_scope(next_); } |
935 | 873 |
936 BreakAndContinueInfo* info() { return info_; } | 874 BreakAndContinueInfo* info() { return info_; } |
937 HOptimizedGraphBuilder* owner() { return owner_; } | 875 HGraphBuilder* owner() { return owner_; } |
938 BreakAndContinueScope* next() { return next_; } | 876 BreakAndContinueScope* next() { return next_; } |
939 | 877 |
940 // Search the break stack for a break or continue target. | 878 // Search the break stack for a break or continue target. |
941 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra); | 879 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra); |
942 | 880 |
943 private: | 881 private: |
944 BreakAndContinueInfo* info_; | 882 BreakAndContinueInfo* info_; |
945 HOptimizedGraphBuilder* owner_; | 883 HGraphBuilder* owner_; |
946 BreakAndContinueScope* next_; | 884 BreakAndContinueScope* next_; |
947 }; | 885 }; |
948 | 886 |
949 HOptimizedGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle); | 887 HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle); |
950 | 888 |
951 virtual bool BuildGraph(); | 889 HGraph* CreateGraph(); |
952 | 890 |
953 // Simple accessors. | 891 // Simple accessors. |
| 892 HGraph* graph() const { return graph_; } |
954 BreakAndContinueScope* break_scope() const { return break_scope_; } | 893 BreakAndContinueScope* break_scope() const { return break_scope_; } |
955 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } | 894 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } |
956 | 895 |
| 896 HBasicBlock* current_block() const { return current_block_; } |
| 897 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
| 898 HEnvironment* environment() const { |
| 899 return current_block()->last_environment(); |
| 900 } |
| 901 |
957 bool inline_bailout() { return inline_bailout_; } | 902 bool inline_bailout() { return inline_bailout_; } |
958 | 903 |
| 904 // Adding instructions. |
| 905 HInstruction* AddInstruction(HInstruction* instr); |
| 906 void AddSimulate(BailoutId ast_id, |
| 907 RemovableSimulate removable = FIXED_SIMULATE); |
| 908 |
959 // Bailout environment manipulation. | 909 // Bailout environment manipulation. |
960 void Push(HValue* value) { environment()->Push(value); } | 910 void Push(HValue* value) { environment()->Push(value); } |
961 HValue* Pop() { return environment()->Pop(); } | 911 HValue* Pop() { return environment()->Pop(); } |
962 | 912 |
963 void Bailout(const char* reason); | 913 void Bailout(const char* reason); |
964 | 914 |
965 HBasicBlock* CreateJoin(HBasicBlock* first, | 915 HBasicBlock* CreateJoin(HBasicBlock* first, |
966 HBasicBlock* second, | 916 HBasicBlock* second, |
967 BailoutId join_id); | 917 BailoutId join_id); |
968 | 918 |
969 TypeFeedbackOracle* oracle() const { return function_state()->oracle(); } | 919 TypeFeedbackOracle* oracle() const { return function_state()->oracle(); } |
970 | 920 |
971 FunctionState* function_state() const { return function_state_; } | 921 FunctionState* function_state() const { return function_state_; } |
972 | 922 |
973 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 923 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
974 | 924 |
975 void* operator new(size_t size, Zone* zone) { | 925 void* operator new(size_t size, Zone* zone) { |
976 return zone->New(static_cast<int>(size)); | 926 return zone->New(static_cast<int>(size)); |
977 } | 927 } |
978 void operator delete(void* pointer, Zone* zone) { } | 928 void operator delete(void* pointer, Zone* zone) { } |
979 void operator delete(void* pointer) { } | 929 void operator delete(void* pointer) { } |
980 | 930 |
981 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | |
982 | |
983 private: | 931 private: |
984 // Type of a member function that generates inline code for a native function. | 932 // Type of a member function that generates inline code for a native function. |
985 typedef void (HOptimizedGraphBuilder::*InlineFunctionGenerator) | 933 typedef void (HGraphBuilder::*InlineFunctionGenerator)(CallRuntime* call); |
986 (CallRuntime* call); | |
987 | 934 |
988 // Forward declarations for inner scope classes. | 935 // Forward declarations for inner scope classes. |
989 class SubgraphScope; | 936 class SubgraphScope; |
990 | 937 |
991 static const InlineFunctionGenerator kInlineFunctionGenerators[]; | 938 static const InlineFunctionGenerator kInlineFunctionGenerators[]; |
992 | 939 |
993 static const int kMaxCallPolymorphism = 4; | 940 static const int kMaxCallPolymorphism = 4; |
994 static const int kMaxLoadPolymorphism = 4; | 941 static const int kMaxLoadPolymorphism = 4; |
995 static const int kMaxStorePolymorphism = 4; | 942 static const int kMaxStorePolymorphism = 4; |
996 | 943 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 NilValue nil); | 1132 NilValue nil); |
1186 | 1133 |
1187 HStringCharCodeAt* BuildStringCharCodeAt(HValue* context, | 1134 HStringCharCodeAt* BuildStringCharCodeAt(HValue* context, |
1188 HValue* string, | 1135 HValue* string, |
1189 HValue* index); | 1136 HValue* index); |
1190 HInstruction* BuildBinaryOperation(BinaryOperation* expr, | 1137 HInstruction* BuildBinaryOperation(BinaryOperation* expr, |
1191 HValue* left, | 1138 HValue* left, |
1192 HValue* right); | 1139 HValue* right); |
1193 HInstruction* BuildIncrement(bool returns_original_input, | 1140 HInstruction* BuildIncrement(bool returns_original_input, |
1194 CountOperation* expr); | 1141 CountOperation* expr); |
1195 HInstruction* BuildLoadKeyedGeneric(HValue* object, | 1142 HInstruction* BuildFastElementAccess(HValue* elements, |
1196 HValue* key); | 1143 HValue* checked_key, |
| 1144 HValue* val, |
| 1145 HValue* dependency, |
| 1146 ElementsKind elements_kind, |
| 1147 bool is_store); |
1197 | 1148 |
1198 HInstruction* TryBuildConsolidatedElementLoad(HValue* object, | 1149 HInstruction* TryBuildConsolidatedElementLoad(HValue* object, |
1199 HValue* key, | 1150 HValue* key, |
1200 HValue* val, | 1151 HValue* val, |
1201 SmallMapList* maps); | 1152 SmallMapList* maps); |
1202 | 1153 |
| 1154 HInstruction* BuildUncheckedMonomorphicElementAccess(HValue* object, |
| 1155 HValue* key, |
| 1156 HValue* val, |
| 1157 HCheckMaps* mapcheck, |
| 1158 Handle<Map> map, |
| 1159 bool is_store); |
| 1160 |
1203 HInstruction* BuildMonomorphicElementAccess(HValue* object, | 1161 HInstruction* BuildMonomorphicElementAccess(HValue* object, |
1204 HValue* key, | 1162 HValue* key, |
1205 HValue* val, | 1163 HValue* val, |
1206 HValue* dependency, | 1164 HValue* dependency, |
1207 Handle<Map> map, | 1165 Handle<Map> map, |
1208 bool is_store); | 1166 bool is_store); |
1209 | 1167 |
1210 HValue* HandlePolymorphicElementAccess(HValue* object, | 1168 HValue* HandlePolymorphicElementAccess(HValue* object, |
1211 HValue* key, | 1169 HValue* key, |
1212 HValue* val, | 1170 HValue* val, |
(...skipping 19 matching lines...) Expand all Loading... |
1232 Handle<String> name, | 1190 Handle<String> name, |
1233 Property* expr); | 1191 Property* expr); |
1234 HInstruction* BuildCallGetter(HValue* object, | 1192 HInstruction* BuildCallGetter(HValue* object, |
1235 Handle<Map> map, | 1193 Handle<Map> map, |
1236 Handle<JSFunction> getter, | 1194 Handle<JSFunction> getter, |
1237 Handle<JSObject> holder); | 1195 Handle<JSObject> holder); |
1238 HInstruction* BuildLoadNamedMonomorphic(HValue* object, | 1196 HInstruction* BuildLoadNamedMonomorphic(HValue* object, |
1239 Handle<String> name, | 1197 Handle<String> name, |
1240 Property* expr, | 1198 Property* expr, |
1241 Handle<Map> map); | 1199 Handle<Map> map); |
| 1200 HInstruction* BuildLoadKeyedGeneric(HValue* object, HValue* key); |
| 1201 HInstruction* BuildExternalArrayElementAccess( |
| 1202 HValue* external_elements, |
| 1203 HValue* checked_key, |
| 1204 HValue* val, |
| 1205 HValue* dependency, |
| 1206 ElementsKind elements_kind, |
| 1207 bool is_store); |
1242 | 1208 |
1243 void AddCheckMapsWithTransitions(HValue* object, | 1209 void AddCheckMapsWithTransitions(HValue* object, |
1244 Handle<Map> map); | 1210 Handle<Map> map); |
1245 | 1211 |
1246 HInstruction* BuildStoreNamedField(HValue* object, | 1212 HInstruction* BuildStoreNamedField(HValue* object, |
1247 Handle<String> name, | 1213 Handle<String> name, |
1248 HValue* value, | 1214 HValue* value, |
1249 Handle<Map> map, | 1215 Handle<Map> map, |
1250 LookupResult* lookup); | 1216 LookupResult* lookup); |
1251 HInstruction* BuildStoreNamedGeneric(HValue* object, | 1217 HInstruction* BuildStoreNamedGeneric(HValue* object, |
(...skipping 21 matching lines...) Expand all Loading... |
1273 | 1239 |
1274 void AddCheckConstantFunction(Handle<JSObject> holder, | 1240 void AddCheckConstantFunction(Handle<JSObject> holder, |
1275 HValue* receiver, | 1241 HValue* receiver, |
1276 Handle<Map> receiver_map); | 1242 Handle<Map> receiver_map); |
1277 | 1243 |
1278 bool MatchRotateRight(HValue* left, | 1244 bool MatchRotateRight(HValue* left, |
1279 HValue* right, | 1245 HValue* right, |
1280 HValue** operand, | 1246 HValue** operand, |
1281 HValue** shift_amount); | 1247 HValue** shift_amount); |
1282 | 1248 |
| 1249 Zone* zone() const { return zone_; } |
| 1250 |
1283 // The translation state of the currently-being-translated function. | 1251 // The translation state of the currently-being-translated function. |
1284 FunctionState* function_state_; | 1252 FunctionState* function_state_; |
1285 | 1253 |
1286 // The base of the function state stack. | 1254 // The base of the function state stack. |
1287 FunctionState initial_function_state_; | 1255 FunctionState initial_function_state_; |
1288 | 1256 |
1289 // Expression context of the currently visited subexpression. NULL when | 1257 // Expression context of the currently visited subexpression. NULL when |
1290 // visiting statements. | 1258 // visiting statements. |
1291 AstContext* ast_context_; | 1259 AstContext* ast_context_; |
1292 | 1260 |
1293 // A stack of breakable statements entered. | 1261 // A stack of breakable statements entered. |
1294 BreakAndContinueScope* break_scope_; | 1262 BreakAndContinueScope* break_scope_; |
1295 | 1263 |
| 1264 HGraph* graph_; |
| 1265 HBasicBlock* current_block_; |
| 1266 |
1296 int inlined_count_; | 1267 int inlined_count_; |
1297 ZoneList<Handle<Object> > globals_; | 1268 ZoneList<Handle<Object> > globals_; |
1298 | 1269 |
| 1270 Zone* zone_; |
| 1271 |
1299 bool inline_bailout_; | 1272 bool inline_bailout_; |
1300 | 1273 |
1301 friend class FunctionState; // Pushes and pops the state stack. | 1274 friend class FunctionState; // Pushes and pops the state stack. |
1302 friend class AstContext; // Pushes and pops the AST context stack. | 1275 friend class AstContext; // Pushes and pops the AST context stack. |
1303 friend class KeyedLoadFastElementStub; | |
1304 | 1276 |
1305 DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder); | 1277 DISALLOW_COPY_AND_ASSIGN(HGraphBuilder); |
1306 }; | 1278 }; |
1307 | 1279 |
1308 | 1280 |
1309 Zone* AstContext::zone() const { return owner_->zone(); } | 1281 Zone* AstContext::zone() const { return owner_->zone(); } |
1310 | 1282 |
1311 | 1283 |
1312 class HValueMap: public ZoneObject { | 1284 class HValueMap: public ZoneObject { |
1313 public: | 1285 public: |
1314 explicit HValueMap(Zone* zone) | 1286 explicit HValueMap(Zone* zone) |
1315 : array_size_(0), | 1287 : array_size_(0), |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 const char* name_; | 1440 const char* name_; |
1469 HGraph* graph_; | 1441 HGraph* graph_; |
1470 LChunk* chunk_; | 1442 LChunk* chunk_; |
1471 LAllocator* allocator_; | 1443 LAllocator* allocator_; |
1472 unsigned start_allocation_size_; | 1444 unsigned start_allocation_size_; |
1473 }; | 1445 }; |
1474 | 1446 |
1475 | 1447 |
1476 class HTracer: public Malloced { | 1448 class HTracer: public Malloced { |
1477 public: | 1449 public: |
1478 void TraceCompilation(CompilationInfo* info); | 1450 void TraceCompilation(FunctionLiteral* function); |
1479 void TraceHydrogen(const char* name, HGraph* graph); | 1451 void TraceHydrogen(const char* name, HGraph* graph); |
1480 void TraceLithium(const char* name, LChunk* chunk); | 1452 void TraceLithium(const char* name, LChunk* chunk); |
1481 void TraceLiveRanges(const char* name, LAllocator* allocator); | 1453 void TraceLiveRanges(const char* name, LAllocator* allocator); |
1482 | 1454 |
1483 static HTracer* Instance() { | 1455 static HTracer* Instance() { |
1484 static SetOncePointer<HTracer> instance; | 1456 static SetOncePointer<HTracer> instance; |
1485 if (!instance.is_set()) { | 1457 if (!instance.is_set()) { |
1486 instance.set(new HTracer("hydrogen.cfg")); | 1458 instance.set(new HTracer("hydrogen.cfg")); |
1487 } | 1459 } |
1488 return instance.get(); | 1460 return instance.get(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 const char* filename_; | 1527 const char* filename_; |
1556 HeapStringAllocator string_allocator_; | 1528 HeapStringAllocator string_allocator_; |
1557 StringStream trace_; | 1529 StringStream trace_; |
1558 int indent_; | 1530 int indent_; |
1559 }; | 1531 }; |
1560 | 1532 |
1561 | 1533 |
1562 } } // namespace v8::internal | 1534 } } // namespace v8::internal |
1563 | 1535 |
1564 #endif // V8_HYDROGEN_H_ | 1536 #endif // V8_HYDROGEN_H_ |
OLD | NEW |