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 LazyCompilationMode; | |
19 | 18 |
20 namespace interpreter { | 19 namespace interpreter { |
21 | 20 |
22 class LoopBuilder; | 21 class LoopBuilder; |
23 | 22 |
24 class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> { | 23 class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> { |
25 public: | 24 public: |
26 BytecodeGenerator(CompilationInfo* info, LazyCompilationMode mode); | 25 explicit BytecodeGenerator(CompilationInfo* info); |
27 | 26 |
28 void GenerateBytecode(uintptr_t stack_limit); | 27 void GenerateBytecode(uintptr_t stack_limit); |
29 Handle<BytecodeArray> FinalizeBytecode(Isolate* isolate); | 28 Handle<BytecodeArray> FinalizeBytecode(Isolate* isolate); |
30 | 29 |
31 #define DECLARE_VISIT(type) void Visit##type(type* node); | 30 #define DECLARE_VISIT(type) void Visit##type(type* node); |
32 AST_NODE_LIST(DECLARE_VISIT) | 31 AST_NODE_LIST(DECLARE_VISIT) |
33 #undef DECLARE_VISIT | 32 #undef DECLARE_VISIT |
34 | 33 |
35 // Visiting function for declarations list and statements are overridden. | 34 // Visiting function for declarations list and statements are overridden. |
36 void VisitDeclarations(Declaration::List* declarations); | 35 void VisitDeclarations(Declaration::List* declarations); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 Handle<Name> home_object_symbol() const { return home_object_symbol_; } | 197 Handle<Name> home_object_symbol() const { return home_object_symbol_; } |
199 Handle<Name> iterator_symbol() const { return iterator_symbol_; } | 198 Handle<Name> iterator_symbol() const { return iterator_symbol_; } |
200 Handle<Name> prototype_string() const { return prototype_string_; } | 199 Handle<Name> prototype_string() const { return prototype_string_; } |
201 Handle<FixedArray> empty_fixed_array() const { return empty_fixed_array_; } | 200 Handle<FixedArray> empty_fixed_array() const { return empty_fixed_array_; } |
202 const AstRawString* undefined_string() const { return undefined_string_; } | 201 const AstRawString* undefined_string() const { return undefined_string_; } |
203 | 202 |
204 Zone* zone_; | 203 Zone* zone_; |
205 BytecodeArrayBuilder* builder_; | 204 BytecodeArrayBuilder* builder_; |
206 CompilationInfo* info_; | 205 CompilationInfo* info_; |
207 DeclarationScope* scope_; | 206 DeclarationScope* scope_; |
208 LazyCompilationMode compilation_mode_; | |
209 | 207 |
210 GlobalDeclarationsBuilder* globals_builder_; | 208 GlobalDeclarationsBuilder* globals_builder_; |
211 ZoneVector<GlobalDeclarationsBuilder*> global_declarations_; | 209 ZoneVector<GlobalDeclarationsBuilder*> global_declarations_; |
212 ZoneVector<std::pair<FunctionLiteral*, size_t>> function_literals_; | 210 ZoneVector<std::pair<FunctionLiteral*, size_t>> function_literals_; |
213 ZoneVector<std::pair<NativeFunctionLiteral*, size_t>> | 211 ZoneVector<std::pair<NativeFunctionLiteral*, size_t>> |
214 native_function_literals_; | 212 native_function_literals_; |
215 | 213 |
216 ControlScope* execution_control_; | 214 ControlScope* execution_control_; |
217 ContextScope* execution_context_; | 215 ContextScope* execution_context_; |
218 ExpressionResultScope* execution_result_; | 216 ExpressionResultScope* execution_result_; |
219 | 217 |
220 ZoneVector<BytecodeLabel> generator_resume_points_; | 218 ZoneVector<BytecodeLabel> generator_resume_points_; |
221 Register generator_state_; | 219 Register generator_state_; |
222 int loop_depth_; | 220 int loop_depth_; |
223 | 221 |
224 Handle<Name> home_object_symbol_; | 222 Handle<Name> home_object_symbol_; |
225 Handle<Name> iterator_symbol_; | 223 Handle<Name> iterator_symbol_; |
226 Handle<Name> prototype_string_; | 224 Handle<Name> prototype_string_; |
227 Handle<FixedArray> empty_fixed_array_; | 225 Handle<FixedArray> empty_fixed_array_; |
228 const AstRawString* undefined_string_; | 226 const AstRawString* undefined_string_; |
229 }; | 227 }; |
230 | 228 |
231 } // namespace interpreter | 229 } // namespace interpreter |
232 } // namespace internal | 230 } // namespace internal |
233 } // namespace v8 | 231 } // namespace v8 |
234 | 232 |
235 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 233 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
OLD | NEW |