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/bytecode-label.h" | 10 #include "src/interpreter/bytecode-label.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 class ControlScopeForTryCatch; | 46 class ControlScopeForTryCatch; |
47 class ControlScopeForTryFinally; | 47 class ControlScopeForTryFinally; |
48 class CurrentScope; | 48 class CurrentScope; |
49 class ExpressionResultScope; | 49 class ExpressionResultScope; |
50 class EffectResultScope; | 50 class EffectResultScope; |
51 class GlobalDeclarationsBuilder; | 51 class GlobalDeclarationsBuilder; |
52 class RegisterAllocationScope; | 52 class RegisterAllocationScope; |
53 class TestResultScope; | 53 class TestResultScope; |
54 class ValueResultScope; | 54 class ValueResultScope; |
55 | 55 |
| 56 using ToBooleanMode = BytecodeArrayBuilder::ToBooleanMode; |
| 57 |
56 enum class TestFallthrough { kThen, kElse, kNone }; | 58 enum class TestFallthrough { kThen, kElse, kNone }; |
| 59 enum class TypeHint { kAny, kBoolean }; |
57 | 60 |
58 void GenerateBytecodeBody(); | 61 void GenerateBytecodeBody(); |
59 void AllocateDeferredConstants(Isolate* isolate); | 62 void AllocateDeferredConstants(Isolate* isolate); |
60 | 63 |
61 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 64 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
62 | 65 |
63 // Dispatched from VisitBinaryOperation. | 66 // Dispatched from VisitBinaryOperation. |
64 void VisitArithmeticExpression(BinaryOperation* binop); | 67 void VisitArithmeticExpression(BinaryOperation* binop); |
65 void VisitCommaExpression(BinaryOperation* binop); | 68 void VisitCommaExpression(BinaryOperation* binop); |
66 void VisitLogicalOrExpression(BinaryOperation* binop); | 69 void VisitLogicalOrExpression(BinaryOperation* binop); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 LoopBuilder* loop_builder); | 158 LoopBuilder* loop_builder); |
156 void VisitIterationBody(IterationStatement* stmt, LoopBuilder* loop_builder); | 159 void VisitIterationBody(IterationStatement* stmt, LoopBuilder* loop_builder); |
157 | 160 |
158 // Visit a statement and switch scopes, the context is in the accumulator. | 161 // Visit a statement and switch scopes, the context is in the accumulator. |
159 void VisitInScope(Statement* stmt, Scope* scope); | 162 void VisitInScope(Statement* stmt, Scope* scope); |
160 | 163 |
161 void BuildPushUndefinedIntoRegisterList(RegisterList* reg_list); | 164 void BuildPushUndefinedIntoRegisterList(RegisterList* reg_list); |
162 | 165 |
163 // Visitors for obtaining expression result in the accumulator, in a | 166 // Visitors for obtaining expression result in the accumulator, in a |
164 // register, or just getting the effect. | 167 // register, or just getting the effect. |
165 void VisitForAccumulatorValue(Expression* expr); | 168 TypeHint VisitForAccumulatorValue(Expression* expr); |
166 void VisitForAccumulatorValueOrTheHole(Expression* expr); | 169 void VisitForAccumulatorValueOrTheHole(Expression* expr); |
167 MUST_USE_RESULT Register VisitForRegisterValue(Expression* expr); | 170 MUST_USE_RESULT Register VisitForRegisterValue(Expression* expr); |
168 void VisitForRegisterValue(Expression* expr, Register destination); | 171 void VisitForRegisterValue(Expression* expr, Register destination); |
169 void VisitAndPushIntoRegisterList(Expression* expr, RegisterList* reg_list); | 172 void VisitAndPushIntoRegisterList(Expression* expr, RegisterList* reg_list); |
170 void VisitForEffect(Expression* expr); | 173 void VisitForEffect(Expression* expr); |
171 void VisitForTest(Expression* expr, BytecodeLabels* then_labels, | 174 void VisitForTest(Expression* expr, BytecodeLabels* then_labels, |
172 BytecodeLabels* else_labels, TestFallthrough fallthrough); | 175 BytecodeLabels* else_labels, TestFallthrough fallthrough); |
173 | 176 |
174 // Returns the runtime function id for a store to super for the function's | 177 // Returns the runtime function id for a store to super for the function's |
175 // language mode. | 178 // language mode. |
176 inline Runtime::FunctionId StoreToSuperRuntimeId(); | 179 inline Runtime::FunctionId StoreToSuperRuntimeId(); |
177 inline Runtime::FunctionId StoreKeyedToSuperRuntimeId(); | 180 inline Runtime::FunctionId StoreKeyedToSuperRuntimeId(); |
178 | 181 |
| 182 ToBooleanMode ToBooleanModeFromTypeHint(TypeHint type_hint); |
| 183 |
179 inline BytecodeArrayBuilder* builder() const { return builder_; } | 184 inline BytecodeArrayBuilder* builder() const { return builder_; } |
180 inline Zone* zone() const { return zone_; } | 185 inline Zone* zone() const { return zone_; } |
181 inline DeclarationScope* closure_scope() const { return closure_scope_; } | 186 inline DeclarationScope* closure_scope() const { return closure_scope_; } |
182 inline CompilationInfo* info() const { return info_; } | 187 inline CompilationInfo* info() const { return info_; } |
183 inline const AstStringConstants* ast_string_constants() const { | 188 inline const AstStringConstants* ast_string_constants() const { |
184 return ast_string_constants_; | 189 return ast_string_constants_; |
185 } | 190 } |
186 | 191 |
187 inline Scope* current_scope() const { return current_scope_; } | 192 inline Scope* current_scope() const { return current_scope_; } |
188 inline void set_current_scope(Scope* scope) { current_scope_ = scope; } | 193 inline void set_current_scope(Scope* scope) { current_scope_ = scope; } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 ZoneVector<BytecodeLabel> generator_resume_points_; | 237 ZoneVector<BytecodeLabel> generator_resume_points_; |
233 Register generator_state_; | 238 Register generator_state_; |
234 int loop_depth_; | 239 int loop_depth_; |
235 }; | 240 }; |
236 | 241 |
237 } // namespace interpreter | 242 } // namespace interpreter |
238 } // namespace internal | 243 } // namespace internal |
239 } // namespace v8 | 244 } // namespace v8 |
240 | 245 |
241 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ | 246 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ |
OLD | NEW |