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