| 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" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 Handle<BytecodeArray> MakeBytecode(); | 27 Handle<BytecodeArray> MakeBytecode(); |
| 28 | 28 |
| 29 #define DECLARE_VISIT(type) void Visit##type(type* node); | 29 #define DECLARE_VISIT(type) void Visit##type(type* node); |
| 30 AST_NODE_LIST(DECLARE_VISIT) | 30 AST_NODE_LIST(DECLARE_VISIT) |
| 31 #undef DECLARE_VISIT | 31 #undef DECLARE_VISIT |
| 32 | 32 |
| 33 // Visiting function for declarations list and statements are overridden. | 33 // Visiting function for declarations list and statements are overridden. |
| 34 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 34 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 35 void VisitStatements(ZoneList<Statement*>* statments); | 35 void VisitStatements(ZoneList<Statement*>* statments); |
| 36 | 36 |
| 37 void set_isolate_access_allowed(bool isolate_access_allowed) { |
| 38 isolate_access_allowed_ = isolate_access_allowed; |
| 39 } |
| 40 bool isolate_access_allowed() { return isolate_access_allowed_; } |
| 41 |
| 37 private: | 42 private: |
| 38 class AccumulatorResultScope; | 43 class AccumulatorResultScope; |
| 39 class ContextScope; | 44 class ContextScope; |
| 40 class ControlScope; | 45 class ControlScope; |
| 41 class ControlScopeForBreakable; | 46 class ControlScopeForBreakable; |
| 42 class ControlScopeForIteration; | 47 class ControlScopeForIteration; |
| 43 class ControlScopeForTopLevel; | 48 class ControlScopeForTopLevel; |
| 44 class ControlScopeForTryCatch; | 49 class ControlScopeForTryCatch; |
| 45 class ControlScopeForTryFinally; | 50 class ControlScopeForTryFinally; |
| 46 class ExpressionResultScope; | 51 class ExpressionResultScope; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 175 |
| 171 // Methods for tracking and remapping register. | 176 // Methods for tracking and remapping register. |
| 172 void RecordStoreToRegister(Register reg); | 177 void RecordStoreToRegister(Register reg); |
| 173 Register LoadFromAliasedRegister(Register reg); | 178 Register LoadFromAliasedRegister(Register reg); |
| 174 | 179 |
| 175 // Initialize an array of temporary registers with consecutive registers. | 180 // Initialize an array of temporary registers with consecutive registers. |
| 176 template <size_t N> | 181 template <size_t N> |
| 177 void InitializeWithConsecutiveRegisters(Register (®isters)[N]); | 182 void InitializeWithConsecutiveRegisters(Register (®isters)[N]); |
| 178 | 183 |
| 179 inline BytecodeArrayBuilder* builder() const { return builder_; } | 184 inline BytecodeArrayBuilder* builder() const { return builder_; } |
| 180 inline Isolate* isolate() const { return isolate_; } | 185 inline Isolate* isolate() const { |
| 186 DCHECK(isolate_access_allowed_); |
| 187 return isolate_; |
| 188 } |
| 181 inline Zone* zone() const { return zone_; } | 189 inline Zone* zone() const { return zone_; } |
| 182 inline DeclarationScope* scope() const { return scope_; } | 190 inline DeclarationScope* scope() const { return scope_; } |
| 183 inline CompilationInfo* info() const { return info_; } | 191 inline CompilationInfo* info() const { return info_; } |
| 184 | 192 |
| 185 inline ControlScope* execution_control() const { return execution_control_; } | 193 inline ControlScope* execution_control() const { return execution_control_; } |
| 186 inline void set_execution_control(ControlScope* scope) { | 194 inline void set_execution_control(ControlScope* scope) { |
| 187 execution_control_ = scope; | 195 execution_control_ = scope; |
| 188 } | 196 } |
| 189 inline ContextScope* execution_context() const { return execution_context_; } | 197 inline ContextScope* execution_context() const { return execution_context_; } |
| 190 inline void set_execution_context(ContextScope* context) { | 198 inline void set_execution_context(ContextScope* context) { |
| 191 execution_context_ = context; | 199 execution_context_ = context; |
| 192 } | 200 } |
| 193 inline void set_execution_result(ExpressionResultScope* execution_result) { | 201 inline void set_execution_result(ExpressionResultScope* execution_result) { |
| 194 execution_result_ = execution_result; | 202 execution_result_ = execution_result; |
| 195 } | 203 } |
| 196 ExpressionResultScope* execution_result() const { return execution_result_; } | 204 ExpressionResultScope* execution_result() const { return execution_result_; } |
| 197 inline void set_register_allocator( | 205 inline void set_register_allocator( |
| 198 RegisterAllocationScope* register_allocator) { | 206 RegisterAllocationScope* register_allocator) { |
| 199 register_allocator_ = register_allocator; | 207 register_allocator_ = register_allocator; |
| 200 } | 208 } |
| 201 RegisterAllocationScope* register_allocator() const { | 209 RegisterAllocationScope* register_allocator() const { |
| 202 return register_allocator_; | 210 return register_allocator_; |
| 203 } | 211 } |
| 204 | 212 |
| 205 GlobalDeclarationsBuilder* globals_builder() { return globals_builder_; } | 213 GlobalDeclarationsBuilder* globals_builder() { return globals_builder_; } |
| 206 inline LanguageMode language_mode() const; | 214 inline LanguageMode language_mode() const; |
| 207 int feedback_index(FeedbackVectorSlot slot) const; | 215 int feedback_index(FeedbackVectorSlot slot) const; |
| 208 | 216 |
| 217 Handle<Name> home_object_symbol() const { return home_object_symbol_; } |
| 218 Handle<Name> prototype_string() const { return prototype_string_; } |
| 219 |
| 209 Isolate* isolate_; | 220 Isolate* isolate_; |
| 210 Zone* zone_; | 221 Zone* zone_; |
| 211 BytecodeArrayBuilder* builder_; | 222 BytecodeArrayBuilder* builder_; |
| 212 CompilationInfo* info_; | 223 CompilationInfo* info_; |
| 213 DeclarationScope* scope_; | 224 DeclarationScope* scope_; |
| 225 bool isolate_access_allowed_; |
| 226 |
| 214 GlobalDeclarationsBuilder* globals_builder_; | 227 GlobalDeclarationsBuilder* globals_builder_; |
| 215 ZoneVector<GlobalDeclarationsBuilder*> global_declarations_; | 228 ZoneVector<GlobalDeclarationsBuilder*> global_declarations_; |
| 216 ZoneVector<std::pair<FunctionLiteral*, size_t>> function_literals_; | 229 ZoneVector<std::pair<FunctionLiteral*, size_t>> function_literals_; |
| 217 ZoneVector<std::pair<NativeFunctionLiteral*, size_t>> | 230 ZoneVector<std::pair<NativeFunctionLiteral*, size_t>> |
| 218 native_function_literals_; | 231 native_function_literals_; |
| 232 |
| 219 ControlScope* execution_control_; | 233 ControlScope* execution_control_; |
| 220 ContextScope* execution_context_; | 234 ContextScope* execution_context_; |
| 221 ExpressionResultScope* execution_result_; | 235 ExpressionResultScope* execution_result_; |
| 222 RegisterAllocationScope* register_allocator_; | 236 RegisterAllocationScope* register_allocator_; |
| 237 |
| 223 ZoneVector<BytecodeLabel> generator_resume_points_; | 238 ZoneVector<BytecodeLabel> generator_resume_points_; |
| 224 Register generator_state_; | 239 Register generator_state_; |
| 225 int loop_depth_; | 240 int loop_depth_; |
| 241 |
| 242 Handle<Name> home_object_symbol_; |
| 243 Handle<Name> prototype_string_; |
| 226 }; | 244 }; |
| 227 | 245 |
| 228 } // namespace interpreter | 246 } // namespace interpreter |
| 229 } // namespace internal | 247 } // namespace internal |
| 230 } // namespace v8 | 248 } // namespace v8 |
| 231 | 249 |
| 232 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 250 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
| OLD | NEW |