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 | 18 |
19 namespace interpreter { | 19 namespace interpreter { |
20 | 20 |
21 class LoopBuilder; | 21 class LoopBuilder; |
22 | 22 |
23 class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> { | 23 class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> { |
24 public: | 24 public: |
25 explicit BytecodeGenerator(CompilationInfo* info); | 25 explicit BytecodeGenerator(CompilationInfo* info); |
26 | 26 |
27 void GenerateBytecode(); | 27 Handle<BytecodeArray> MakeBytecode(); |
28 Handle<BytecodeArray> FinalizeBytecode(); | |
29 | 28 |
30 #define DECLARE_VISIT(type) void Visit##type(type* node); | 29 #define DECLARE_VISIT(type) void Visit##type(type* node); |
31 AST_NODE_LIST(DECLARE_VISIT) | 30 AST_NODE_LIST(DECLARE_VISIT) |
32 #undef DECLARE_VISIT | 31 #undef DECLARE_VISIT |
33 | 32 |
34 // Visiting function for declarations list and statements are overridden. | 33 // Visiting function for declarations list and statements are overridden. |
35 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 34 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
36 void VisitStatements(ZoneList<Statement*>* statments); | 35 void VisitStatements(ZoneList<Statement*>* statments); |
37 | 36 |
38 private: | 37 private: |
39 class AccumulatorResultScope; | 38 class AccumulatorResultScope; |
40 class ContextScope; | 39 class ContextScope; |
41 class ControlScope; | 40 class ControlScope; |
42 class ControlScopeForBreakable; | 41 class ControlScopeForBreakable; |
43 class ControlScopeForIteration; | 42 class ControlScopeForIteration; |
44 class ControlScopeForTopLevel; | 43 class ControlScopeForTopLevel; |
45 class ControlScopeForTryCatch; | 44 class ControlScopeForTryCatch; |
46 class ControlScopeForTryFinally; | 45 class ControlScopeForTryFinally; |
47 class ExpressionResultScope; | 46 class ExpressionResultScope; |
48 class EffectResultScope; | 47 class EffectResultScope; |
49 class GlobalDeclarationsBuilder; | 48 class GlobalDeclarationsBuilder; |
50 class RegisterResultScope; | 49 class RegisterResultScope; |
51 class RegisterAllocationScope; | 50 class RegisterAllocationScope; |
52 class TestResultScope; | 51 class TestResultScope; |
53 | 52 |
54 enum class TestFallthrough { kThen, kElse, kNone }; | 53 enum class TestFallthrough { kThen, kElse, kNone }; |
55 | 54 |
| 55 void GenerateBytecode(); |
56 void GenerateBytecodeBody(); | 56 void GenerateBytecodeBody(); |
57 void AllocateDeferredConstants(); | 57 void FinalizeBytecode(); |
58 | 58 |
59 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 59 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
60 | 60 |
61 // Dispatched from VisitBinaryOperation. | 61 // Dispatched from VisitBinaryOperation. |
62 void VisitArithmeticExpression(BinaryOperation* binop); | 62 void VisitArithmeticExpression(BinaryOperation* binop); |
63 void VisitCommaExpression(BinaryOperation* binop); | 63 void VisitCommaExpression(BinaryOperation* binop); |
64 void VisitLogicalOrExpression(BinaryOperation* binop); | 64 void VisitLogicalOrExpression(BinaryOperation* binop); |
65 void VisitLogicalAndExpression(BinaryOperation* binop); | 65 void VisitLogicalAndExpression(BinaryOperation* binop); |
66 | 66 |
67 // Dispatched from VisitUnaryOperation. | 67 // Dispatched from VisitUnaryOperation. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 ZoneVector<BytecodeLabel> generator_resume_points_; | 223 ZoneVector<BytecodeLabel> generator_resume_points_; |
224 Register generator_state_; | 224 Register generator_state_; |
225 int loop_depth_; | 225 int loop_depth_; |
226 }; | 226 }; |
227 | 227 |
228 } // namespace interpreter | 228 } // namespace interpreter |
229 } // namespace internal | 229 } // namespace internal |
230 } // namespace v8 | 230 } // namespace v8 |
231 | 231 |
232 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 232 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
OLD | NEW |