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); |
81 | 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 |
82 void BuildThrowIfHole(Handle<String> name); | 110 void BuildThrowIfHole(Handle<String> name); |
83 void BuildThrowIfNotHole(Handle<String> name); | 111 void BuildThrowIfNotHole(Handle<String> name); |
84 void BuildThrowReassignConstant(Handle<String> name); | 112 void BuildThrowReassignConstant(Handle<String> name); |
85 void BuildThrowReferenceError(Handle<String> name); | 113 void BuildThrowReferenceError(Handle<String> name); |
86 void BuildHoleCheckForVariableLoad(VariableMode mode, Handle<String> name); | 114 void BuildHoleCheckForVariableLoad(VariableMode mode, Handle<String> name); |
87 void BuildHoleCheckForVariableAssignment(Variable* variable, Token::Value op); | 115 void BuildHoleCheckForVariableAssignment(Variable* variable, Token::Value op); |
88 | 116 |
89 void VisitArgumentsObject(Variable* variable); | 117 void VisitArgumentsObject(Variable* variable); |
90 void VisitRestArgumentsArray(Variable* rest); | 118 void VisitRestArgumentsArray(Variable* rest); |
| 119 void VisitCallSuper(Call* call); |
91 void VisitClassLiteralContents(ClassLiteral* expr); | 120 void VisitClassLiteralContents(ClassLiteral* expr); |
92 void VisitClassLiteralForRuntimeDefinition(ClassLiteral* expr); | 121 void VisitClassLiteralForRuntimeDefinition(ClassLiteral* expr); |
93 void VisitClassLiteralProperties(ClassLiteral* expr, Register literal, | 122 void VisitClassLiteralProperties(ClassLiteral* expr, Register literal, |
94 Register prototype); | 123 Register prototype); |
95 void VisitClassLiteralStaticPrototypeWithComputedName(Register name); | 124 void VisitClassLiteralStaticPrototypeWithComputedName(Register name); |
96 void VisitThisFunctionVariable(Variable* variable); | 125 void VisitThisFunctionVariable(Variable* variable); |
97 void VisitNewTargetVariable(Variable* variable); | 126 void VisitNewTargetVariable(Variable* variable); |
98 void VisitNewLocalFunctionContext(); | 127 void VisitNewLocalFunctionContext(); |
99 void VisitBuildLocalActivationContext(); | 128 void VisitBuildLocalActivationContext(); |
100 void VisitBlockDeclarationsAndStatements(Block* stmt); | 129 void VisitBlockDeclarationsAndStatements(Block* stmt); |
(...skipping 22 matching lines...) Expand all Loading... |
123 void VisitForEffect(Expression* expr); | 152 void VisitForEffect(Expression* expr); |
124 | 153 |
125 // Methods for tracking and remapping register. | 154 // Methods for tracking and remapping register. |
126 void RecordStoreToRegister(Register reg); | 155 void RecordStoreToRegister(Register reg); |
127 Register LoadFromAliasedRegister(Register reg); | 156 Register LoadFromAliasedRegister(Register reg); |
128 | 157 |
129 // Methods for tracking try-block nesting. | 158 // Methods for tracking try-block nesting. |
130 bool IsInsideTryCatch() const { return try_catch_nesting_level_ > 0; } | 159 bool IsInsideTryCatch() const { return try_catch_nesting_level_ > 0; } |
131 bool IsInsideTryFinally() const { return try_finally_nesting_level_ > 0; } | 160 bool IsInsideTryFinally() const { return try_finally_nesting_level_ > 0; } |
132 | 161 |
| 162 // Initialize an array of temporary registers with consecutive registers. |
| 163 template <size_t N> |
| 164 void InitializeWithConsecutiveRegisters(Register (®isters)[N]); |
| 165 |
133 inline void set_builder(BytecodeArrayBuilder* builder) { builder_ = builder; } | 166 inline void set_builder(BytecodeArrayBuilder* builder) { builder_ = builder; } |
134 inline BytecodeArrayBuilder* builder() const { return builder_; } | 167 inline BytecodeArrayBuilder* builder() const { return builder_; } |
135 | 168 |
136 inline Isolate* isolate() const { return isolate_; } | 169 inline Isolate* isolate() const { return isolate_; } |
137 inline Zone* zone() const { return zone_; } | 170 inline Zone* zone() const { return zone_; } |
138 | 171 |
139 inline Scope* scope() const { return scope_; } | 172 inline Scope* scope() const { return scope_; } |
140 inline void set_scope(Scope* scope) { scope_ = scope; } | 173 inline void set_scope(Scope* scope) { scope_ = scope; } |
141 inline CompilationInfo* info() const { return info_; } | 174 inline CompilationInfo* info() const { return info_; } |
142 inline void set_info(CompilationInfo* info) { info_ = info; } | 175 inline void set_info(CompilationInfo* info) { info_ = info; } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 RegisterAllocationScope* register_allocator_; | 211 RegisterAllocationScope* register_allocator_; |
179 int try_catch_nesting_level_; | 212 int try_catch_nesting_level_; |
180 int try_finally_nesting_level_; | 213 int try_finally_nesting_level_; |
181 }; | 214 }; |
182 | 215 |
183 } // namespace interpreter | 216 } // namespace interpreter |
184 } // namespace internal | 217 } // namespace internal |
185 } // namespace v8 | 218 } // namespace v8 |
186 | 219 |
187 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 220 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
OLD | NEW |