| 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 LoopBuilder; | 16 class LoopBuilder; |
| 17 | 17 |
| 18 class BytecodeGenerator final : public AstVisitor { | 18 class BytecodeGenerator final : public AstVisitor { |
| 19 public: | 19 public: |
| 20 BytecodeGenerator(Isolate* isolate, Zone* zone); | 20 explicit BytecodeGenerator(CompilationInfo* info); |
| 21 | 21 |
| 22 Handle<BytecodeArray> MakeBytecode(CompilationInfo* info); | 22 Handle<BytecodeArray> MakeBytecode(); |
| 23 | 23 |
| 24 #define DECLARE_VISIT(type) void Visit##type(type* node) override; | 24 #define DECLARE_VISIT(type) void Visit##type(type* node) override; |
| 25 AST_NODE_LIST(DECLARE_VISIT) | 25 AST_NODE_LIST(DECLARE_VISIT) |
| 26 #undef DECLARE_VISIT | 26 #undef DECLARE_VISIT |
| 27 | 27 |
| 28 // Visiting function for declarations list and statements are overridden. | 28 // Visiting function for declarations list and statements are overridden. |
| 29 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; | 29 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; |
| 30 void VisitStatements(ZoneList<Statement*>* statments) override; | 30 void VisitStatements(ZoneList<Statement*>* statments) override; |
| 31 | 31 |
| 32 private: | 32 private: |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 Register LoadFromAliasedRegister(Register reg); | 154 Register LoadFromAliasedRegister(Register reg); |
| 155 | 155 |
| 156 // Methods for tracking try-block nesting. | 156 // Methods for tracking try-block nesting. |
| 157 bool IsInsideTryCatch() const { return try_catch_nesting_level_ > 0; } | 157 bool IsInsideTryCatch() const { return try_catch_nesting_level_ > 0; } |
| 158 bool IsInsideTryFinally() const { return try_finally_nesting_level_ > 0; } | 158 bool IsInsideTryFinally() const { return try_finally_nesting_level_ > 0; } |
| 159 | 159 |
| 160 // Initialize an array of temporary registers with consecutive registers. | 160 // Initialize an array of temporary registers with consecutive registers. |
| 161 template <size_t N> | 161 template <size_t N> |
| 162 void InitializeWithConsecutiveRegisters(Register (®isters)[N]); | 162 void InitializeWithConsecutiveRegisters(Register (®isters)[N]); |
| 163 | 163 |
| 164 inline void set_builder(BytecodeArrayBuilder* builder) { builder_ = builder; } | |
| 165 inline BytecodeArrayBuilder* builder() const { return builder_; } | 164 inline BytecodeArrayBuilder* builder() const { return builder_; } |
| 166 | |
| 167 inline Isolate* isolate() const { return isolate_; } | 165 inline Isolate* isolate() const { return isolate_; } |
| 168 inline Zone* zone() const { return zone_; } | 166 inline Zone* zone() const { return zone_; } |
| 169 | |
| 170 inline Scope* scope() const { return scope_; } | 167 inline Scope* scope() const { return scope_; } |
| 171 inline void set_scope(Scope* scope) { scope_ = scope; } | |
| 172 inline CompilationInfo* info() const { return info_; } | 168 inline CompilationInfo* info() const { return info_; } |
| 173 inline void set_info(CompilationInfo* info) { info_ = info; } | |
| 174 | 169 |
| 175 inline ControlScope* execution_control() const { return execution_control_; } | 170 inline ControlScope* execution_control() const { return execution_control_; } |
| 176 inline void set_execution_control(ControlScope* scope) { | 171 inline void set_execution_control(ControlScope* scope) { |
| 177 execution_control_ = scope; | 172 execution_control_ = scope; |
| 178 } | 173 } |
| 179 inline ContextScope* execution_context() const { return execution_context_; } | 174 inline ContextScope* execution_context() const { return execution_context_; } |
| 180 inline void set_execution_context(ContextScope* context) { | 175 inline void set_execution_context(ContextScope* context) { |
| 181 execution_context_ = context; | 176 execution_context_ = context; |
| 182 } | 177 } |
| 183 inline void set_execution_result(ExpressionResultScope* execution_result) { | 178 inline void set_execution_result(ExpressionResultScope* execution_result) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 210 int try_catch_nesting_level_; | 205 int try_catch_nesting_level_; |
| 211 int try_finally_nesting_level_; | 206 int try_finally_nesting_level_; |
| 212 int generator_yields_seen_; | 207 int generator_yields_seen_; |
| 213 }; | 208 }; |
| 214 | 209 |
| 215 } // namespace interpreter | 210 } // namespace interpreter |
| 216 } // namespace internal | 211 } // namespace internal |
| 217 } // namespace v8 | 212 } // namespace v8 |
| 218 | 213 |
| 219 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 214 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
| OLD | NEW |