| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_COMPILER_AST_GRAPH_BUILDER_H_ | 5 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| 6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ | 6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/ast.h" | 10 #include "src/ast.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // other dependencies tracked by the environment might be mutated though. | 71 // other dependencies tracked by the environment might be mutated though. |
| 72 // | 72 // |
| 73 | 73 |
| 74 // Builder to create a local function context. | 74 // Builder to create a local function context. |
| 75 Node* BuildLocalFunctionContext(Node* context, Node* closure); | 75 Node* BuildLocalFunctionContext(Node* context, Node* closure); |
| 76 | 76 |
| 77 // Builder to create an arguments object if it is used. | 77 // Builder to create an arguments object if it is used. |
| 78 Node* BuildArgumentsObject(Variable* arguments); | 78 Node* BuildArgumentsObject(Variable* arguments); |
| 79 | 79 |
| 80 // Builders for variable load and assignment. | 80 // Builders for variable load and assignment. |
| 81 Node* BuildVariableAssignment(Variable* var, Node* value, Token::Value op, | 81 Node* BuildVariableAssignment(Variable* var, Node* value, Token::Value op); |
| 82 BailoutId bailout_id); | |
| 83 Node* BuildVariableDelete(Variable* var); | 82 Node* BuildVariableDelete(Variable* var); |
| 84 Node* BuildVariableLoad(Variable* var, BailoutId bailout_id, | 83 Node* BuildVariableLoad(Variable* var, ContextualMode mode = CONTEXTUAL); |
| 85 ContextualMode mode = CONTEXTUAL); | |
| 86 | 84 |
| 87 // Builders for accessing the function context. | 85 // Builders for accessing the function context. |
| 88 Node* BuildLoadBuiltinsObject(); | 86 Node* BuildLoadBuiltinsObject(); |
| 89 Node* BuildLoadGlobalObject(); | 87 Node* BuildLoadGlobalObject(); |
| 90 Node* BuildLoadClosure(); | 88 Node* BuildLoadClosure(); |
| 91 | 89 |
| 92 // Builders for automatic type conversion. | 90 // Builders for automatic type conversion. |
| 93 Node* BuildToBoolean(Node* value); | 91 Node* BuildToBoolean(Node* value); |
| 94 | 92 |
| 95 // Builders for error reporting at runtime. | 93 // Builders for error reporting at runtime. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 163 |
| 166 // Dispatched from VisitBinaryOperation. | 164 // Dispatched from VisitBinaryOperation. |
| 167 void VisitComma(BinaryOperation* expr); | 165 void VisitComma(BinaryOperation* expr); |
| 168 void VisitLogicalExpression(BinaryOperation* expr); | 166 void VisitLogicalExpression(BinaryOperation* expr); |
| 169 void VisitArithmeticExpression(BinaryOperation* expr); | 167 void VisitArithmeticExpression(BinaryOperation* expr); |
| 170 | 168 |
| 171 // Dispatched from VisitForInStatement. | 169 // Dispatched from VisitForInStatement. |
| 172 void VisitForInAssignment(Expression* expr, Node* value); | 170 void VisitForInAssignment(Expression* expr, Node* value); |
| 173 | 171 |
| 174 void BuildLazyBailout(Node* node, BailoutId ast_id); | 172 void BuildLazyBailout(Node* node, BailoutId ast_id); |
| 175 void BuildLazyBailoutWithPushedNode(Node* node, BailoutId ast_id); | |
| 176 | 173 |
| 177 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 174 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 178 DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder); | 175 DISALLOW_COPY_AND_ASSIGN(AstGraphBuilder); |
| 179 }; | 176 }; |
| 180 | 177 |
| 181 | 178 |
| 182 // The abstract execution environment for generated code consists of | 179 // The abstract execution environment for generated code consists of |
| 183 // parameter variables, local variables and the operand stack. The | 180 // parameter variables, local variables and the operand stack. The |
| 184 // environment will perform proper SSA-renaming of all tracked nodes | 181 // environment will perform proper SSA-renaming of all tracked nodes |
| 185 // at split and merge points in the control flow. Internally all the | 182 // at split and merge points in the control flow. Internally all the |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 // decides how the evaluation result is passed up the visitor. | 275 // decides how the evaluation result is passed up the visitor. |
| 279 class AstGraphBuilder::AstContext BASE_EMBEDDED { | 276 class AstGraphBuilder::AstContext BASE_EMBEDDED { |
| 280 public: | 277 public: |
| 281 bool IsEffect() const { return kind_ == Expression::kEffect; } | 278 bool IsEffect() const { return kind_ == Expression::kEffect; } |
| 282 bool IsValue() const { return kind_ == Expression::kValue; } | 279 bool IsValue() const { return kind_ == Expression::kValue; } |
| 283 bool IsTest() const { return kind_ == Expression::kTest; } | 280 bool IsTest() const { return kind_ == Expression::kTest; } |
| 284 | 281 |
| 285 // Plug a node into this expression context. Call this function in tail | 282 // Plug a node into this expression context. Call this function in tail |
| 286 // position in the Visit functions for expressions. | 283 // position in the Visit functions for expressions. |
| 287 virtual void ProduceValue(Node* value) = 0; | 284 virtual void ProduceValue(Node* value) = 0; |
| 288 virtual void ProduceValueWithLazyBailout(Node* value) = 0; | |
| 289 | 285 |
| 290 // Unplugs a node from this expression context. Call this to retrieve the | 286 // Unplugs a node from this expression context. Call this to retrieve the |
| 291 // result of another Visit function that already plugged the context. | 287 // result of another Visit function that already plugged the context. |
| 292 virtual Node* ConsumeValue() = 0; | 288 virtual Node* ConsumeValue() = 0; |
| 293 | 289 |
| 294 // Shortcut for "context->ProduceValue(context->ConsumeValue())". | 290 // Shortcut for "context->ProduceValue(context->ConsumeValue())". |
| 295 void ReplaceValue() { ProduceValue(ConsumeValue()); } | 291 void ReplaceValue() { ProduceValue(ConsumeValue()); } |
| 296 | 292 |
| 297 protected: | 293 protected: |
| 298 AstContext(AstGraphBuilder* owner, Expression::Context kind, | 294 AstContext(AstGraphBuilder* owner, Expression::Context kind); |
| 299 BailoutId bailout_id); | |
| 300 virtual ~AstContext(); | 295 virtual ~AstContext(); |
| 301 | 296 |
| 302 AstGraphBuilder* owner() const { return owner_; } | 297 AstGraphBuilder* owner() const { return owner_; } |
| 303 Environment* environment() const { return owner_->environment(); } | 298 Environment* environment() const { return owner_->environment(); } |
| 304 | 299 |
| 305 // We want to be able to assert, in a context-specific way, that the stack | 300 // We want to be able to assert, in a context-specific way, that the stack |
| 306 // height makes sense when the context is filled. | 301 // height makes sense when the context is filled. |
| 307 #ifdef DEBUG | 302 #ifdef DEBUG |
| 308 int original_height_; | 303 int original_height_; |
| 309 #endif | 304 #endif |
| 310 | 305 |
| 311 BailoutId bailout_id_; | |
| 312 | |
| 313 private: | 306 private: |
| 314 Expression::Context kind_; | 307 Expression::Context kind_; |
| 315 AstGraphBuilder* owner_; | 308 AstGraphBuilder* owner_; |
| 316 AstContext* outer_; | 309 AstContext* outer_; |
| 317 }; | 310 }; |
| 318 | 311 |
| 319 | 312 |
| 320 // Context to evaluate expression for its side effects only. | 313 // Context to evaluate expression for its side effects only. |
| 321 class AstGraphBuilder::AstEffectContext V8_FINAL : public AstContext { | 314 class AstGraphBuilder::AstEffectContext V8_FINAL : public AstContext { |
| 322 public: | 315 public: |
| 323 explicit AstEffectContext(AstGraphBuilder* owner, BailoutId bailout_id) | 316 explicit AstEffectContext(AstGraphBuilder* owner) |
| 324 : AstContext(owner, Expression::kEffect, bailout_id) {} | 317 : AstContext(owner, Expression::kEffect) {} |
| 325 virtual ~AstEffectContext(); | 318 virtual ~AstEffectContext(); |
| 326 virtual void ProduceValue(Node* value) V8_OVERRIDE; | 319 virtual void ProduceValue(Node* value) V8_OVERRIDE; |
| 327 virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE; | |
| 328 virtual Node* ConsumeValue() V8_OVERRIDE; | 320 virtual Node* ConsumeValue() V8_OVERRIDE; |
| 329 }; | 321 }; |
| 330 | 322 |
| 331 | 323 |
| 332 // Context to evaluate expression for its value (and side effects). | 324 // Context to evaluate expression for its value (and side effects). |
| 333 class AstGraphBuilder::AstValueContext V8_FINAL : public AstContext { | 325 class AstGraphBuilder::AstValueContext V8_FINAL : public AstContext { |
| 334 public: | 326 public: |
| 335 explicit AstValueContext(AstGraphBuilder* owner, BailoutId bailout_id) | 327 explicit AstValueContext(AstGraphBuilder* owner) |
| 336 : AstContext(owner, Expression::kValue, bailout_id) {} | 328 : AstContext(owner, Expression::kValue) {} |
| 337 virtual ~AstValueContext(); | 329 virtual ~AstValueContext(); |
| 338 virtual void ProduceValue(Node* value) V8_OVERRIDE; | 330 virtual void ProduceValue(Node* value) V8_OVERRIDE; |
| 339 virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE; | |
| 340 virtual Node* ConsumeValue() V8_OVERRIDE; | 331 virtual Node* ConsumeValue() V8_OVERRIDE; |
| 341 }; | 332 }; |
| 342 | 333 |
| 343 | 334 |
| 344 // Context to evaluate expression for a condition value (and side effects). | 335 // Context to evaluate expression for a condition value (and side effects). |
| 345 class AstGraphBuilder::AstTestContext V8_FINAL : public AstContext { | 336 class AstGraphBuilder::AstTestContext V8_FINAL : public AstContext { |
| 346 public: | 337 public: |
| 347 explicit AstTestContext(AstGraphBuilder* owner, BailoutId bailout_id) | 338 explicit AstTestContext(AstGraphBuilder* owner) |
| 348 : AstContext(owner, Expression::kTest, bailout_id) {} | 339 : AstContext(owner, Expression::kTest) {} |
| 349 virtual ~AstTestContext(); | 340 virtual ~AstTestContext(); |
| 350 virtual void ProduceValue(Node* value) V8_OVERRIDE; | 341 virtual void ProduceValue(Node* value) V8_OVERRIDE; |
| 351 virtual void ProduceValueWithLazyBailout(Node* value) V8_OVERRIDE; | |
| 352 virtual Node* ConsumeValue() V8_OVERRIDE; | 342 virtual Node* ConsumeValue() V8_OVERRIDE; |
| 353 }; | 343 }; |
| 354 | 344 |
| 355 | 345 |
| 356 // Scoped class tracking breakable statements entered by the visitor. Allows to | 346 // Scoped class tracking breakable statements entered by the visitor. Allows to |
| 357 // properly 'break' and 'continue' iteration statements as well as to 'break' | 347 // properly 'break' and 'continue' iteration statements as well as to 'break' |
| 358 // from blocks within switch statements. | 348 // from blocks within switch statements. |
| 359 class AstGraphBuilder::BreakableScope BASE_EMBEDDED { | 349 class AstGraphBuilder::BreakableScope BASE_EMBEDDED { |
| 360 public: | 350 public: |
| 361 BreakableScope(AstGraphBuilder* owner, BreakableStatement* target, | 351 BreakableScope(AstGraphBuilder* owner, BreakableStatement* target, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 }; | 409 }; |
| 420 | 410 |
| 421 Scope* AstGraphBuilder::current_scope() const { | 411 Scope* AstGraphBuilder::current_scope() const { |
| 422 return execution_context_->scope(); | 412 return execution_context_->scope(); |
| 423 } | 413 } |
| 424 } | 414 } |
| 425 } | 415 } |
| 426 } // namespace v8::internal::compiler | 416 } // namespace v8::internal::compiler |
| 427 | 417 |
| 428 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 418 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| OLD | NEW |