OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HYDROGEN_H_ | 5 #ifndef V8_HYDROGEN_H_ |
6 #define V8_HYDROGEN_H_ | 6 #define V8_HYDROGEN_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 }; | 812 }; |
813 | 813 |
814 | 814 |
815 class EffectContext FINAL : public AstContext { | 815 class EffectContext FINAL : public AstContext { |
816 public: | 816 public: |
817 explicit EffectContext(HOptimizedGraphBuilder* owner) | 817 explicit EffectContext(HOptimizedGraphBuilder* owner) |
818 : AstContext(owner, Expression::kEffect) { | 818 : AstContext(owner, Expression::kEffect) { |
819 } | 819 } |
820 virtual ~EffectContext(); | 820 virtual ~EffectContext(); |
821 | 821 |
822 virtual void ReturnValue(HValue* value) OVERRIDE; | 822 void ReturnValue(HValue* value) OVERRIDE; |
823 virtual void ReturnInstruction(HInstruction* instr, | 823 virtual void ReturnInstruction(HInstruction* instr, |
824 BailoutId ast_id) OVERRIDE; | 824 BailoutId ast_id) OVERRIDE; |
825 virtual void ReturnControl(HControlInstruction* instr, | 825 virtual void ReturnControl(HControlInstruction* instr, |
826 BailoutId ast_id) OVERRIDE; | 826 BailoutId ast_id) OVERRIDE; |
827 virtual void ReturnContinuation(HIfContinuation* continuation, | 827 virtual void ReturnContinuation(HIfContinuation* continuation, |
828 BailoutId ast_id) OVERRIDE; | 828 BailoutId ast_id) OVERRIDE; |
829 }; | 829 }; |
830 | 830 |
831 | 831 |
832 class ValueContext FINAL : public AstContext { | 832 class ValueContext FINAL : public AstContext { |
833 public: | 833 public: |
834 ValueContext(HOptimizedGraphBuilder* owner, ArgumentsAllowedFlag flag) | 834 ValueContext(HOptimizedGraphBuilder* owner, ArgumentsAllowedFlag flag) |
835 : AstContext(owner, Expression::kValue), flag_(flag) { | 835 : AstContext(owner, Expression::kValue), flag_(flag) { |
836 } | 836 } |
837 virtual ~ValueContext(); | 837 virtual ~ValueContext(); |
838 | 838 |
839 virtual void ReturnValue(HValue* value) OVERRIDE; | 839 void ReturnValue(HValue* value) OVERRIDE; |
840 virtual void ReturnInstruction(HInstruction* instr, | 840 virtual void ReturnInstruction(HInstruction* instr, |
841 BailoutId ast_id) OVERRIDE; | 841 BailoutId ast_id) OVERRIDE; |
842 virtual void ReturnControl(HControlInstruction* instr, | 842 virtual void ReturnControl(HControlInstruction* instr, |
843 BailoutId ast_id) OVERRIDE; | 843 BailoutId ast_id) OVERRIDE; |
844 virtual void ReturnContinuation(HIfContinuation* continuation, | 844 virtual void ReturnContinuation(HIfContinuation* continuation, |
845 BailoutId ast_id) OVERRIDE; | 845 BailoutId ast_id) OVERRIDE; |
846 | 846 |
847 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } | 847 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; } |
848 | 848 |
849 private: | 849 private: |
850 ArgumentsAllowedFlag flag_; | 850 ArgumentsAllowedFlag flag_; |
851 }; | 851 }; |
852 | 852 |
853 | 853 |
854 class TestContext FINAL : public AstContext { | 854 class TestContext FINAL : public AstContext { |
855 public: | 855 public: |
856 TestContext(HOptimizedGraphBuilder* owner, | 856 TestContext(HOptimizedGraphBuilder* owner, |
857 Expression* condition, | 857 Expression* condition, |
858 HBasicBlock* if_true, | 858 HBasicBlock* if_true, |
859 HBasicBlock* if_false) | 859 HBasicBlock* if_false) |
860 : AstContext(owner, Expression::kTest), | 860 : AstContext(owner, Expression::kTest), |
861 condition_(condition), | 861 condition_(condition), |
862 if_true_(if_true), | 862 if_true_(if_true), |
863 if_false_(if_false) { | 863 if_false_(if_false) { |
864 } | 864 } |
865 | 865 |
866 virtual void ReturnValue(HValue* value) OVERRIDE; | 866 void ReturnValue(HValue* value) OVERRIDE; |
867 virtual void ReturnInstruction(HInstruction* instr, | 867 virtual void ReturnInstruction(HInstruction* instr, |
868 BailoutId ast_id) OVERRIDE; | 868 BailoutId ast_id) OVERRIDE; |
869 virtual void ReturnControl(HControlInstruction* instr, | 869 virtual void ReturnControl(HControlInstruction* instr, |
870 BailoutId ast_id) OVERRIDE; | 870 BailoutId ast_id) OVERRIDE; |
871 virtual void ReturnContinuation(HIfContinuation* continuation, | 871 virtual void ReturnContinuation(HIfContinuation* continuation, |
872 BailoutId ast_id) OVERRIDE; | 872 BailoutId ast_id) OVERRIDE; |
873 | 873 |
874 static TestContext* cast(AstContext* context) { | 874 static TestContext* cast(AstContext* context) { |
875 DCHECK(context->IsTest()); | 875 DCHECK(context->IsTest()); |
876 return reinterpret_cast<TestContext*>(context); | 876 return reinterpret_cast<TestContext*>(context); |
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2101 Scope** scope, int* drop_extra); | 2101 Scope** scope, int* drop_extra); |
2102 | 2102 |
2103 private: | 2103 private: |
2104 BreakAndContinueInfo* info_; | 2104 BreakAndContinueInfo* info_; |
2105 HOptimizedGraphBuilder* owner_; | 2105 HOptimizedGraphBuilder* owner_; |
2106 BreakAndContinueScope* next_; | 2106 BreakAndContinueScope* next_; |
2107 }; | 2107 }; |
2108 | 2108 |
2109 explicit HOptimizedGraphBuilder(CompilationInfo* info); | 2109 explicit HOptimizedGraphBuilder(CompilationInfo* info); |
2110 | 2110 |
2111 virtual bool BuildGraph() OVERRIDE; | 2111 bool BuildGraph() OVERRIDE; |
2112 | 2112 |
2113 // Simple accessors. | 2113 // Simple accessors. |
2114 BreakAndContinueScope* break_scope() const { return break_scope_; } | 2114 BreakAndContinueScope* break_scope() const { return break_scope_; } |
2115 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } | 2115 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } |
2116 | 2116 |
2117 HValue* context() { return environment()->context(); } | 2117 HValue* context() OVERRIDE { return environment()->context(); } |
2118 | 2118 |
2119 HOsrBuilder* osr() const { return osr_; } | 2119 HOsrBuilder* osr() const { return osr_; } |
2120 | 2120 |
2121 void Bailout(BailoutReason reason); | 2121 void Bailout(BailoutReason reason); |
2122 | 2122 |
2123 HBasicBlock* CreateJoin(HBasicBlock* first, | 2123 HBasicBlock* CreateJoin(HBasicBlock* first, |
2124 HBasicBlock* second, | 2124 HBasicBlock* second, |
2125 BailoutId join_id); | 2125 BailoutId join_id); |
2126 | 2126 |
2127 FunctionState* function_state() const { return function_state_; } | 2127 FunctionState* function_state() const { return function_state_; } |
2128 | 2128 |
2129 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 2129 void VisitDeclarations(ZoneList<Declaration*>* declarations) OVERRIDE; |
2130 | 2130 |
2131 void* operator new(size_t size, Zone* zone) { | 2131 void* operator new(size_t size, Zone* zone) { |
2132 return zone->New(static_cast<int>(size)); | 2132 return zone->New(static_cast<int>(size)); |
2133 } | 2133 } |
2134 void operator delete(void* pointer, Zone* zone) { } | 2134 void operator delete(void* pointer, Zone* zone) { } |
2135 void operator delete(void* pointer) { } | 2135 void operator delete(void* pointer) { } |
2136 | 2136 |
2137 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 2137 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
2138 | 2138 |
2139 protected: | 2139 protected: |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2278 // test contexts.) | 2278 // test contexts.) |
2279 void VisitForValue(Expression* expr, | 2279 void VisitForValue(Expression* expr, |
2280 ArgumentsAllowedFlag flag = ARGUMENTS_NOT_ALLOWED); | 2280 ArgumentsAllowedFlag flag = ARGUMENTS_NOT_ALLOWED); |
2281 void VisitForTypeOf(Expression* expr); | 2281 void VisitForTypeOf(Expression* expr); |
2282 void VisitForEffect(Expression* expr); | 2282 void VisitForEffect(Expression* expr); |
2283 void VisitForControl(Expression* expr, | 2283 void VisitForControl(Expression* expr, |
2284 HBasicBlock* true_block, | 2284 HBasicBlock* true_block, |
2285 HBasicBlock* false_block); | 2285 HBasicBlock* false_block); |
2286 | 2286 |
2287 // Visit a list of expressions from left to right, each in a value context. | 2287 // Visit a list of expressions from left to right, each in a value context. |
2288 void VisitExpressions(ZoneList<Expression*>* exprs); | 2288 void VisitExpressions(ZoneList<Expression*>* exprs) OVERRIDE; |
2289 void VisitExpressions(ZoneList<Expression*>* exprs, | 2289 void VisitExpressions(ZoneList<Expression*>* exprs, |
2290 ArgumentsAllowedFlag flag); | 2290 ArgumentsAllowedFlag flag); |
2291 | 2291 |
2292 // Remove the arguments from the bailout environment and emit instructions | 2292 // Remove the arguments from the bailout environment and emit instructions |
2293 // to push them as outgoing parameters. | 2293 // to push them as outgoing parameters. |
2294 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); | 2294 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); |
2295 void PushArgumentsFromEnvironment(int count); | 2295 void PushArgumentsFromEnvironment(int count); |
2296 | 2296 |
2297 void SetUpScope(Scope* scope); | 2297 void SetUpScope(Scope* scope); |
2298 virtual void VisitStatements(ZoneList<Statement*>* statements) OVERRIDE; | 2298 void VisitStatements(ZoneList<Statement*>* statements) OVERRIDE; |
2299 | 2299 |
2300 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) OVERRIDE; | 2300 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) OVERRIDE; |
2301 AST_NODE_LIST(DECLARE_VISIT) | 2301 AST_NODE_LIST(DECLARE_VISIT) |
2302 #undef DECLARE_VISIT | 2302 #undef DECLARE_VISIT |
2303 | 2303 |
2304 Type* ToType(Handle<Map> map); | 2304 Type* ToType(Handle<Map> map); |
2305 | 2305 |
2306 private: | 2306 private: |
2307 // Helpers for flow graph construction. | 2307 // Helpers for flow graph construction. |
2308 enum GlobalPropertyAccess { | 2308 enum GlobalPropertyAccess { |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2942 } | 2942 } |
2943 | 2943 |
2944 private: | 2944 private: |
2945 HGraphBuilder* builder_; | 2945 HGraphBuilder* builder_; |
2946 }; | 2946 }; |
2947 | 2947 |
2948 | 2948 |
2949 } } // namespace v8::internal | 2949 } } // namespace v8::internal |
2950 | 2950 |
2951 #endif // V8_HYDROGEN_H_ | 2951 #endif // V8_HYDROGEN_H_ |
OLD | NEW |