Chromium Code Reviews| 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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 | 858 |
| 859 HArgumentsElements* arguments_elements_; | 859 HArgumentsElements* arguments_elements_; |
| 860 | 860 |
| 861 FunctionState* outer_; | 861 FunctionState* outer_; |
| 862 }; | 862 }; |
| 863 | 863 |
| 864 | 864 |
| 865 class HGraphBuilder { | 865 class HGraphBuilder { |
| 866 public: | 866 public: |
| 867 explicit HGraphBuilder(CompilationInfo* info) | 867 explicit HGraphBuilder(CompilationInfo* info) |
| 868 : info_(info), graph_(NULL), current_block_(NULL) {} | 868 : info_(info), |
| 869 graph_(NULL), | |
| 870 current_block_(NULL), | |
| 871 in_no_side_effects_scope_(0) {} | |
|
danno
2013/04/11 12:55:51
no_side_effects_scope_count_?
Hannes Payer (out of office)
2013/04/11 13:00:03
Done.
| |
| 869 virtual ~HGraphBuilder() {} | 872 virtual ~HGraphBuilder() {} |
| 870 | 873 |
| 871 HBasicBlock* current_block() const { return current_block_; } | 874 HBasicBlock* current_block() const { return current_block_; } |
| 872 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 875 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
| 873 HEnvironment* environment() const { | 876 HEnvironment* environment() const { |
| 874 return current_block()->last_environment(); | 877 return current_block()->last_environment(); |
| 875 } | 878 } |
| 876 Zone* zone() const { return info_->zone(); } | 879 Zone* zone() const { return info_->zone(); } |
| 877 HGraph* graph() const { return graph_; } | 880 HGraph* graph() const { return graph_; } |
| 878 Isolate* isolate() const { return graph_->isolate(); } | 881 Isolate* isolate() const { return graph_->isolate(); } |
| 879 | 882 |
| 880 HGraph* CreateGraph(); | 883 HGraph* CreateGraph(); |
| 881 | 884 |
| 882 // Adding instructions. | 885 // Adding instructions. |
| 883 HInstruction* AddInstruction(HInstruction* instr); | 886 HInstruction* AddInstruction(HInstruction* instr); |
| 884 void AddSimulate(BailoutId id, | 887 void AddSimulate(BailoutId id, |
| 885 RemovableSimulate removable = FIXED_SIMULATE); | 888 RemovableSimulate removable = FIXED_SIMULATE); |
| 886 HBoundsCheck* AddBoundsCheck( | 889 HBoundsCheck* AddBoundsCheck( |
| 887 HValue* index, | 890 HValue* index, |
| 888 HValue* length, | 891 HValue* length, |
| 889 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, | 892 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, |
| 890 Representation r = Representation::None()); | 893 Representation r = Representation::None()); |
| 891 | 894 |
| 892 HReturn* AddReturn(HValue* value); | 895 HReturn* AddReturn(HValue* value); |
| 893 | 896 |
| 897 void IncrementInNoSideEffectsScope() { | |
| 898 in_no_side_effects_scope_++; | |
| 899 } | |
| 900 | |
| 901 void DecrementInNoSideEffectsScope() { | |
| 902 in_no_side_effects_scope_--; | |
|
mvstanton
2013/04/11 13:02:38
I would add ASSERT(in_no_side_effects_scope >= 0);
| |
| 903 } | |
| 904 | |
| 894 protected: | 905 protected: |
| 895 virtual bool BuildGraph() = 0; | 906 virtual bool BuildGraph() = 0; |
| 896 | 907 |
| 897 HBasicBlock* CreateBasicBlock(HEnvironment* envy, | 908 HBasicBlock* CreateBasicBlock(HEnvironment* envy, |
| 898 BailoutId previous_ast_id); | 909 BailoutId previous_ast_id); |
| 899 HBasicBlock* CreateLoopHeaderBlock(BailoutId previous_ast_id); | 910 HBasicBlock* CreateLoopHeaderBlock(BailoutId previous_ast_id); |
| 900 | 911 |
| 901 // Building common constructs | 912 // Building common constructs |
| 902 HInstruction* BuildExternalArrayElementAccess( | 913 HInstruction* BuildExternalArrayElementAccess( |
| 903 HValue* external_elements, | 914 HValue* external_elements, |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1025 HInstruction* increment_; | 1036 HInstruction* increment_; |
| 1026 HPhi* phi_; | 1037 HPhi* phi_; |
| 1027 HBasicBlock* header_block_; | 1038 HBasicBlock* header_block_; |
| 1028 HBasicBlock* body_block_; | 1039 HBasicBlock* body_block_; |
| 1029 HBasicBlock* exit_block_; | 1040 HBasicBlock* exit_block_; |
| 1030 Direction direction_; | 1041 Direction direction_; |
| 1031 BailoutId id_; | 1042 BailoutId id_; |
| 1032 bool finished_; | 1043 bool finished_; |
| 1033 }; | 1044 }; |
| 1034 | 1045 |
| 1046 class NoObservableSideEffectsScope { | |
| 1047 public: | |
| 1048 explicit NoObservableSideEffectsScope(HGraphBuilder* builder) : | |
| 1049 builder_(builder) { | |
| 1050 builder_->IncrementInNoSideEffectsScope(); | |
| 1051 } | |
| 1052 ~NoObservableSideEffectsScope() { | |
| 1053 builder_->DecrementInNoSideEffectsScope(); | |
| 1054 } | |
| 1055 | |
| 1056 private: | |
| 1057 HGraphBuilder* builder_; | |
| 1058 }; | |
| 1059 | |
| 1035 HValue* BuildNewElementsCapacity(HValue* context, | 1060 HValue* BuildNewElementsCapacity(HValue* context, |
| 1036 HValue* old_capacity); | 1061 HValue* old_capacity); |
| 1037 | 1062 |
| 1038 void BuildNewSpaceArrayCheck(HValue* length, | 1063 void BuildNewSpaceArrayCheck(HValue* length, |
| 1039 ElementsKind kind); | 1064 ElementsKind kind); |
| 1040 | 1065 |
| 1041 HValue* BuildAllocateElements(HValue* context, | 1066 HValue* BuildAllocateElements(HValue* context, |
| 1042 ElementsKind kind, | 1067 ElementsKind kind, |
| 1043 HValue* capacity); | 1068 HValue* capacity); |
| 1044 | 1069 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1075 AllocationSiteMode mode, | 1100 AllocationSiteMode mode, |
| 1076 ElementsKind kind, | 1101 ElementsKind kind, |
| 1077 BailoutId id, | 1102 BailoutId id, |
| 1078 int length); | 1103 int length); |
| 1079 | 1104 |
| 1080 private: | 1105 private: |
| 1081 HGraphBuilder(); | 1106 HGraphBuilder(); |
| 1082 CompilationInfo* info_; | 1107 CompilationInfo* info_; |
| 1083 HGraph* graph_; | 1108 HGraph* graph_; |
| 1084 HBasicBlock* current_block_; | 1109 HBasicBlock* current_block_; |
| 1110 int in_no_side_effects_scope_; | |
| 1085 }; | 1111 }; |
| 1086 | 1112 |
| 1087 | 1113 |
| 1088 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1114 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
| 1089 public: | 1115 public: |
| 1090 enum BreakType { BREAK, CONTINUE }; | 1116 enum BreakType { BREAK, CONTINUE }; |
| 1091 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH }; | 1117 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH }; |
| 1092 | 1118 |
| 1093 // A class encapsulating (lazily-allocated) break and continue blocks for | 1119 // A class encapsulating (lazily-allocated) break and continue blocks for |
| 1094 // a breakable statement. Separated from BreakAndContinueScope so that it | 1120 // a breakable statement. Separated from BreakAndContinueScope so that it |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1769 EmbeddedVector<char, 64> filename_; | 1795 EmbeddedVector<char, 64> filename_; |
| 1770 HeapStringAllocator string_allocator_; | 1796 HeapStringAllocator string_allocator_; |
| 1771 StringStream trace_; | 1797 StringStream trace_; |
| 1772 int indent_; | 1798 int indent_; |
| 1773 }; | 1799 }; |
| 1774 | 1800 |
| 1775 | 1801 |
| 1776 } } // namespace v8::internal | 1802 } } // namespace v8::internal |
| 1777 | 1803 |
| 1778 #endif // V8_HYDROGEN_H_ | 1804 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |