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/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 class ControlScopeForBreakable; | 35 class ControlScopeForBreakable; |
36 class ControlScopeForIteration; | 36 class ControlScopeForIteration; |
37 class ControlScopeForTopLevel; | 37 class ControlScopeForTopLevel; |
38 class ControlScopeForTryCatch; | 38 class ControlScopeForTryCatch; |
39 class ControlScopeForTryFinally; | 39 class ControlScopeForTryFinally; |
40 class ExpressionResultScope; | 40 class ExpressionResultScope; |
41 class EffectResultScope; | 41 class EffectResultScope; |
42 class AccumulatorResultScope; | 42 class AccumulatorResultScope; |
43 class RegisterResultScope; | 43 class RegisterResultScope; |
44 class RegisterAllocationScope; | 44 class RegisterAllocationScope; |
| 45 class SuperPropertyArguments; |
45 | 46 |
46 void MakeBytecodeBody(); | 47 void MakeBytecodeBody(); |
47 | 48 |
48 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 49 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
49 | 50 |
50 // Dispatched from VisitBinaryOperation. | 51 // Dispatched from VisitBinaryOperation. |
51 void VisitArithmeticExpression(BinaryOperation* binop); | 52 void VisitArithmeticExpression(BinaryOperation* binop); |
52 void VisitCommaExpression(BinaryOperation* binop); | 53 void VisitCommaExpression(BinaryOperation* binop); |
53 void VisitLogicalOrExpression(BinaryOperation* binop); | 54 void VisitLogicalOrExpression(BinaryOperation* binop); |
54 void VisitLogicalAndExpression(BinaryOperation* binop); | 55 void VisitLogicalAndExpression(BinaryOperation* binop); |
55 | 56 |
56 // Dispatched from VisitUnaryOperation. | 57 // Dispatched from VisitUnaryOperation. |
57 void VisitVoid(UnaryOperation* expr); | 58 void VisitVoid(UnaryOperation* expr); |
58 void VisitTypeOf(UnaryOperation* expr); | 59 void VisitTypeOf(UnaryOperation* expr); |
59 void VisitNot(UnaryOperation* expr); | 60 void VisitNot(UnaryOperation* expr); |
60 void VisitDelete(UnaryOperation* expr); | 61 void VisitDelete(UnaryOperation* expr); |
61 | 62 |
62 // Used by flow control routines to evaluate loop condition. | 63 // Used by flow control routines to evaluate loop condition. |
63 void VisitCondition(Expression* expr); | 64 void VisitCondition(Expression* expr); |
64 | 65 |
65 // Helper visitors which perform common operations. | 66 // Helper visitors which perform common operations. |
66 Register VisitArguments(ZoneList<Expression*>* arguments); | 67 Register VisitArguments(ZoneList<Expression*>* arguments); |
67 | 68 |
| 69 // Visit a keyed super property load. The optional |
| 70 // |opt_receiver_out| register will have the receiver stored to it |
| 71 // if it's a valid register. The loaded value is placed in the |
| 72 // accumulator. |
| 73 void VisitKeyedSuperPropertyLoad(Property* property, |
| 74 Register opt_receiver_out); |
| 75 |
| 76 // Visit a named super property load. The optional |
| 77 // |opt_receiver_out| register will have the receiver stored to it |
| 78 // if it's a valid register. The loaded value is placed in the |
| 79 // accumulator. |
| 80 void VisitNamedSuperPropertyLoad(Property* property, |
| 81 Register opt_receiver_out); |
| 82 |
68 void VisitPropertyLoad(Register obj, Property* expr); | 83 void VisitPropertyLoad(Register obj, Property* expr); |
69 void VisitPropertyLoadForAccumulator(Register obj, Property* expr); | 84 void VisitPropertyLoadForAccumulator(Register obj, Property* expr); |
70 | 85 |
71 void VisitVariableLoad(Variable* variable, FeedbackVectorSlot slot, | 86 void VisitVariableLoad(Variable* variable, FeedbackVectorSlot slot, |
72 TypeofMode typeof_mode = NOT_INSIDE_TYPEOF); | 87 TypeofMode typeof_mode = NOT_INSIDE_TYPEOF); |
73 void VisitVariableLoadForAccumulatorValue( | 88 void VisitVariableLoadForAccumulatorValue( |
74 Variable* variable, FeedbackVectorSlot slot, | 89 Variable* variable, FeedbackVectorSlot slot, |
75 TypeofMode typeof_mode = NOT_INSIDE_TYPEOF); | 90 TypeofMode typeof_mode = NOT_INSIDE_TYPEOF); |
76 MUST_USE_RESULT Register | 91 MUST_USE_RESULT Register |
77 VisitVariableLoadForRegisterValue(Variable* variable, FeedbackVectorSlot slot, | 92 VisitVariableLoadForRegisterValue(Variable* variable, FeedbackVectorSlot slot, |
78 TypeofMode typeof_mode = NOT_INSIDE_TYPEOF); | 93 TypeofMode typeof_mode = NOT_INSIDE_TYPEOF); |
79 void VisitVariableAssignment(Variable* variable, Token::Value op, | 94 void VisitVariableAssignment(Variable* variable, Token::Value op, |
80 FeedbackVectorSlot slot); | 95 FeedbackVectorSlot slot); |
| 96 |
| 97 void PrepareNamedSuperPropertyArguments( |
| 98 SuperPropertyReference* super_property, Handle<Name> name, |
| 99 SuperPropertyArguments* super_property_args); |
| 100 void PrepareKeyedSuperPropertyArguments( |
| 101 SuperPropertyReference* super_property, Expression* key, |
| 102 SuperPropertyArguments* super_property_args); |
| 103 void BuildNamedSuperPropertyLoad(SuperPropertyArguments* super_property_args); |
| 104 void BuildKeyedSuperPropertyLoad(SuperPropertyArguments* super_property_args); |
| 105 void BuildNamedSuperPropertyStore( |
| 106 SuperPropertyArguments* super_property_args); |
| 107 void BuildKeyedSuperPropertyStore( |
| 108 SuperPropertyArguments* super_property_args); |
| 109 |
81 void BuildThrowIfHole(Handle<String> name); | 110 void BuildThrowIfHole(Handle<String> name); |
82 void BuildThrowIfNotHole(Handle<String> name); | 111 void BuildThrowIfNotHole(Handle<String> name); |
83 void BuildThrowReassignConstant(Handle<String> name); | 112 void BuildThrowReassignConstant(Handle<String> name); |
84 void BuildHoleCheckForVariableLoad(VariableMode mode, Handle<String> name); | 113 void BuildHoleCheckForVariableLoad(VariableMode mode, Handle<String> name); |
85 void BuildHoleCheckForVariableAssignment(Variable* variable, Token::Value op); | 114 void BuildHoleCheckForVariableAssignment(Variable* variable, Token::Value op); |
86 | 115 |
87 void VisitArgumentsObject(Variable* variable); | 116 void VisitArgumentsObject(Variable* variable); |
88 void VisitRestArgumentsArray(Variable* rest); | 117 void VisitRestArgumentsArray(Variable* rest); |
| 118 void VisitCallSuper(Call* call); |
89 void VisitClassLiteralContents(ClassLiteral* expr); | 119 void VisitClassLiteralContents(ClassLiteral* expr); |
90 void VisitClassLiteralForRuntimeDefinition(ClassLiteral* expr); | 120 void VisitClassLiteralForRuntimeDefinition(ClassLiteral* expr); |
91 void VisitClassLiteralProperties(ClassLiteral* expr, Register literal, | 121 void VisitClassLiteralProperties(ClassLiteral* expr, Register literal, |
92 Register prototype); | 122 Register prototype); |
93 void VisitClassLiteralStaticPrototypeWithComputedName(Register name); | 123 void VisitClassLiteralStaticPrototypeWithComputedName(Register name); |
94 void VisitThisFunctionVariable(Variable* variable); | 124 void VisitThisFunctionVariable(Variable* variable); |
95 void VisitNewTargetVariable(Variable* variable); | 125 void VisitNewTargetVariable(Variable* variable); |
96 void VisitNewLocalFunctionContext(); | 126 void VisitNewLocalFunctionContext(); |
97 void VisitBuildLocalActivationContext(); | 127 void VisitBuildLocalActivationContext(); |
98 void VisitBlockDeclarationsAndStatements(Block* stmt); | 128 void VisitBlockDeclarationsAndStatements(Block* stmt); |
(...skipping 22 matching lines...) Expand all Loading... |
121 void VisitForEffect(Expression* expr); | 151 void VisitForEffect(Expression* expr); |
122 | 152 |
123 // Methods for tracking and remapping register. | 153 // Methods for tracking and remapping register. |
124 void RecordStoreToRegister(Register reg); | 154 void RecordStoreToRegister(Register reg); |
125 Register LoadFromAliasedRegister(Register reg); | 155 Register LoadFromAliasedRegister(Register reg); |
126 | 156 |
127 // Methods for tracking try-block nesting. | 157 // Methods for tracking try-block nesting. |
128 bool IsInsideTryCatch() const { return try_catch_nesting_level_ > 0; } | 158 bool IsInsideTryCatch() const { return try_catch_nesting_level_ > 0; } |
129 bool IsInsideTryFinally() const { return try_finally_nesting_level_ > 0; } | 159 bool IsInsideTryFinally() const { return try_finally_nesting_level_ > 0; } |
130 | 160 |
| 161 // Initialize an array of temporary registers with consecutive registers. |
| 162 template <size_t N> |
| 163 void InitializeWithConsecutiveRegisters(Register (®isters)[N]); |
| 164 |
131 inline void set_builder(BytecodeArrayBuilder* builder) { builder_ = builder; } | 165 inline void set_builder(BytecodeArrayBuilder* builder) { builder_ = builder; } |
132 inline BytecodeArrayBuilder* builder() const { return builder_; } | 166 inline BytecodeArrayBuilder* builder() const { return builder_; } |
133 | 167 |
134 inline Isolate* isolate() const { return isolate_; } | 168 inline Isolate* isolate() const { return isolate_; } |
135 inline Zone* zone() const { return zone_; } | 169 inline Zone* zone() const { return zone_; } |
136 | 170 |
137 inline Scope* scope() const { return scope_; } | 171 inline Scope* scope() const { return scope_; } |
138 inline void set_scope(Scope* scope) { scope_ = scope; } | 172 inline void set_scope(Scope* scope) { scope_ = scope; } |
139 inline CompilationInfo* info() const { return info_; } | 173 inline CompilationInfo* info() const { return info_; } |
140 inline void set_info(CompilationInfo* info) { info_ = info; } | 174 inline void set_info(CompilationInfo* info) { info_ = info; } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 RegisterAllocationScope* register_allocator_; | 210 RegisterAllocationScope* register_allocator_; |
177 int try_catch_nesting_level_; | 211 int try_catch_nesting_level_; |
178 int try_finally_nesting_level_; | 212 int try_finally_nesting_level_; |
179 }; | 213 }; |
180 | 214 |
181 } // namespace interpreter | 215 } // namespace interpreter |
182 } // namespace internal | 216 } // namespace internal |
183 } // namespace v8 | 217 } // namespace v8 |
184 | 218 |
185 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 219 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
OLD | NEW |