Chromium Code Reviews| 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.h" | 8 #include "src/ast.h" |
| 9 #include "src/interpreter/bytecode-array-builder.h" | 9 #include "src/interpreter/bytecode-array-builder.h" |
| 10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #define DECLARE_VISIT(type) void Visit##type(type* node) override; | 23 #define DECLARE_VISIT(type) void Visit##type(type* node) override; |
| 24 AST_NODE_LIST(DECLARE_VISIT) | 24 AST_NODE_LIST(DECLARE_VISIT) |
| 25 #undef DECLARE_VISIT | 25 #undef DECLARE_VISIT |
| 26 | 26 |
| 27 // Visiting function for declarations list is overridden. | 27 // Visiting function for declarations list is overridden. |
| 28 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; | 28 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 class ControlScope; | 31 class ControlScope; |
| 32 class ControlScopeForIteration; | 32 class ControlScopeForIteration; |
| 33 class ExpressionResultScope; | |
| 34 class AccumulatorResultScope; | |
| 35 class RegisterResultScope; | |
| 33 | 36 |
| 34 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 37 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 35 | 38 |
| 36 void VisitArithmeticExpression(BinaryOperation* binop); | 39 void VisitArithmeticExpression(BinaryOperation* binop); |
| 37 void VisitPropertyLoad(Register obj, Property* expr); | 40 void VisitPropertyLoad(Register obj, Property* expr); |
| 38 void VisitVariableLoad(Variable* variable, FeedbackVectorSlot slot); | 41 void VisitVariableLoad(Variable* variable, FeedbackVectorSlot slot); |
| 39 void VisitVariableAssignment(Variable* variable, FeedbackVectorSlot slot); | 42 void VisitVariableAssignment(Variable* variable, FeedbackVectorSlot slot); |
| 40 | 43 |
| 41 // Dispatched from VisitUnaryOperation. | 44 // Dispatched from VisitUnaryOperation. |
| 42 void VisitVoid(UnaryOperation* expr); | 45 void VisitVoid(UnaryOperation* expr); |
| 43 void VisitTypeOf(UnaryOperation* expr); | 46 void VisitTypeOf(UnaryOperation* expr); |
| 44 void VisitNot(UnaryOperation* expr); | 47 void VisitNot(UnaryOperation* expr); |
| 45 | 48 |
| 49 void VisitForAccumulatorValue(Expression* expression); | |
|
rmcilroy
2015/10/08 16:54:26
Could we have some comments on when these are expe
oth
2015/10/09 12:50:48
Done.
| |
| 50 void VisitForRegisterValue(Expression* expression, | |
|
rmcilroy
2015/10/08 16:54:26
Could VisitForRegisterValue just return the Regist
oth
2015/10/09 12:50:48
Done.
rmcilroy
2015/10/09 13:02:56
What did you think of storing the register in the
| |
| 51 TemporaryRegisterScope* temporary_register_scope); | |
| 52 MUST_USE_RESULT Register GetResultRegister(); | |
| 53 void DropResultRegister(); | |
|
rmcilroy
2015/10/08 16:54:26
Doesn't look like this is necessary as a seperate
oth
2015/10/09 12:50:48
Done. Right there was an intermediate step that al
| |
| 54 void SetResultRegister(Register reg); | |
| 55 | |
| 46 inline BytecodeArrayBuilder* builder() { return &builder_; } | 56 inline BytecodeArrayBuilder* builder() { return &builder_; } |
| 47 inline Scope* scope() const { return scope_; } | 57 inline Scope* scope() const { return scope_; } |
| 48 inline void set_scope(Scope* scope) { scope_ = scope; } | 58 inline void set_scope(Scope* scope) { scope_ = scope; } |
| 49 inline ControlScope* control_scope() const { return control_scope_; } | 59 inline ControlScope* control_scope() const { return control_scope_; } |
| 50 inline void set_control_scope(ControlScope* scope) { control_scope_ = scope; } | 60 inline void set_control_scope(ControlScope* scope) { control_scope_ = scope; } |
| 51 inline CompilationInfo* info() const { return info_; } | 61 inline CompilationInfo* info() const { return info_; } |
| 52 inline void set_info(CompilationInfo* info) { info_ = info; } | 62 inline void set_info(CompilationInfo* info) { info_ = info; } |
| 53 ZoneVector<Handle<Object>>* globals() { return &globals_; } | 63 ZoneVector<Handle<Object>>* globals() { return &globals_; } |
| 64 inline void set_result_scope(ExpressionResultScope* result_scope) { | |
| 65 result_scope_ = result_scope; | |
| 66 } | |
| 67 inline ExpressionResultScope* result_scope() const { | |
| 68 return result_scope_; | |
| 69 } | |
| 54 | 70 |
| 55 LanguageMode language_mode() const; | 71 LanguageMode language_mode() const; |
| 56 Strength language_mode_strength() const; | 72 Strength language_mode_strength() const; |
| 57 int feedback_index(FeedbackVectorSlot slot) const; | 73 int feedback_index(FeedbackVectorSlot slot) const; |
| 58 Register current_context() const; | 74 Register current_context() const; |
| 59 | 75 |
| 60 BytecodeArrayBuilder builder_; | 76 BytecodeArrayBuilder builder_; |
| 61 CompilationInfo* info_; | 77 CompilationInfo* info_; |
| 62 Scope* scope_; | 78 Scope* scope_; |
| 63 ZoneVector<Handle<Object>> globals_; | 79 ZoneVector<Handle<Object>> globals_; |
| 64 ControlScope* control_scope_; | 80 ControlScope* control_scope_; |
| 65 | 81 |
| 66 // TODO(rmcilroy): Encapsulate this in an environment object. | 82 // TODO(rmcilroy): Encapsulate this in an environment object. |
| 67 Register current_context_; | 83 Register current_context_; |
| 84 ExpressionResultScope* result_scope_; | |
| 85 Maybe<Register> result_register_; | |
| 68 }; | 86 }; |
| 69 | 87 |
| 70 } // namespace interpreter | 88 } // namespace interpreter |
| 71 } // namespace internal | 89 } // namespace internal |
| 72 } // namespace v8 | 90 } // namespace v8 |
| 73 | 91 |
| 74 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 92 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
| OLD | NEW |