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 EffectResultScope; |
| 36 class RegisterResultScope; |
33 | 37 |
34 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 38 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
35 | 39 |
36 void VisitArithmeticExpression(BinaryOperation* binop); | 40 void VisitArithmeticExpression(BinaryOperation* binop); |
37 void VisitPropertyLoad(Register obj, Property* expr); | 41 void VisitPropertyLoad(Register obj, Property* expr); |
38 void VisitVariableLoad(Variable* variable, FeedbackVectorSlot slot); | 42 void VisitVariableLoad(Variable* variable, FeedbackVectorSlot slot); |
39 void VisitVariableAssignment(Variable* variable, FeedbackVectorSlot slot); | 43 void VisitVariableAssignment(Variable* variable, FeedbackVectorSlot slot); |
40 | 44 |
41 // Dispatched from VisitUnaryOperation. | 45 // Dispatched from VisitUnaryOperation. |
42 void VisitVoid(UnaryOperation* expr); | 46 void VisitVoid(UnaryOperation* expr); |
43 void VisitTypeOf(UnaryOperation* expr); | 47 void VisitTypeOf(UnaryOperation* expr); |
44 void VisitNot(UnaryOperation* expr); | 48 void VisitNot(UnaryOperation* expr); |
45 | 49 |
| 50 // Visitors for obtaining expression result in the accumulator, in a |
| 51 // register, or just getting the effect. |
| 52 void VisitForAccumulatorValue(Expression* expression); |
| 53 MUST_USE_RESULT Register VisitForRegisterValue( |
| 54 Expression* expression, TemporaryRegisterScope* temporary_register_scope); |
| 55 void VisitForEffect(Expression* node); |
| 56 |
| 57 void SetResultRegister(Register reg); |
| 58 Register GetResultRegister(); |
| 59 bool ResultRegisterIsEmpty() const; |
| 60 |
46 inline BytecodeArrayBuilder* builder() { return &builder_; } | 61 inline BytecodeArrayBuilder* builder() { return &builder_; } |
47 inline Scope* scope() const { return scope_; } | 62 inline Scope* scope() const { return scope_; } |
48 inline void set_scope(Scope* scope) { scope_ = scope; } | 63 inline void set_scope(Scope* scope) { scope_ = scope; } |
49 inline ControlScope* control_scope() const { return control_scope_; } | 64 inline ControlScope* control_scope() const { return control_scope_; } |
50 inline void set_control_scope(ControlScope* scope) { control_scope_ = scope; } | 65 inline void set_control_scope(ControlScope* scope) { control_scope_ = scope; } |
51 inline CompilationInfo* info() const { return info_; } | 66 inline CompilationInfo* info() const { return info_; } |
52 inline void set_info(CompilationInfo* info) { info_ = info; } | 67 inline void set_info(CompilationInfo* info) { info_ = info; } |
53 ZoneVector<Handle<Object>>* globals() { return &globals_; } | 68 ZoneVector<Handle<Object>>* globals() { return &globals_; } |
| 69 inline void set_result_scope(ExpressionResultScope* result_scope) { |
| 70 result_scope_ = result_scope; |
| 71 } |
| 72 inline ExpressionResultScope* result_scope() const { return result_scope_; } |
54 | 73 |
55 LanguageMode language_mode() const; | 74 LanguageMode language_mode() const; |
56 Strength language_mode_strength() const; | 75 Strength language_mode_strength() const; |
57 int feedback_index(FeedbackVectorSlot slot) const; | 76 int feedback_index(FeedbackVectorSlot slot) const; |
58 Register current_context() const; | 77 Register current_context() const; |
59 | 78 |
60 BytecodeArrayBuilder builder_; | 79 BytecodeArrayBuilder builder_; |
61 CompilationInfo* info_; | 80 CompilationInfo* info_; |
62 Scope* scope_; | 81 Scope* scope_; |
63 ZoneVector<Handle<Object>> globals_; | 82 ZoneVector<Handle<Object>> globals_; |
64 ControlScope* control_scope_; | 83 ControlScope* control_scope_; |
65 | 84 |
66 // TODO(rmcilroy): Encapsulate this in an environment object. | 85 // TODO(rmcilroy): Encapsulate this in an environment object. |
67 Register current_context_; | 86 Register current_context_; |
| 87 ExpressionResultScope* result_scope_; |
| 88 Maybe<Register> result_register_; |
68 }; | 89 }; |
69 | 90 |
70 } // namespace interpreter | 91 } // namespace interpreter |
71 } // namespace internal | 92 } // namespace internal |
72 } // namespace v8 | 93 } // namespace v8 |
73 | 94 |
74 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 95 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
OLD | NEW |