| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_INTERPRETER_BYTECODE_GENERATOR_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
| 6 #define V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 6 #define V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
| 7 | 7 |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/interpreter/bytecode-array-builder.h" | 9 #include "src/interpreter/bytecode-array-builder.h" |
| 10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 namespace interpreter { | 14 namespace interpreter { |
| 15 | 15 |
| 16 class BytecodeGenerator final : public AstVisitor { | 16 class BytecodeGenerator final : public AstVisitor { |
| 17 public: | 17 public: |
| 18 BytecodeGenerator(Isolate* isolate, Zone* zone); | 18 BytecodeGenerator(Isolate* isolate, Zone* zone); |
| 19 | 19 |
| 20 Handle<BytecodeArray> MakeBytecode(CompilationInfo* info); | 20 Handle<BytecodeArray> MakeBytecode(CompilationInfo* info); |
| 21 | 21 |
| 22 #define DECLARE_VISIT(type) void Visit##type(type* node) override; | 22 #define DECLARE_VISIT(type) void Visit##type(type* node) override; |
| 23 AST_NODE_LIST(DECLARE_VISIT) | 23 AST_NODE_LIST(DECLARE_VISIT) |
| 24 #undef DECLARE_VISIT | 24 #undef DECLARE_VISIT |
| 25 | 25 |
| 26 // Visiting function for declarations list is overridden. | 26 // Visiting function for declarations list and statements are overridden. |
| 27 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; | 27 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; |
| 28 void VisitStatements(ZoneList<Statement*>* statments) override; |
| 28 | 29 |
| 29 private: | 30 private: |
| 30 class ContextScope; | 31 class ContextScope; |
| 31 class ControlScope; | 32 class ControlScope; |
| 32 class ControlScopeForBreakable; | 33 class ControlScopeForBreakable; |
| 33 class ControlScopeForIteration; | 34 class ControlScopeForIteration; |
| 34 class ExpressionResultScope; | 35 class ExpressionResultScope; |
| 35 class EffectResultScope; | 36 class EffectResultScope; |
| 36 class AccumulatorResultScope; | 37 class AccumulatorResultScope; |
| 37 class RegisterResultScope; | 38 class RegisterResultScope; |
| 39 class RegisterAllocationScope; |
| 38 | 40 |
| 39 void MakeBytecodeBody(); | 41 void MakeBytecodeBody(); |
| 40 Register NextContextRegister() const; | 42 Register NextContextRegister() const; |
| 41 | 43 |
| 42 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 44 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 43 | 45 |
| 44 // Dispatched from VisitBinaryOperation. | 46 // Dispatched from VisitBinaryOperation. |
| 45 void VisitArithmeticExpression(BinaryOperation* binop); | 47 void VisitArithmeticExpression(BinaryOperation* binop); |
| 46 void VisitCommaExpression(BinaryOperation* binop); | 48 void VisitCommaExpression(BinaryOperation* binop); |
| 47 void VisitLogicalOrExpression(BinaryOperation* binop); | 49 void VisitLogicalOrExpression(BinaryOperation* binop); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 execution_control_ = scope; | 113 execution_control_ = scope; |
| 112 } | 114 } |
| 113 inline ContextScope* execution_context() const { return execution_context_; } | 115 inline ContextScope* execution_context() const { return execution_context_; } |
| 114 inline void set_execution_context(ContextScope* context) { | 116 inline void set_execution_context(ContextScope* context) { |
| 115 execution_context_ = context; | 117 execution_context_ = context; |
| 116 } | 118 } |
| 117 inline void set_execution_result(ExpressionResultScope* execution_result) { | 119 inline void set_execution_result(ExpressionResultScope* execution_result) { |
| 118 execution_result_ = execution_result; | 120 execution_result_ = execution_result; |
| 119 } | 121 } |
| 120 ExpressionResultScope* execution_result() const { return execution_result_; } | 122 ExpressionResultScope* execution_result() const { return execution_result_; } |
| 123 inline void set_register_allocator( |
| 124 RegisterAllocationScope* register_allocator) { |
| 125 register_allocator_ = register_allocator; |
| 126 } |
| 127 RegisterAllocationScope* register_allocator() const { |
| 128 return register_allocator_; |
| 129 } |
| 121 | 130 |
| 122 ZoneVector<Handle<Object>>* globals() { return &globals_; } | 131 ZoneVector<Handle<Object>>* globals() { return &globals_; } |
| 123 inline LanguageMode language_mode() const; | 132 inline LanguageMode language_mode() const; |
| 124 Strength language_mode_strength() const; | 133 Strength language_mode_strength() const; |
| 125 int feedback_index(FeedbackVectorSlot slot) const; | 134 int feedback_index(FeedbackVectorSlot slot) const; |
| 126 | 135 |
| 127 Isolate* isolate_; | 136 Isolate* isolate_; |
| 128 Zone* zone_; | 137 Zone* zone_; |
| 129 BytecodeArrayBuilder builder_; | 138 BytecodeArrayBuilder builder_; |
| 130 CompilationInfo* info_; | 139 CompilationInfo* info_; |
| 131 Scope* scope_; | 140 Scope* scope_; |
| 132 ZoneVector<Handle<Object>> globals_; | 141 ZoneVector<Handle<Object>> globals_; |
| 133 ControlScope* execution_control_; | 142 ControlScope* execution_control_; |
| 134 ContextScope* execution_context_; | 143 ContextScope* execution_context_; |
| 135 ExpressionResultScope* execution_result_; | 144 ExpressionResultScope* execution_result_; |
| 145 RegisterAllocationScope* register_allocator_; |
| 136 }; | 146 }; |
| 137 | 147 |
| 138 } // namespace interpreter | 148 } // namespace interpreter |
| 139 } // namespace internal | 149 } // namespace internal |
| 140 } // namespace v8 | 150 } // namespace v8 |
| 141 | 151 |
| 142 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 152 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
| OLD | NEW |