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 18 matching lines...) Expand all Loading... | |
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 ControlScopeForSwitch; | 34 class ControlScopeForSwitch; |
35 class ExpressionResultScope; | 35 class ExpressionResultScope; |
36 class EffectResultScope; | 36 class EffectResultScope; |
37 class AccumulatorResultScope; | 37 class AccumulatorResultScope; |
38 class RegisterResultScope; | 38 class RegisterResultScope; |
39 class StatementResultScope; | |
39 | 40 |
40 void MakeBytecodeBody(); | 41 void MakeBytecodeBody(); |
41 Register NextContextRegister() const; | 42 Register NextContextRegister() const; |
42 | 43 |
43 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 44 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
44 | 45 |
45 // Dispatched from VisitBinaryOperation. | 46 // Dispatched from VisitBinaryOperation. |
46 void VisitArithmeticExpression(BinaryOperation* binop); | 47 void VisitArithmeticExpression(BinaryOperation* binop); |
47 void VisitCommaExpression(BinaryOperation* binop); | 48 void VisitCommaExpression(BinaryOperation* binop); |
48 void VisitLogicalOrExpression(BinaryOperation* binop); | 49 void VisitLogicalOrExpression(BinaryOperation* binop); |
49 void VisitLogicalAndExpression(BinaryOperation* binop); | 50 void VisitLogicalAndExpression(BinaryOperation* binop); |
50 | 51 |
51 // Dispatched from VisitUnaryOperation. | 52 // Dispatched from VisitUnaryOperation. |
52 void VisitVoid(UnaryOperation* expr); | 53 void VisitVoid(UnaryOperation* expr); |
53 void VisitTypeOf(UnaryOperation* expr); | 54 void VisitTypeOf(UnaryOperation* expr); |
54 void VisitNot(UnaryOperation* expr); | 55 void VisitNot(UnaryOperation* expr); |
55 void VisitDelete(UnaryOperation* expr); | 56 void VisitDelete(UnaryOperation* expr); |
56 | 57 |
58 // Used by flow control routines to evaluate loop condition. | |
59 void VisitCondition(Expression* expr); | |
rmcilroy
2015/11/03 14:17:52
Should this be VisitForCondition or VisitForTest (
oth
2015/11/04 10:03:36
Removed from latest revision as no longer need to
| |
60 | |
57 // Helper visitors which perform common operations. | 61 // Helper visitors which perform common operations. |
58 Register VisitArguments(ZoneList<Expression*>* arguments); | 62 Register VisitArguments(ZoneList<Expression*>* arguments); |
59 | 63 |
60 void VisitPropertyLoad(Register obj, Property* expr); | 64 void VisitPropertyLoad(Register obj, Property* expr); |
61 void VisitPropertyLoadForAccumulator(Register obj, Property* expr); | 65 void VisitPropertyLoadForAccumulator(Register obj, Property* expr); |
62 | 66 |
63 void VisitVariableLoad(Variable* variable, FeedbackVectorSlot slot); | 67 void VisitVariableLoad(Variable* variable, FeedbackVectorSlot slot); |
64 void VisitVariableLoadForAccumulatorValue(Variable* variable, | 68 void VisitVariableLoadForAccumulatorValue(Variable* variable, |
65 FeedbackVectorSlot slot); | 69 FeedbackVectorSlot slot); |
66 MUST_USE_RESULT Register VisitVariableLoadForRegisterValue( | 70 MUST_USE_RESULT Register VisitVariableLoadForRegisterValue( |
67 Variable* variable, FeedbackVectorSlot slot); | 71 Variable* variable, FeedbackVectorSlot slot); |
68 void VisitVariableAssignment(Variable* variable, FeedbackVectorSlot slot); | 72 void VisitVariableAssignment(Variable* variable, FeedbackVectorSlot slot); |
69 | 73 |
70 void VisitArgumentsObject(Variable* variable); | 74 void VisitArgumentsObject(Variable* variable); |
71 void VisitThisFunctionVariable(Variable* variable); | 75 void VisitThisFunctionVariable(Variable* variable); |
72 void VisitNewTargetVariable(Variable* variable); | 76 void VisitNewTargetVariable(Variable* variable); |
73 void VisitNewLocalFunctionContext(); | 77 void VisitNewLocalFunctionContext(); |
74 void VisitBuildLocalActivationContext(); | 78 void VisitBuildLocalActivationContext(); |
75 void VisitNewLocalBlockContext(Scope* scope); | 79 void VisitNewLocalBlockContext(Scope* scope); |
76 void VisitFunctionClosureForContext(); | 80 void VisitFunctionClosureForContext(); |
77 void VisitSetHomeObject(Register value, Register home_object, | 81 void VisitSetHomeObject(Register value, Register home_object, |
78 ObjectLiteralProperty* property, int slot_number = 0); | 82 ObjectLiteralProperty* property, int slot_number = 0); |
79 void VisitObjectLiteralAccessor(Register home_object, | 83 void VisitObjectLiteralAccessor(Register home_object, |
80 ObjectLiteralProperty* property, | 84 ObjectLiteralProperty* property, |
81 Register value_out); | 85 Register value_out); |
82 void VisitForInAssignment(Expression* expr, FeedbackVectorSlot slot); | 86 void VisitForInAssignment(Expression* expr, FeedbackVectorSlot slot); |
83 | 87 void VisitExpressionStatementExpression(Expression* expr); |
rmcilroy
2015/11/03 14:17:52
Unused?
oth
2015/11/04 10:03:37
Done.
| |
84 | 88 |
85 // Visitors for obtaining expression result in the accumulator, in a | 89 // Visitors for obtaining expression result in the accumulator, in a |
86 // register, or just getting the effect. | 90 // register, or just getting the effect. |
87 void VisitForAccumulatorValue(Expression* expression); | 91 void VisitForAccumulatorValue(Expression* expression); |
88 MUST_USE_RESULT Register VisitForRegisterValue(Expression* expression); | 92 MUST_USE_RESULT Register VisitForRegisterValue(Expression* expression); |
89 void VisitForEffect(Expression* node); | 93 void VisitForEffect(Expression* node); |
90 | 94 |
91 // Methods marking the start and end of binary expressions. | |
92 void PrepareForBinaryExpression(); | |
93 void CompleteBinaryExpression(); | |
94 | |
95 // Methods for tracking and remapping register. | 95 // Methods for tracking and remapping register. |
96 void RecordStoreToRegister(Register reg); | 96 void RecordStoreToRegister(Register reg); |
97 Register LoadFromAliasedRegister(Register reg); | 97 Register LoadFromAliasedRegister(Register reg); |
98 | 98 |
99 inline BytecodeArrayBuilder* builder() { return &builder_; } | 99 inline BytecodeArrayBuilder* builder() { return &builder_; } |
100 | 100 |
101 inline Isolate* isolate() const { return isolate_; } | 101 inline Isolate* isolate() const { return isolate_; } |
102 inline Zone* zone() const { return zone_; } | 102 inline Zone* zone() const { return zone_; } |
103 | 103 |
104 inline Scope* scope() const { return scope_; } | 104 inline Scope* scope() const { return scope_; } |
105 inline void set_scope(Scope* scope) { scope_ = scope; } | 105 inline void set_scope(Scope* scope) { scope_ = scope; } |
106 inline CompilationInfo* info() const { return info_; } | 106 inline CompilationInfo* info() const { return info_; } |
107 inline void set_info(CompilationInfo* info) { info_ = info; } | 107 inline void set_info(CompilationInfo* info) { info_ = info; } |
108 | 108 |
109 inline ControlScope* execution_control() const { return execution_control_; } | 109 inline ControlScope* execution_control() const { return execution_control_; } |
110 inline void set_execution_control(ControlScope* scope) { | 110 inline void set_execution_control(ControlScope* scope) { |
111 execution_control_ = scope; | 111 execution_control_ = scope; |
112 } | 112 } |
113 inline ContextScope* execution_context() const { return execution_context_; } | 113 inline ContextScope* execution_context() const { return execution_context_; } |
114 inline void set_execution_context(ContextScope* context) { | 114 inline void set_execution_context(ContextScope* context) { |
115 execution_context_ = context; | 115 execution_context_ = context; |
116 } | 116 } |
117 inline void set_execution_result(ExpressionResultScope* execution_result) { | 117 inline void set_execution_result(ExpressionResultScope* execution_result) { |
118 execution_result_ = execution_result; | 118 execution_result_ = execution_result; |
119 } | 119 } |
120 ExpressionResultScope* execution_result() const { return execution_result_; } | 120 ExpressionResultScope* execution_result() const { return execution_result_; } |
121 | 121 |
122 inline void set_statement_execution_result( | |
123 StatementResultScope* statement_execution_result) { | |
124 statement_execution_result_ = statement_execution_result; | |
125 } | |
126 inline StatementResultScope* statement_execution_result() const { | |
127 return statement_execution_result_; | |
128 } | |
129 | |
122 ZoneVector<Handle<Object>>* globals() { return &globals_; } | 130 ZoneVector<Handle<Object>>* globals() { return &globals_; } |
123 inline LanguageMode language_mode() const; | 131 inline LanguageMode language_mode() const; |
124 Strength language_mode_strength() const; | 132 Strength language_mode_strength() const; |
125 int feedback_index(FeedbackVectorSlot slot) const; | 133 int feedback_index(FeedbackVectorSlot slot) const; |
126 | 134 |
127 Isolate* isolate_; | 135 Isolate* isolate_; |
128 Zone* zone_; | 136 Zone* zone_; |
129 BytecodeArrayBuilder builder_; | 137 BytecodeArrayBuilder builder_; |
130 CompilationInfo* info_; | 138 CompilationInfo* info_; |
131 Scope* scope_; | 139 Scope* scope_; |
132 ZoneVector<Handle<Object>> globals_; | 140 ZoneVector<Handle<Object>> globals_; |
133 ControlScope* execution_control_; | 141 ControlScope* execution_control_; |
134 ContextScope* execution_context_; | 142 ContextScope* execution_context_; |
135 ExpressionResultScope* execution_result_; | 143 ExpressionResultScope* execution_result_; |
136 | 144 StatementResultScope* statement_execution_result_; |
137 int binary_expression_depth_; | |
138 ZoneSet<int> binary_expression_hazard_set_; | |
139 }; | 145 }; |
140 | 146 |
141 } // namespace interpreter | 147 } // namespace interpreter |
142 } // namespace internal | 148 } // namespace internal |
143 } // namespace v8 | 149 } // namespace v8 |
144 | 150 |
145 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 151 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
OLD | NEW |