| 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/bytecode-label.h" | 10 #include "src/interpreter/bytecode-label.h" |
| 11 #include "src/interpreter/bytecode-register.h" | 11 #include "src/interpreter/bytecode-register.h" |
| 12 #include "src/interpreter/bytecodes.h" | 12 #include "src/interpreter/bytecodes.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 class CompilationInfo; | 17 class CompilationInfo; |
| 18 enum class ShouldCompile; |
| 18 | 19 |
| 19 namespace interpreter { | 20 namespace interpreter { |
| 20 | 21 |
| 21 class LoopBuilder; | 22 class LoopBuilder; |
| 22 | 23 |
| 23 class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> { | 24 class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> { |
| 24 public: | 25 public: |
| 25 explicit BytecodeGenerator(CompilationInfo* info); | 26 explicit BytecodeGenerator(CompilationInfo* info); |
| 26 | 27 |
| 27 void GenerateBytecode(uintptr_t stack_limit); | 28 void GenerateBytecode(uintptr_t stack_limit); |
| 28 Handle<BytecodeArray> FinalizeBytecode(Isolate* isolate); | 29 Handle<BytecodeArray> FinalizeBytecode(Isolate* isolate, |
| 30 ShouldCompile should_compile); |
| 29 | 31 |
| 30 #define DECLARE_VISIT(type) void Visit##type(type* node); | 32 #define DECLARE_VISIT(type) void Visit##type(type* node); |
| 31 AST_NODE_LIST(DECLARE_VISIT) | 33 AST_NODE_LIST(DECLARE_VISIT) |
| 32 #undef DECLARE_VISIT | 34 #undef DECLARE_VISIT |
| 33 | 35 |
| 34 // Visiting function for declarations list and statements are overridden. | 36 // Visiting function for declarations list and statements are overridden. |
| 35 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 37 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 36 void VisitStatements(ZoneList<Statement*>* statments); | 38 void VisitStatements(ZoneList<Statement*>* statments); |
| 37 | 39 |
| 38 private: | 40 private: |
| 39 class ContextScope; | 41 class ContextScope; |
| 40 class ControlScope; | 42 class ControlScope; |
| 41 class ControlScopeForBreakable; | 43 class ControlScopeForBreakable; |
| 42 class ControlScopeForIteration; | 44 class ControlScopeForIteration; |
| 43 class ControlScopeForTopLevel; | 45 class ControlScopeForTopLevel; |
| 44 class ControlScopeForTryCatch; | 46 class ControlScopeForTryCatch; |
| 45 class ControlScopeForTryFinally; | 47 class ControlScopeForTryFinally; |
| 46 class ExpressionResultScope; | 48 class ExpressionResultScope; |
| 47 class EffectResultScope; | 49 class EffectResultScope; |
| 48 class GlobalDeclarationsBuilder; | 50 class GlobalDeclarationsBuilder; |
| 49 class RegisterAllocationScope; | 51 class RegisterAllocationScope; |
| 50 class TestResultScope; | 52 class TestResultScope; |
| 51 class ValueResultScope; | 53 class ValueResultScope; |
| 52 | 54 |
| 53 enum class TestFallthrough { kThen, kElse, kNone }; | 55 enum class TestFallthrough { kThen, kElse, kNone }; |
| 54 | 56 |
| 55 void GenerateBytecodeBody(); | 57 void GenerateBytecodeBody(); |
| 56 void AllocateDeferredConstants(); | 58 void AllocateDeferredConstants(ShouldCompile should_compile); |
| 57 | 59 |
| 58 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 60 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 59 | 61 |
| 60 // Dispatched from VisitBinaryOperation. | 62 // Dispatched from VisitBinaryOperation. |
| 61 void VisitArithmeticExpression(BinaryOperation* binop); | 63 void VisitArithmeticExpression(BinaryOperation* binop); |
| 62 void VisitCommaExpression(BinaryOperation* binop); | 64 void VisitCommaExpression(BinaryOperation* binop); |
| 63 void VisitLogicalOrExpression(BinaryOperation* binop); | 65 void VisitLogicalOrExpression(BinaryOperation* binop); |
| 64 void VisitLogicalAndExpression(BinaryOperation* binop); | 66 void VisitLogicalAndExpression(BinaryOperation* binop); |
| 65 | 67 |
| 66 // Dispatched from VisitUnaryOperation. | 68 // Dispatched from VisitUnaryOperation. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 219 |
| 218 Handle<Name> home_object_symbol_; | 220 Handle<Name> home_object_symbol_; |
| 219 Handle<Name> prototype_string_; | 221 Handle<Name> prototype_string_; |
| 220 }; | 222 }; |
| 221 | 223 |
| 222 } // namespace interpreter | 224 } // namespace interpreter |
| 223 } // namespace internal | 225 } // namespace internal |
| 224 } // namespace v8 | 226 } // namespace v8 |
| 225 | 227 |
| 226 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 228 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
| OLD | NEW |