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 13 matching lines...) Expand all Loading... | |
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 ContextScope; | 31 class ContextScope; |
32 class ControlScope; | 32 class ControlScope; |
33 class ControlScopeForIteration; | 33 class ControlScopeForIteration; |
34 class ExpressionResultScope; | |
35 class TopLevelResultScope; | |
36 class AccumulatorResultScope; | |
37 class EffectResultScope; | |
38 class RegisterResultScope; | |
34 | 39 |
35 void MakeBytecodeBody(); | 40 void MakeBytecodeBody(); |
36 Register NextContextRegister() const; | 41 Register NextContextRegister() const; |
37 | 42 |
38 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 43 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
39 | 44 |
40 Register VisitArguments(ZoneList<Expression*>* arguments, | 45 Register VisitArguments(ZoneList<Expression*>* arguments); |
41 TemporaryRegisterScope* caller_scope); | |
42 void VisitArithmeticExpression(BinaryOperation* binop); | 46 void VisitArithmeticExpression(BinaryOperation* binop); |
43 void VisitCommaExpression(BinaryOperation* binop); | 47 void VisitCommaExpression(BinaryOperation* binop); |
44 void VisitLogicalOrExpression(BinaryOperation* binop); | 48 void VisitLogicalOrExpression(BinaryOperation* binop); |
45 void VisitLogicalAndExpression(BinaryOperation* binop); | 49 void VisitLogicalAndExpression(BinaryOperation* binop); |
46 void VisitPropertyLoad(Register obj, Property* expr); | 50 void VisitPropertyLoad(Register obj, Property* expr); |
47 void VisitVariableLoad(Variable* variable, FeedbackVectorSlot slot); | 51 void VisitVariableLoad(Variable* variable, FeedbackVectorSlot slot); |
48 void VisitVariableAssignment(Variable* variable, FeedbackVectorSlot slot); | 52 void VisitVariableAssignment(Variable* variable, FeedbackVectorSlot slot); |
49 void VisitNewLocalFunctionContext(); | 53 void VisitNewLocalFunctionContext(); |
50 void VisitBuildLocalActivationContext(); | 54 void VisitBuildLocalActivationContext(); |
51 void VisitNewLocalBlockContext(Scope* scope); | 55 void VisitNewLocalBlockContext(Scope* scope); |
52 void VisitFunctionClosureForContext(); | 56 void VisitFunctionClosureForContext(); |
53 void VisitSetHomeObject(Register value, Register home_object, | 57 void VisitSetHomeObject(Register value, Register home_object, |
54 ObjectLiteralProperty* property, int slot_number = 0); | 58 ObjectLiteralProperty* property, int slot_number = 0); |
55 void VisitObjectLiteralAccessor(Register home_object, | 59 void VisitObjectLiteralAccessor(Register home_object, |
56 ObjectLiteralProperty* property, | 60 ObjectLiteralProperty* property, |
57 Register value_out); | 61 Register value_out); |
58 | 62 |
59 // Dispatched from VisitUnaryOperation. | 63 // Dispatched from VisitUnaryOperation. |
60 void VisitVoid(UnaryOperation* expr); | 64 void VisitVoid(UnaryOperation* expr); |
61 void VisitTypeOf(UnaryOperation* expr); | 65 void VisitTypeOf(UnaryOperation* expr); |
62 void VisitNot(UnaryOperation* expr); | 66 void VisitNot(UnaryOperation* expr); |
63 | 67 |
68 // Visitors for obtaining expression result in the accumulator, in a | |
69 // register, or just getting the effect. | |
70 void VisitForAccumulatorValue(Expression* expression); | |
71 MUST_USE_RESULT Register VisitForRegisterValue(Expression* expression); | |
72 void VisitForEffect(Expression* node); | |
73 | |
74 // Binary expression state machine and load-store tracking. | |
75 void PrepareForBinaryExpression(); | |
76 Register LoadForBinaryExpression(Register reg); | |
77 void StoreForBinaryExpression(Register reg); | |
78 void CompleteBinaryExpression(); | |
79 | |
64 inline BytecodeArrayBuilder* builder() { return &builder_; } | 80 inline BytecodeArrayBuilder* builder() { return &builder_; } |
65 | 81 |
66 inline Isolate* isolate() const { return isolate_; } | 82 inline Isolate* isolate() const { return isolate_; } |
67 inline Zone* zone() const { return zone_; } | 83 inline Zone* zone() const { return zone_; } |
68 | 84 |
69 inline Scope* scope() const { return scope_; } | 85 inline Scope* scope() const { return scope_; } |
70 inline void set_scope(Scope* scope) { scope_ = scope; } | 86 inline void set_scope(Scope* scope) { scope_ = scope; } |
71 inline CompilationInfo* info() const { return info_; } | 87 inline CompilationInfo* info() const { return info_; } |
72 inline void set_info(CompilationInfo* info) { info_ = info; } | 88 inline void set_info(CompilationInfo* info) { info_ = info; } |
73 | 89 |
74 inline ControlScope* execution_control() const { return execution_control_; } | 90 inline ControlScope* execution_control() const { return execution_control_; } |
75 inline void set_execution_control(ControlScope* scope) { | 91 inline void set_execution_control(ControlScope* scope) { |
76 execution_control_ = scope; | 92 execution_control_ = scope; |
77 } | 93 } |
78 inline ContextScope* execution_context() const { return execution_context_; } | 94 inline ContextScope* execution_context() const { return execution_context_; } |
79 inline void set_execution_context(ContextScope* context) { | 95 inline void set_execution_context(ContextScope* context) { |
80 execution_context_ = context; | 96 execution_context_ = context; |
81 } | 97 } |
82 | 98 |
99 void set_result_scope(ExpressionResultScope* result_scope); | |
100 ExpressionResultScope* result_scope() const; | |
101 ExpressionResultScope* parent_result_scope() const; | |
102 TopLevelResultScope* top_level_result_scope() const; | |
103 void set_top_level_result_scope(TopLevelResultScope* result_scope); | |
104 | |
83 ZoneVector<Handle<Object>>* globals() { return &globals_; } | 105 ZoneVector<Handle<Object>>* globals() { return &globals_; } |
84 inline LanguageMode language_mode() const; | 106 inline LanguageMode language_mode() const; |
85 Strength language_mode_strength() const; | 107 Strength language_mode_strength() const; |
86 int feedback_index(FeedbackVectorSlot slot) const; | 108 int feedback_index(FeedbackVectorSlot slot) const; |
87 | 109 |
88 Isolate* isolate_; | 110 Isolate* isolate_; |
89 Zone* zone_; | 111 Zone* zone_; |
90 BytecodeArrayBuilder builder_; | 112 BytecodeArrayBuilder builder_; |
91 CompilationInfo* info_; | 113 CompilationInfo* info_; |
92 Scope* scope_; | 114 Scope* scope_; |
93 ZoneVector<Handle<Object>> globals_; | 115 ZoneVector<Handle<Object>> globals_; |
94 ControlScope* execution_control_; | 116 ControlScope* execution_control_; |
95 ContextScope* execution_context_; | 117 ContextScope* execution_context_; |
118 ExpressionResultScope* result_scope_; | |
119 TopLevelResultScope* top_level_result_scope_; | |
rmcilroy
2015/10/19 12:56:23
This doesn't seem to be used? Can we remove it for
oth
2015/10/20 15:28:53
Removed for now. Having a central reference saves
| |
120 | |
121 int binary_expression_depth_; | |
122 ZoneSet<int> binary_expression_hazard_set_; | |
96 }; | 123 }; |
97 | 124 |
98 } // namespace interpreter | 125 } // namespace interpreter |
99 } // namespace internal | 126 } // namespace internal |
100 } // namespace v8 | 127 } // namespace v8 |
101 | 128 |
102 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 129 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
OLD | NEW |